[llvm] [InstCombine] Make fptrunc combine use union of fast math flags (PR #118808)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 06:16:09 PST 2024


================
@@ -1847,15 +1847,16 @@ Instruction *InstCombinerImpl::visitFPTrunc(FPTruncInst &FPT) {
   Value *X;
   Instruction *Op = dyn_cast<Instruction>(FPT.getOperand(0));
   if (Op && Op->hasOneUse()) {
-    // FIXME: The FMF should propagate from the fptrunc, not the source op.
     IRBuilder<>::FastMathFlagGuard FMFG(Builder);
+    FastMathFlags FMF = FPT.getFastMathFlags();
     if (isa<FPMathOperator>(Op))
-      Builder.setFastMathFlags(Op->getFastMathFlags());
+      FMF &= Op->getFastMathFlags();
----------------
arsenm wrote:

Description says union but this is intersection.Also dyn_cast to FPMathOperator and query flags from that, this is effectively isa + cast 

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


More information about the llvm-commits mailing list