[llvm] f23b4fa - [InstSimplify] Add tests for shl implied conditions
Joshua Cao via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 6 21:08:33 PDT 2023
Author: Joshua Cao
Date: 2023-06-06T21:06:22-07:00
New Revision: f23b4faaffb1172c3f090f5a28825240aa36969d
URL: https://github.com/llvm/llvm-project/commit/f23b4faaffb1172c3f090f5a28825240aa36969d
DIFF: https://github.com/llvm/llvm-project/commit/f23b4faaffb1172c3f090f5a28825240aa36969d.diff
LOG: [InstSimplify] Add tests for shl implied conditions
Added:
Modified:
llvm/test/Transforms/InstSimplify/implies.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/implies.ll b/llvm/test/Transforms/InstSimplify/implies.ll
index e94ad62e5e32c..c8e3d10a40659 100644
--- a/llvm/test/Transforms/InstSimplify/implies.ll
+++ b/llvm/test/Transforms/InstSimplify/implies.ll
@@ -476,4 +476,36 @@ define i1 @assume_x_ugt_y_plus_1(i64 %x, i64 %y) {
ret i1 %3
}
+; i <u L ==> i >> C <u L
+define i1 @lshr_constant(i32 %length.i, i32 %i) {
+; CHECK-LABEL: @lshr_constant(
+; CHECK-NEXT: [[SHL:%.*]] = lshr i32 [[I:%.*]], 1
+; CHECK-NEXT: [[VAR29:%.*]] = icmp ult i32 [[I]], [[LENGTH_I:%.*]]
+; CHECK-NEXT: [[VAR30:%.*]] = icmp ult i32 [[SHL]], [[LENGTH_I]]
+; CHECK-NEXT: [[RES:%.*]] = icmp ule i1 [[VAR29]], [[VAR30]]
+; CHECK-NEXT: ret i1 [[RES]]
+;
+ %shl = lshr i32 %i, 1
+ %var29 = icmp ult i32 %i, %length.i
+ %var30 = icmp ult i32 %shl, %length.i
+ %res = icmp ule i1 %var29, %var30
+ ret i1 %res
+}
+
+; i <u L ==> i >> V <u L
+define i1 @lshr_value(i32 %length.i, i32 %i, i32 %v) {
+; CHECK-LABEL: @lshr_value(
+; CHECK-NEXT: [[SHL:%.*]] = lshr i32 [[I:%.*]], [[V:%.*]]
+; CHECK-NEXT: [[VAR29:%.*]] = icmp ult i32 [[I]], [[LENGTH_I:%.*]]
+; CHECK-NEXT: [[VAR30:%.*]] = icmp ult i32 [[SHL]], [[LENGTH_I]]
+; CHECK-NEXT: [[RES:%.*]] = icmp ule i1 [[VAR29]], [[VAR30]]
+; CHECK-NEXT: ret i1 [[RES]]
+;
+ %shl = lshr i32 %i, %v
+ %var29 = icmp ult i32 %i, %length.i
+ %var30 = icmp ult i32 %shl, %length.i
+ %res = icmp ule i1 %var29, %var30
+ ret i1 %res
+}
+
declare void @llvm.assume(i1)
More information about the llvm-commits
mailing list