[llvm] efa1544 - [LVI] Add tests for tracking `or disjoint` like add; NFC
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 11:49:21 PDT 2024
Author: Noah Goldstein
Date: 2024-03-28T13:49:05-05:00
New Revision: efa1544c2c3551e014c2d73aebe4fd0d4cc30462
URL: https://github.com/llvm/llvm-project/commit/efa1544c2c3551e014c2d73aebe4fd0d4cc30462
DIFF: https://github.com/llvm/llvm-project/commit/efa1544c2c3551e014c2d73aebe4fd0d4cc30462.diff
LOG: [LVI] Add tests for tracking `or disjoint` like add; NFC
Added:
Modified:
llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll b/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
index 8dce9ef9fa4350..94de0128a09ac1 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/basic.ll
@@ -870,6 +870,34 @@ out:
ret i1 false
}
+define i1 @clamp_high1_or(i32 noundef %a) {
+; CHECK-LABEL: @clamp_high1_or(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[A:%.*]], 5
+; CHECK-NEXT: br i1 [[CMP]], label [[A_GUARD:%.*]], label [[OUT:%.*]]
+; CHECK: a_guard:
+; CHECK-NEXT: [[SEL_CMP:%.*]] = icmp eq i32 [[A]], 5
+; CHECK-NEXT: [[ADD:%.*]] = or disjoint i32 [[A]], 1
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[SEL_CMP]], i32 5, i32 [[ADD]]
+; CHECK-NEXT: [[RES:%.*]] = icmp eq i32 [[SEL]], 6
+; CHECK-NEXT: ret i1 [[RES]]
+; CHECK: out:
+; CHECK-NEXT: ret i1 false
+;
+entry:
+ %cmp = icmp sle i32 %a, 5
+ br i1 %cmp, label %a_guard, label %out
+
+a_guard:
+ %sel_cmp = icmp eq i32 %a, 5
+ %add = or disjoint i32 %a, 1
+ %sel = select i1 %sel_cmp, i32 5, i32 %add
+ %res = icmp eq i32 %sel, 6
+ ret i1 %res
+out:
+ ret i1 false
+}
+
define i1 @clamp_high2(i32 noundef %a) {
; CHECK-LABEL: @clamp_high2(
; CHECK-NEXT: entry:
@@ -897,6 +925,36 @@ out:
ret i1 false
}
+
+define i1 @clamp_high2_or_disjoint(i32 noundef %a) {
+; CHECK-LABEL: @clamp_high2_or_disjoint(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp sle i32 [[A:%.*]], 5
+; CHECK-NEXT: br i1 [[CMP]], label [[A_GUARD:%.*]], label [[OUT:%.*]]
+; CHECK: a_guard:
+; CHECK-NEXT: [[SEL_CMP:%.*]] = icmp ne i32 [[A]], 5
+; CHECK-NEXT: [[ADD:%.*]] = or disjoint i32 [[A]], 1
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[SEL_CMP]], i32 [[ADD]], i32 5
+; CHECK-NEXT: [[RES:%.*]] = icmp eq i32 [[SEL]], 6
+; CHECK-NEXT: ret i1 [[RES]]
+; CHECK: out:
+; CHECK-NEXT: ret i1 false
+;
+entry:
+ %cmp = icmp sle i32 %a, 5
+ br i1 %cmp, label %a_guard, label %out
+
+a_guard:
+ %sel_cmp = icmp ne i32 %a, 5
+ %add = or disjoint i32 %a, 1
+ %sel = select i1 %sel_cmp, i32 %add, i32 5
+ %res = icmp eq i32 %sel, 6
+ ret i1 %res
+out:
+ ret i1 false
+}
+
+
define i1 @clamp_high3(i32 noundef %a) {
; CHECK-LABEL: @clamp_high3(
; CHECK-NEXT: entry:
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll b/llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
index 101820a4c65f23..b534e3fd2137c0 100644
--- a/llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/icmp.ll
@@ -587,6 +587,27 @@ define i1 @test_assume_cmp_with_offset(i64 %idx) {
ret i1 %cmp2
}
+define i1 @test_assume_cmp_with_offset_or(i64 %idx, i1 %other) {
+; CHECK-LABEL: @test_assume_cmp_with_offset_or(
+; CHECK-NEXT: [[IDX_OFF1:%.*]] = or disjoint i64 [[IDX:%.*]], 5
+; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i64 [[IDX_OFF1]], 10
+; CHECK-NEXT: br i1 [[CMP1]], label [[T:%.*]], label [[F:%.*]]
+; CHECK: T:
+; CHECK-NEXT: [[CMP3:%.*]] = icmp ugt i64 [[IDX]], 2
+; CHECK-NEXT: ret i1 [[CMP3]]
+; CHECK: F:
+; CHECK-NEXT: ret i1 [[CMP2:%.*]]
+;
+ %idx.off1 = or disjoint i64 %idx, 5
+ %cmp1 = icmp ugt i64 %idx.off1, 10
+ br i1 %cmp1, label %T, label %F
+T:
+ %cmp2 = icmp ugt i64 %idx, 2
+ ret i1 %cmp2
+F:
+ ret i1 %other
+}
+
define void @test_cmp_phi(i8 %a) {
; CHECK-LABEL: @test_cmp_phi(
; CHECK-NEXT: entry:
More information about the llvm-commits
mailing list