[clang] [llvm] [InstCombine] Fold `X > C2 ? X + C1 : C2 + C1` to `max(X, C2) + C1` (PR #116888)
Yingwei Zheng via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 25 23:47:59 PST 2024
================
@@ -1793,10 +1793,9 @@ define i32 @not_uadd_sat(i32 %x, i32 %y) {
define i32 @not_uadd_sat2(i32 %x, i32 %y) {
; CHECK-LABEL: @not_uadd_sat2(
-; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], -2
-; CHECK-NEXT: [[C:%.*]] = icmp ugt i32 [[X]], 1
-; CHECK-NEXT: [[R:%.*]] = select i1 [[C]], i32 [[A]], i32 -1
-; CHECK-NEXT: ret i32 [[R]]
+; CHECK-NEXT: [[X:%.*]] = call i32 @llvm.umax.i32(i32 [[X1:%.*]], i32 1)
----------------
dtcxzyw wrote:
You can convert the icmp into `icmp ule i32 %x, 1` with `getFlippedStrictnessPredicateAndConstant`.
https://github.com/llvm/llvm-project/pull/116888
More information about the cfe-commits
mailing list