[llvm] 91af6a7 - [CVP] Add tests for mask comparisons (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 20 12:22:11 PDT 2020
Author: Nikita Popov
Date: 2020-09-20T21:13:57+02:00
New Revision: 91af6a78d00f731826ff2eb81c9a9281b1d21388
URL: https://github.com/llvm/llvm-project/commit/91af6a78d00f731826ff2eb81c9a9281b1d21388
DIFF: https://github.com/llvm/llvm-project/commit/91af6a78d00f731826ff2eb81c9a9281b1d21388.diff
LOG: [CVP] Add tests for mask comparisons (NFC)
Added:
Modified:
llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll b/llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
index ac57b86887cc..76d8e0d00f70 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
@@ -989,4 +989,136 @@ if.false:
ret void
}
+define void @test_icmp_mask_two_values(i32 %a) {
+; CHECK-LABEL: @test_icmp_mask_two_values(
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[A:%.*]], -2
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[AND]], 10
+; CHECK-NEXT: br i1 [[CMP]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
+; CHECK: if.true:
+; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i32 [[A]], 10
+; CHECK-NEXT: call void @check1(i1 [[CMP2]])
+; CHECK-NEXT: [[CMP3:%.*]] = icmp ule i32 [[A]], 11
+; CHECK-NEXT: call void @check1(i1 [[CMP3]])
+; CHECK-NEXT: [[CMP4:%.*]] = icmp ult i32 [[A]], 10
+; CHECK-NEXT: call void @check1(i1 [[CMP4]])
+; CHECK-NEXT: [[CMP5:%.*]] = icmp ugt i32 [[A]], 11
+; CHECK-NEXT: call void @check1(i1 [[CMP5]])
+; CHECK-NEXT: ret void
+; CHECK: if.false:
+; CHECK-NEXT: ret void
+;
+ %and = and i32 %a, -2
+ %cmp = icmp eq i32 %and, 10
+ br i1 %cmp, label %if.true, label %if.false
+
+if.true:
+ %cmp2 = icmp uge i32 %a, 10
+ call void @check1(i1 %cmp2)
+ %cmp3 = icmp ule i32 %a, 11
+ call void @check1(i1 %cmp3)
+ %cmp4 = icmp ult i32 %a, 10
+ call void @check1(i1 %cmp4)
+ %cmp5 = icmp ugt i32 %a, 11
+ call void @check1(i1 %cmp5)
+ ret void
+
+if.false:
+ ret void
+}
+
+define void @test_icmp_mask_bit_set(i32 %a) {
+; CHECK-LABEL: @test_icmp_mask_bit_set(
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[A:%.*]], 32
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[AND]], 32
+; CHECK-NEXT: br i1 [[CMP]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
+; CHECK: if.true:
+; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i32 [[A]], 32
+; CHECK-NEXT: call void @check1(i1 [[CMP2]])
+; CHECK-NEXT: [[CMP3:%.*]] = icmp uge i32 [[A]], 33
+; CHECK-NEXT: call void @check1(i1 [[CMP3]])
+; CHECK-NEXT: ret void
+; CHECK: if.false:
+; CHECK-NEXT: ret void
+;
+ %and = and i32 %a, 32
+ %cmp = icmp eq i32 %and, 32
+ br i1 %cmp, label %if.true, label %if.false
+
+if.true:
+ %cmp2 = icmp uge i32 %a, 32
+ call void @check1(i1 %cmp2)
+ %cmp3 = icmp uge i32 %a, 33
+ call void @check1(i1 %cmp3)
+ ret void
+
+if.false:
+ ret void
+}
+
+define void @test_icmp_mask_bit_unset(i32 %a) {
+; CHECK-LABEL: @test_icmp_mask_bit_unset(
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[A:%.*]], 32
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[AND]], 0
+; CHECK-NEXT: br i1 [[CMP]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
+; CHECK: if.true:
+; CHECK-NEXT: [[CMP2:%.*]] = icmp ule i32 [[A]], -33
+; CHECK-NEXT: call void @check1(i1 [[CMP2]])
+; CHECK-NEXT: [[CMP3:%.*]] = icmp ule i32 [[A]], -34
+; CHECK-NEXT: call void @check1(i1 [[CMP3]])
+; CHECK-NEXT: ret void
+; CHECK: if.false:
+; CHECK-NEXT: ret void
+;
+ %and = and i32 %a, 32
+ %cmp = icmp eq i32 %and, 0
+ br i1 %cmp, label %if.true, label %if.false
+
+if.true:
+ %cmp2 = icmp ule i32 %a, -33
+ call void @check1(i1 %cmp2)
+ %cmp3 = icmp ule i32 %a, -34
+ call void @check1(i1 %cmp3)
+ ret void
+
+if.false:
+ ret void
+}
+
+define void @test_icmp_mask_wrong_predicate(i32 %a) {
+; CHECK-LABEL: @test_icmp_mask_wrong_predicate(
+; CHECK-NEXT: [[AND:%.*]] = and i32 [[A:%.*]], -2
+; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[AND]], 10
+; CHECK-NEXT: br i1 [[CMP]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
+; CHECK: if.true:
+; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i32 [[A]], 10
+; CHECK-NEXT: call void @check1(i1 [[CMP2]])
+; CHECK-NEXT: [[CMP3:%.*]] = icmp ule i32 [[A]], 11
+; CHECK-NEXT: call void @check1(i1 [[CMP3]])
+; CHECK-NEXT: [[CMP4:%.*]] = icmp ult i32 [[A]], 10
+; CHECK-NEXT: call void @check1(i1 [[CMP4]])
+; CHECK-NEXT: [[CMP5:%.*]] = icmp ugt i32 [[A]], 11
+; CHECK-NEXT: call void @check1(i1 [[CMP5]])
+; CHECK-NEXT: ret void
+; CHECK: if.false:
+; CHECK-NEXT: ret void
+;
+ %and = and i32 %a, -2
+ %cmp = icmp ne i32 %and, 10
+ br i1 %cmp, label %if.true, label %if.false
+
+if.true:
+ %cmp2 = icmp uge i32 %a, 10
+ call void @check1(i1 %cmp2)
+ %cmp3 = icmp ule i32 %a, 11
+ call void @check1(i1 %cmp3)
+ %cmp4 = icmp ult i32 %a, 10
+ call void @check1(i1 %cmp4)
+ %cmp5 = icmp ugt i32 %a, 11
+ call void @check1(i1 %cmp5)
+ ret void
+
+if.false:
+ ret void
+}
+
attributes #4 = { noreturn }
More information about the llvm-commits
mailing list