[llvm] [InstCombine] Fix for folding `select` into floating point binary operators. (PR #83200)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 15:09:36 PST 2024


================
@@ -527,8 +527,11 @@ Instruction *InstCombinerImpl::foldSelectIntoOp(SelectInst &SI, Value *TrueVal,
     // instructions have different flags and add tests to ensure the
     // behaviour is correct.
     FastMathFlags FMF;
-    if (isa<FPMathOperator>(&SI))
+    if (isa<FPMathOperator>(&SI)) {
       FMF = SI.getFastMathFlags();
+      if (!computeKnownFPClass(FalseVal, FMF, fcNan, &SI).isKnownNeverNaN())
----------------
goldsteinn wrote:

Think it be better to place this below after line 543 to avoid relatively expensive analysis until after all the basic checks have been performed.

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


More information about the llvm-commits mailing list