[llvm] [InstCombine] Fold `X > C2 ? X + C1 : C2 + C1` to `max(X, C2) + C1` (PR #116888)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 22 06:37:21 PST 2024
================
@@ -1898,6 +1898,69 @@ static Instruction *foldSelectICmpEq(SelectInst &SI, ICmpInst *ICI,
return nullptr;
}
+// Turn select (Cmp X C1) (BOp X C2) C3
+// -> BOp (min/max X C1) C2
+// iff C3 == BOp C1 C2
+// This allows for better canonicalization.
+static Value *canonicalizeConstToBOp(ICmpInst *Cmp, Value *TrueVal,
+ Value *FalseVal,
+ InstCombiner::BuilderTy &Builder) {
----------------
nikic wrote:
```suggestion
IRBuilderBase &Builder) {
```
https://github.com/llvm/llvm-project/pull/116888
More information about the llvm-commits
mailing list