[llvm] [InstCombine] Fold unsigned icmp of nuw adds with constants (PR #226685)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 26 05:27:09 PDT 2026
https://github.com/aswinkaliesrm created https://github.com/llvm/llvm-project/pull/226685
Fixes #220238.
foldICmpBinOp already turns
icmp (A + C1), (C + C2) -> icmp (A + (C1 - C2)), C (or the mirrored form)
for signed and equality predicates, but skipped unsigned ones because of the
!I.isUnsigned() check.
For unsigned predicates hasNoWrapProblem already requires both adds to be nuw,
so the smaller constant can be subtracted from both sides. The new add can keep
nuw since its constant is smaller than the original one.
The signed path decides using the sign bits and abs() of the constants, which
doesn't make sense for unsigned values (e.g. add nuw %x, 200 vs add nuw %y, 100
is rejected there), so I added a separate branch that compares C1 and C2 with uge.
With this, the reproducer from the issue now simplifies to icmp ult %off, 59.
disjoint_or_ugt_3 in icmp.ll also folds now.
Alive2:
C1 >= C2: [proof1](https://alive2.llvm.org/ce/z/HGv_gs)
C1 < C2: [proof2](https://alive2.llvm.org/ce/z/npLnut)
Tests are precommitted in the first commit.
>From 931cc81261381c360ba3704f283ab41434390e6e Mon Sep 17 00:00:00 2001
From: Aswin Kalies <aswinkliesrm at gmail.com>
Date: Sat, 26 Sep 2026 17:28:26 +0530
Subject: [PATCH 1/2] [InstCombine] Add tests for unsigned icmp of nuw adds
with constants (NFC)
Precommit tests for #220238: unsigned versions of the existing
icmp_add20_sge_add57 / icmp_sub57_sge_sub20 tests, plus negative tests
for missing nuw, nsw-only, multiple uses and non-splat vectors.
---
llvm/test/Transforms/InstCombine/icmp.ll | 195 +++++++++++++++++++++++
1 file changed, 195 insertions(+)
diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll
index c7bae58a0b197..321d39e01a6ee 100644
--- a/llvm/test/Transforms/InstCombine/icmp.ll
+++ b/llvm/test/Transforms/InstCombine/icmp.ll
@@ -2321,6 +2321,201 @@ define <2 x i1> @icmp_sub57_sge_sub20_vec_nonsplat(<2 x i32> %x, <2 x i32> %y) {
ret <2 x i1> %cmp
}
+; Unsigned versions of the above: with nuw on both adds, the smaller
+; constant can be subtracted from both sides.
+
+define i1 @icmp_add20_uge_add57(i8 %x, i8 %y) {
+; CHECK-LABEL: define i1 @icmp_add20_uge_add57(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 20
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 57
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %1 = add nuw i8 %x, 20
+ %2 = add nuw i8 %y, 57
+ %cmp = icmp uge i8 %1, %2
+ ret i1 %cmp
+}
+
+define i1 @icmp_add57_ult_add20(i8 %x, i8 %y) {
+; CHECK-LABEL: define i1 @icmp_add57_ult_add20(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 57
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 20
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %1 = add nuw i8 %x, 57
+ %2 = add nuw i8 %y, 20
+ %cmp = icmp ult i8 %1, %2
+ ret i1 %cmp
+}
+
+define i1 @icmp_add20_ule_add20(i8 %x, i8 %y) {
+; CHECK-LABEL: define i1 @icmp_add20_ule_add20(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X]], [[Y]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %1 = add nuw i8 %x, 20
+ %2 = add nuw i8 %y, 20
+ %cmp = icmp ule i8 %1, %2
+ ret i1 %cmp
+}
+
+; The constants have different sign bits, which the signed fold rejects.
+define i1 @icmp_add200_ugt_add100(i8 %x, i8 %y) {
+; CHECK-LABEL: define i1 @icmp_add200_ugt_add100(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], -56
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 100
+; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %1 = add nuw i8 %x, 200
+ %2 = add nuw i8 %y, 100
+ %cmp = icmp ugt i8 %1, %2
+ ret i1 %cmp
+}
+
+define <2 x i1> @icmp_add20_uge_add57_splat(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: define <2 x i1> @icmp_add20_uge_add57_splat(
+; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw <2 x i8> [[X]], splat (i8 20)
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw <2 x i8> [[Y]], splat (i8 57)
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge <2 x i8> [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret <2 x i1> [[CMP]]
+;
+ %1 = add nuw <2 x i8> %x, <i8 20, i8 20>
+ %2 = add nuw <2 x i8> %y, <i8 57, i8 57>
+ %cmp = icmp uge <2 x i8> %1, %2
+ ret <2 x i1> %cmp
+}
+
+define <2 x i1> @icmp_add20_uge_add57_poison(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: define <2 x i1> @icmp_add20_uge_add57_poison(
+; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw <2 x i8> [[X]], splat (i8 20)
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw <2 x i8> [[Y]], <i8 57, i8 poison>
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge <2 x i8> [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret <2 x i1> [[CMP]]
+;
+ %1 = add nuw <2 x i8> %x, <i8 20, i8 20>
+ %2 = add nuw <2 x i8> %y, <i8 57, i8 poison>
+ %cmp = icmp uge <2 x i8> %1, %2
+ ret <2 x i1> %cmp
+}
+
+define <2 x i1> @icmp_add20_uge_add57_vec_nonsplat(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: define <2 x i1> @icmp_add20_uge_add57_vec_nonsplat(
+; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw <2 x i8> [[X]], <i8 20, i8 19>
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw <2 x i8> [[Y]], <i8 57, i8 58>
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge <2 x i8> [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret <2 x i1> [[CMP]]
+;
+ %1 = add nuw <2 x i8> %x, <i8 20, i8 19>
+ %2 = add nuw <2 x i8> %y, <i8 57, i8 58>
+ %cmp = icmp uge <2 x i8> %1, %2
+ ret <2 x i1> %cmp
+}
+
+define i1 @icmp_add20_uge_add57_extra_use(i8 %x, i8 %y) {
+; CHECK-LABEL: define i1 @icmp_add20_uge_add57_extra_use(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 20
+; CHECK-NEXT: call void @use_i8(i8 [[TMP1]])
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 57
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %1 = add nuw i8 %x, 20
+ call void @use_i8(i8 %1)
+ %2 = add nuw i8 %y, 57
+ %cmp = icmp uge i8 %1, %2
+ ret i1 %cmp
+}
+
+define i1 @icmp_add20_uge_add57_extra_uses(i8 %x, i8 %y) {
+; CHECK-LABEL: define i1 @icmp_add20_uge_add57_extra_uses(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 20
+; CHECK-NEXT: call void @use_i8(i8 [[TMP1]])
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 57
+; CHECK-NEXT: call void @use_i8(i8 [[TMP2]])
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %1 = add nuw i8 %x, 20
+ call void @use_i8(i8 %1)
+ %2 = add nuw i8 %y, 57
+ call void @use_i8(i8 %2)
+ %cmp = icmp uge i8 %1, %2
+ ret i1 %cmp
+}
+
+define i1 @icmp_add20_uge_add57_no_nuw_lhs(i8 %x, i8 %y) {
+; CHECK-LABEL: define i1 @icmp_add20_uge_add57_no_nuw_lhs(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[X]], 20
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 57
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %1 = add i8 %x, 20
+ %2 = add nuw i8 %y, 57
+ %cmp = icmp uge i8 %1, %2
+ ret i1 %cmp
+}
+
+define i1 @icmp_add20_uge_add57_no_nuw_rhs(i8 %x, i8 %y) {
+; CHECK-LABEL: define i1 @icmp_add20_uge_add57_no_nuw_rhs(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 20
+; CHECK-NEXT: [[TMP2:%.*]] = add i8 [[Y]], 57
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %1 = add nuw i8 %x, 20
+ %2 = add i8 %y, 57
+ %cmp = icmp uge i8 %1, %2
+ ret i1 %cmp
+}
+
+define i1 @icmp_add20_uge_add57_nsw(i8 %x, i8 %y) {
+; CHECK-LABEL: define i1 @icmp_add20_uge_add57_nsw(
+; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
+; CHECK-NEXT: [[TMP1:%.*]] = add nsw i8 [[X]], 20
+; CHECK-NEXT: [[TMP2:%.*]] = add nsw i8 [[Y]], 57
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %1 = add nsw i8 %x, 20
+ %2 = add nsw i8 %y, 57
+ %cmp = icmp uge i8 %1, %2
+ ret i1 %cmp
+}
+
+; After moving the constants, the common %base cancels out.
+define i1 @icmp_add_nuw_common_base_ule(i8 %base, i8 %off) {
+; CHECK-LABEL: define i1 @icmp_add_nuw_common_base_ule(
+; CHECK-SAME: i8 [[BASE:%.*]], i8 [[OFF:%.*]]) {
+; CHECK-NEXT: [[A:%.*]] = add nuw i8 [[BASE]], [[OFF]]
+; CHECK-NEXT: call void @use_i8(i8 [[A]])
+; CHECK-NEXT: [[B:%.*]] = add nuw i8 [[A]], 4
+; CHECK-NEXT: [[C:%.*]] = add nuw i8 [[BASE]], 62
+; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[B]], [[C]]
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %a = add nuw i8 %base, %off
+ call void @use_i8(i8 %a)
+ %b = add nuw i8 %a, 4
+ %c = add nuw i8 %base, 62
+ %cmp = icmp ule i8 %b, %c
+ ret i1 %cmp
+}
+
define i1 @icmp_and_shl_neg_ne_0(i32 %A, i32 %B) {
; CHECK-LABEL: define i1 @icmp_and_shl_neg_ne_0(
; CHECK-SAME: i32 [[A:%.*]], i32 [[B:%.*]]) {
>From 8b6bf06a2f196a7753a115a00f9e11e7305dfa59 Mon Sep 17 00:00:00 2001
From: Aswin Kalies <aswinkliesrm at gmail.com>
Date: Sat, 26 Sep 2026 17:28:33 +0530
Subject: [PATCH 2/2] [InstCombine] Fold unsigned icmp of nuw adds with
constants
The fold
icmp (A + C1), (C + C2) -> icmp (A + (C1 - C2)), C if C1 >= C2
icmp (A + C1), (C + C2) -> icmp A, (C + (C2 - C1)) otherwise
was restricted to signed and equality predicates. It is also valid for
unsigned predicates when both adds are nuw (already required by
hasNoWrapProblem): the smaller constant is subtracted from both sides, and
the remaining add stays nuw because its constant only decreases.
For unsigned predicates the constants are compared as unsigned values,
instead of the sign/magnitude checks used for the signed case.
Fixes #220238.
---
.../InstCombine/InstCombineCompares.cpp | 17 ++++++++-
llvm/test/Transforms/InstCombine/icmp.ll | 37 +++++++------------
2 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 717cb65239189..4b689024b7676 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -5535,12 +5535,25 @@ Instruction *InstCombinerImpl::foldICmpBinOp(ICmpInst &I,
// if C2 has greater magnitude than C1:
// icmp (A + C1), (C + C2) -> icmp A, (C + C3)
// s.t. C3 = C2 - C1
+ //
+ // For unsigned predicates, C1 and C2 are compared as unsigned values.
if (A && C && NoOp0WrapProblem && NoOp1WrapProblem &&
- (BO0->hasOneUse() || BO1->hasOneUse()) && !I.isUnsigned()) {
+ (BO0->hasOneUse() || BO1->hasOneUse())) {
const APInt *AP1, *AP2;
// TODO: Support non-uniform vectors.
// TODO: Allow poison passthrough if B or D's element is poison.
- if (match(B, m_APIntAllowPoison(AP1)) &&
+ if (I.isUnsigned() && match(B, m_APIntAllowPoison(AP1)) &&
+ match(D, m_APIntAllowPoison(AP2))) {
+ // Both adds are nuw here. Subtracting the smaller constant from both
+ // sides keeps the remaining add nuw, as its constant only decreases.
+ if (AP1->uge(*AP2)) {
+ Constant *C3 = Constant::getIntegerValue(BO0->getType(), *AP1 - *AP2);
+ return new ICmpInst(Pred, Builder.CreateNUWAdd(A, C3), C);
+ }
+ Constant *C3 = Constant::getIntegerValue(BO0->getType(), *AP2 - *AP1);
+ return new ICmpInst(Pred, A, Builder.CreateNUWAdd(C, C3));
+ }
+ if (!I.isUnsigned() && match(B, m_APIntAllowPoison(AP1)) &&
match(D, m_APIntAllowPoison(AP2)) &&
AP1->isNegative() == AP2->isNegative()) {
APInt AP1Abs = AP1->abs();
diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll
index 321d39e01a6ee..e59cafe803862 100644
--- a/llvm/test/Transforms/InstCombine/icmp.ll
+++ b/llvm/test/Transforms/InstCombine/icmp.ll
@@ -2327,9 +2327,8 @@ define <2 x i1> @icmp_sub57_sge_sub20_vec_nonsplat(<2 x i32> %x, <2 x i32> %y) {
define i1 @icmp_add20_uge_add57(i8 %x, i8 %y) {
; CHECK-LABEL: define i1 @icmp_add20_uge_add57(
; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
-; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 20
-; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 57
-; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[Y]], 37
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X]], [[TMP1]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%1 = add nuw i8 %x, 20
@@ -2341,9 +2340,8 @@ define i1 @icmp_add20_uge_add57(i8 %x, i8 %y) {
define i1 @icmp_add57_ult_add20(i8 %x, i8 %y) {
; CHECK-LABEL: define i1 @icmp_add57_ult_add20(
; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
-; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 57
-; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 20
-; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 37
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[TMP1]], [[Y]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%1 = add nuw i8 %x, 57
@@ -2368,9 +2366,8 @@ define i1 @icmp_add20_ule_add20(i8 %x, i8 %y) {
define i1 @icmp_add200_ugt_add100(i8 %x, i8 %y) {
; CHECK-LABEL: define i1 @icmp_add200_ugt_add100(
; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
-; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], -56
-; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 100
-; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 100
+; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[TMP1]], [[Y]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%1 = add nuw i8 %x, 200
@@ -2382,9 +2379,8 @@ define i1 @icmp_add200_ugt_add100(i8 %x, i8 %y) {
define <2 x i1> @icmp_add20_uge_add57_splat(<2 x i8> %x, <2 x i8> %y) {
; CHECK-LABEL: define <2 x i1> @icmp_add20_uge_add57_splat(
; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {
-; CHECK-NEXT: [[TMP1:%.*]] = add nuw <2 x i8> [[X]], splat (i8 20)
-; CHECK-NEXT: [[TMP2:%.*]] = add nuw <2 x i8> [[Y]], splat (i8 57)
-; CHECK-NEXT: [[CMP:%.*]] = icmp uge <2 x i8> [[TMP1]], [[TMP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw <2 x i8> [[Y]], splat (i8 37)
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge <2 x i8> [[X]], [[TMP1]]
; CHECK-NEXT: ret <2 x i1> [[CMP]]
;
%1 = add nuw <2 x i8> %x, <i8 20, i8 20>
@@ -2396,9 +2392,8 @@ define <2 x i1> @icmp_add20_uge_add57_splat(<2 x i8> %x, <2 x i8> %y) {
define <2 x i1> @icmp_add20_uge_add57_poison(<2 x i8> %x, <2 x i8> %y) {
; CHECK-LABEL: define <2 x i1> @icmp_add20_uge_add57_poison(
; CHECK-SAME: <2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) {
-; CHECK-NEXT: [[TMP1:%.*]] = add nuw <2 x i8> [[X]], splat (i8 20)
-; CHECK-NEXT: [[TMP2:%.*]] = add nuw <2 x i8> [[Y]], <i8 57, i8 poison>
-; CHECK-NEXT: [[CMP:%.*]] = icmp uge <2 x i8> [[TMP1]], [[TMP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw <2 x i8> [[Y]], splat (i8 37)
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge <2 x i8> [[X]], [[TMP1]]
; CHECK-NEXT: ret <2 x i1> [[CMP]]
;
%1 = add nuw <2 x i8> %x, <i8 20, i8 20>
@@ -2426,8 +2421,8 @@ define i1 @icmp_add20_uge_add57_extra_use(i8 %x, i8 %y) {
; CHECK-SAME: i8 [[X:%.*]], i8 [[Y:%.*]]) {
; CHECK-NEXT: [[TMP1:%.*]] = add nuw i8 [[X]], 20
; CHECK-NEXT: call void @use_i8(i8 [[TMP1]])
-; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 57
-; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw i8 [[Y]], 37
+; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X]], [[TMP2]]
; CHECK-NEXT: ret i1 [[CMP]]
;
%1 = add nuw i8 %x, 20
@@ -2503,9 +2498,7 @@ define i1 @icmp_add_nuw_common_base_ule(i8 %base, i8 %off) {
; CHECK-SAME: i8 [[BASE:%.*]], i8 [[OFF:%.*]]) {
; CHECK-NEXT: [[A:%.*]] = add nuw i8 [[BASE]], [[OFF]]
; CHECK-NEXT: call void @use_i8(i8 [[A]])
-; CHECK-NEXT: [[B:%.*]] = add nuw i8 [[A]], 4
-; CHECK-NEXT: [[C:%.*]] = add nuw i8 [[BASE]], 62
-; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[B]], [[C]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[OFF]], 59
; CHECK-NEXT: ret i1 [[CMP]]
;
%a = add nuw i8 %base, %off
@@ -6000,9 +5993,7 @@ define i1 @disjoint_or_ugt_2(i8 %a, i8 %b) {
define i1 @disjoint_or_ugt_3(i8 %a, i8 %b) {
; CHECK-LABEL: define i1 @disjoint_or_ugt_3(
; CHECK-SAME: i8 [[A:%.*]], i8 [[B:%.*]]) {
-; CHECK-NEXT: [[A1:%.*]] = or disjoint i8 [[A]], 2
-; CHECK-NEXT: [[B1:%.*]] = add nuw i8 [[B]], 1
-; CHECK-NEXT: [[ICMP_:%.*]] = icmp ugt i8 [[A1]], [[B1]]
+; CHECK-NEXT: [[ICMP_:%.*]] = icmp uge i8 [[A]], [[B]]
; CHECK-NEXT: ret i1 [[ICMP_]]
;
%a1 = or disjoint i8 %a, 2
More information about the llvm-commits
mailing list