[llvm] [InstCombine] Enable factorizeMinMaxTree for floating-point values (PR #193195)

Thomas Fry via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 21 08:02:35 PDT 2026


================
@@ -1481,7 +1481,23 @@ static Instruction *factorizeMinMaxTree(IntrinsicInst *II) {
   Module *Mod = II->getModule();
   Function *MinMax =
       Intrinsic::getOrInsertDeclaration(Mod, MinMaxID, II->getType());
-  return CallInst::Create(MinMax, { MinMaxOp, ThirdOp });
+  Instruction *RetI = CallInst::Create(MinMax, {MinMaxOp, ThirdOp});
+  if (isa<FPMathOperator>(II)) {
+    FastMathFlags IIFMF = II->getFastMathFlags();
+    FastMathFlags FoldedOpFMF =
+        (MinMaxOp == LHS ? RHS : LHS)->getFastMathFlags();
----------------
thofry wrote:

I'm not entirely sure what you mean but I think that it would be better done in a separate commit. I believe this transformation would be transparent to `isKnownNeverNaN`'s analysis.

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


More information about the llvm-commits mailing list