[llvm] 9043cb7 - [InstCombine] Add additional test for icmp eq/ne with bool load (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 15 09:04:27 PDT 2023
Author: Nikita Popov
Date: 2023-03-15T17:03:27+01:00
New Revision: 9043cb752d3a8a68c0e713d27600c148e18ffb95
URL: https://github.com/llvm/llvm-project/commit/9043cb752d3a8a68c0e713d27600c148e18ffb95
DIFF: https://github.com/llvm/llvm-project/commit/9043cb752d3a8a68c0e713d27600c148e18ffb95.diff
LOG: [InstCombine] Add additional test for icmp eq/ne with bool load (NFC)
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-range.ll
llvm/test/Transforms/InstCombine/zext.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-range.ll b/llvm/test/Transforms/InstCombine/icmp-range.ll
index 7b7440beaed0..29b601f5522b 100644
--- a/llvm/test/Transforms/InstCombine/icmp-range.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-range.ll
@@ -990,6 +990,50 @@ define i1 @zext_sext_add_icmp_slt_1_type_not_i1(i2 %a, i1 %b) {
ret i1 %r
}
+define i1 @icmp_eq_bool_0(ptr %ptr) {
+; CHECK-LABEL: @icmp_eq_bool_0(
+; CHECK-NEXT: [[VAL:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !range [[RNG6:![0-9]+]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[VAL]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %val = load i64, ptr %ptr, align 8, !range !{i64 0, i64 2}
+ %cmp = icmp eq i64 %val, 0
+ ret i1 %cmp
+}
+
+define i1 @icmp_eq_bool_1(ptr %ptr) {
+; CHECK-LABEL: @icmp_eq_bool_1(
+; CHECK-NEXT: [[VAL:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !range [[RNG6]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[VAL]], 1
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %val = load i64, ptr %ptr, align 8, !range !{i64 0, i64 2}
+ %cmp = icmp eq i64 %val, 1
+ ret i1 %cmp
+}
+
+define i1 @icmp_ne_bool_0(ptr %ptr) {
+; CHECK-LABEL: @icmp_ne_bool_0(
+; CHECK-NEXT: [[VAL:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !range [[RNG6]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[VAL]], 0
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %val = load i64, ptr %ptr, align 8, !range !{i64 0, i64 2}
+ %cmp = icmp ne i64 %val, 0
+ ret i1 %cmp
+}
+
+define i1 @icmp_ne_bool_1(ptr %ptr) {
+; CHECK-LABEL: @icmp_ne_bool_1(
+; CHECK-NEXT: [[VAL:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !range [[RNG6]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[VAL]], 1
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+ %val = load i64, ptr %ptr, align 8, !range !{i64 0, i64 2}
+ %cmp = icmp ne i64 %val, 1
+ ret i1 %cmp
+}
+
!0 = !{i32 1, i32 6}
!1 = !{i32 0, i32 6}
!2 = !{i8 0, i8 1}
diff --git a/llvm/test/Transforms/InstCombine/zext.ll b/llvm/test/Transforms/InstCombine/zext.ll
index d223c94e553e..dd781c78d3fb 100644
--- a/llvm/test/Transforms/InstCombine/zext.ll
+++ b/llvm/test/Transforms/InstCombine/zext.ll
@@ -702,3 +702,52 @@ define i8 @zext_icmp_eq_pow2(i8 %y, i8 %x) {
%r = zext i1 %c to i8
ret i8 %r
}
+
+define i64 @zext_icmp_eq_bool_0(ptr %ptr) {
+; CHECK-LABEL: @zext_icmp_eq_bool_0(
+; CHECK-NEXT: [[VAL:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !range [[RNG0:![0-9]+]]
+; CHECK-NEXT: [[LEN:%.*]] = xor i64 [[VAL]], 1
+; CHECK-NEXT: ret i64 [[LEN]]
+;
+ %val = load i64, ptr %ptr, align 8, !range !{i64 0, i64 2}
+ %cmp = icmp eq i64 %val, 0
+ %len = zext i1 %cmp to i64
+ ret i64 %len
+}
+
+define i64 @zext_icmp_eq_bool_1(ptr %ptr) {
+; CHECK-LABEL: @zext_icmp_eq_bool_1(
+; CHECK-NEXT: [[VAL:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !range [[RNG0]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[VAL]], 1
+; CHECK-NEXT: [[LEN:%.*]] = zext i1 [[CMP]] to i64
+; CHECK-NEXT: ret i64 [[LEN]]
+;
+ %val = load i64, ptr %ptr, align 8, !range !{i64 0, i64 2}
+ %cmp = icmp eq i64 %val, 1
+ %len = zext i1 %cmp to i64
+ ret i64 %len
+}
+
+define i64 @zext_icmp_ne_bool_0(ptr %ptr) {
+; CHECK-LABEL: @zext_icmp_ne_bool_0(
+; CHECK-NEXT: [[VAL:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !range [[RNG0]]
+; CHECK-NEXT: ret i64 [[VAL]]
+;
+ %val = load i64, ptr %ptr, align 8, !range !{i64 0, i64 2}
+ %cmp = icmp ne i64 %val, 0
+ %len = zext i1 %cmp to i64
+ ret i64 %len
+}
+
+define i64 @zext_icmp_ne_bool_1(ptr %ptr) {
+; CHECK-LABEL: @zext_icmp_ne_bool_1(
+; CHECK-NEXT: [[VAL:%.*]] = load i64, ptr [[PTR:%.*]], align 8, !range [[RNG0]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[VAL]], 1
+; CHECK-NEXT: [[LEN:%.*]] = zext i1 [[CMP]] to i64
+; CHECK-NEXT: ret i64 [[LEN]]
+;
+ %val = load i64, ptr %ptr, align 8, !range !{i64 0, i64 2}
+ %cmp = icmp ne i64 %val, 1
+ %len = zext i1 %cmp to i64
+ ret i64 %len
+}
More information about the llvm-commits
mailing list