[llvm] [InstCombine] Don't copy ninf when narrowing fptrunc(binop(fpext, fpext)) (PR #202489)

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 14:50:47 PDT 2026


================
@@ -2200,6 +2206,12 @@ Instruction *InstCombinerImpl::visitFPTrunc(FPTruncInst &FPT) {
     unsigned RHSWidth = RHSMinType->getFPMantissaWidth();
     unsigned SrcWidth = std::max(LHSWidth, RHSWidth);
     unsigned DstWidth = Ty->getFPMantissaWidth();
+
+    // Narrowing recomputes the binop in a smaller type, which can overflow to
+    // inf where the wide op was finite. Therefore we have to drop ninf.
+    FastMathFlags NarrowFMF = BO->getFastMathFlags();
+    NarrowFMF.setNoInfs(false);
----------------
jlebar wrote:

Better, done, thanks.

https://github.com/llvm/llvm-project/pull/202489


More information about the llvm-commits mailing list