[llvm] [InstCombine] Fix FMF propagation in `foldSelectIntoOp` (PR #114356)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 08:16:39 PDT 2024


================
@@ -564,6 +561,8 @@ Instruction *InstCombinerImpl::foldSelectIntoOp(SelectInst &SI, Value *TrueVal,
     BinaryOperator *BO =
         BinaryOperator::Create(TVI->getOpcode(), FalseVal, NewSel);
     BO->copyIRFlags(TVI);
+    if (isa<FPMathOperator>(&SI))
+      BO->andIRFlags(NewSel);
----------------
arsenm wrote:

This API is so clumsy.

We could preserve more value flags if the same operands appear in both instructions, but that's probably not worth the complexity 

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


More information about the llvm-commits mailing list