[llvm] [InstCombine] Relax guard against FP min/max in select fold (PR #143144)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 07:14:26 PDT 2025


================
@@ -1729,7 +1729,8 @@ Instruction *InstCombinerImpl::FoldOpIntoSelect(Instruction &Op, SelectInst *SI,
   if (auto *CI = dyn_cast<FCmpInst>(SI->getCondition())) {
     if (CI->hasOneUse()) {
       Value *Op0 = CI->getOperand(0), *Op1 = CI->getOperand(1);
-      if ((TV == Op0 && FV == Op1) || (FV == Op0 && TV == Op1))
+      if (((TV == Op0 && FV == Op1) || (FV == Op0 && TV == Op1)) &&
+          !CI->isEquality() && !CI->isCommutative())
----------------
dtcxzyw wrote:

```suggestion
          !CI->isCommutative())
```
`isEquality` implies `isCommutative`.


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


More information about the llvm-commits mailing list