================
@@ -1875,13 +1873,17 @@ Instruction *InstCombinerImpl::visitFPTrunc(FPTruncInst 
&FPT) {
       // fptrunc (select Cond, (fpext X), Y --> select Cond, X, (fptrunc Y)
       Value *NarrowY = Builder.CreateFPTrunc(Y, Ty);
       Value *Sel = Builder.CreateSelect(Cond, X, NarrowY, "narrow.sel", Op);
+      if (auto *I = dyn_cast<Instruction>(Sel))
+        I->setFastMathFlags(Op->getFastMathFlags());
       return replaceInstUsesWith(FPT, Sel);
     }
     if (match(Op, m_Select(m_Value(Cond), m_Value(Y), m_FPExt(m_Value(X)))) &&
         X->getType() == Ty) {
       // fptrunc (select Cond, Y, (fpext X) --> select Cond, (fptrunc Y), X
       Value *NarrowY = Builder.CreateFPTrunc(Y, Ty);
       Value *Sel = Builder.CreateSelect(Cond, NarrowY, X, "narrow.sel", Op);
+      if (auto *I = dyn_cast<Instruction>(Sel))
+        I->setFastMathFlags(Op->getFastMathFlags());
----------------
john-brawn-arm wrote:

Do you mean these specific changes for setting the fast math flag on select 
instructions, or also the change at the top of visitFPTrunc to set the fast 
math flags in the builder based on the fptrunc? Either way it causes failures 
in the llvm/test/Transforms/InstCombine/fpcast.ll and 
llvm/test/Transforms/InstCombine/fptrunc.ll tests. Without setting the fast 
math flags in the select the failures are because the select gets the fast math 
flags from the fptrunc. Without setting the flags in the builder the opposite 
happens and the fptrunc gets the fast math flags from the select.

https://github.com/llvm/llvm-project/pull/115894
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to