[llvm] [InstCombine] Fold redundant FP clamp selects; relax min-max-pattern bailout in visitFCmp (PR #173452)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 24 05:28:39 PST 2025
================
@@ -8679,6 +8679,40 @@ static Instruction *foldFCmpWithFloorAndCeil(FCmpInst &I,
return nullptr;
}
+/// Returns true if a select that implements a min/max is redundant and
+/// select result can be replaced with its non-constant operand, e.g.,
+/// select ( (si/ui-to-fp A) <= C ), C, (si/ui-to-fp A)
+/// where C is the FP constant equal to the minimum integer value
+/// representable by A.
+static bool isMinMaxCmpSelectEliminable(SelectPatternFlavor Flavor, Value *A,
+ Value *B) {
+ Constant *C = dyn_cast<Constant>(B);
+ if (isa<Constant>(A) || !C)
+ return false;
+
+ if (C->getType()->isVectorTy())
+ C = C->getSplatValue();
+ auto *CFP = dyn_cast_or_null<ConstantFP>(C);
+ if (!CFP)
+ return false;
----------------
dtcxzyw wrote:
```suggestion
ConstantFP *CFP;
if (!match(B, m_APFloat(CFP)))
return false;
```
https://github.com/llvm/llvm-project/pull/173452
More information about the llvm-commits
mailing list