[llvm] af5e64d - [InstCombine] add tests for (pow2 >> X) >u C; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 17 05:41:57 PDT 2022
Author: Sanjay Patel
Date: 2022-06-17T08:41:51-04:00
New Revision: af5e64df728f498ea9c6d43432debdb1be775251
URL: https://github.com/llvm/llvm-project/commit/af5e64df728f498ea9c6d43432debdb1be775251
DIFF: https://github.com/llvm/llvm-project/commit/af5e64df728f498ea9c6d43432debdb1be775251.diff
LOG: [InstCombine] add tests for (pow2 >> X) >u C; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-shr.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-shr.ll b/llvm/test/Transforms/InstCombine/icmp-shr.ll
index a6dcf136e233e..2d78916356ab7 100644
--- a/llvm/test/Transforms/InstCombine/icmp-shr.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-shr.ll
@@ -1006,4 +1006,83 @@ define i1 @ashr_exact_ne_0_multiuse(i8 %x) {
ret i1 %c
}
+define i1 @lshr_pow2_ugt(i8 %x) {
+; CHECK-LABEL: @lshr_pow2_ugt(
+; CHECK-NEXT: [[S:%.*]] = lshr i8 2, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[S]], 1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = lshr i8 2, %x
+ %r = icmp ugt i8 %s, 1
+ ret i1 %r
+}
+
+define i1 @lshr_pow2_ugt_use(i8 %x) {
+; CHECK-LABEL: @lshr_pow2_ugt_use(
+; CHECK-NEXT: [[S:%.*]] = lshr i8 -128, [[X:%.*]]
+; CHECK-NEXT: call void @use(i8 [[S]])
+; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[S]], 5
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = lshr i8 128, %x
+ call void @use(i8 %s)
+ %r = icmp ugt i8 %s, 5
+ ret i1 %r
+}
+
+define <2 x i1> @lshr_pow2_ugt_vec(<2 x i8> %x) {
+; CHECK-LABEL: @lshr_pow2_ugt_vec(
+; CHECK-NEXT: [[S:%.*]] = lshr <2 x i8> <i8 8, i8 8>, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ugt <2 x i8> [[S]], <i8 6, i8 6>
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %s = lshr <2 x i8> <i8 8, i8 8>, %x
+ %r = icmp ugt <2 x i8> %s, <i8 6, i8 6>
+ ret <2 x i1> %r
+}
+
+define i1 @lshr_not_pow2_ugt(i8 %x) {
+; CHECK-LABEL: @lshr_not_pow2_ugt(
+; CHECK-NEXT: [[S:%.*]] = lshr i8 3, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[S]], 1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = lshr i8 3, %x
+ %r = icmp ugt i8 %s, 1
+ ret i1 %r
+}
+
+define i1 @lshr_pow2_ugt1(i8 %x) {
+; CHECK-LABEL: @lshr_pow2_ugt1(
+; CHECK-NEXT: [[S:%.*]] = lshr i8 -128, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[S]], 1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = lshr i8 128, %x
+ %r = icmp ugt i8 %s, 1
+ ret i1 %r
+}
+
+define i1 @ashr_pow2_ugt(i8 %x) {
+; CHECK-LABEL: @ashr_pow2_ugt(
+; CHECK-NEXT: [[S:%.*]] = ashr i8 -128, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[S]], -96
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = ashr i8 128, %x
+ %r = icmp ugt i8 %s, 160
+ ret i1 %r
+}
+
+define i1 @lshr_pow2_sgt(i8 %x) {
+; CHECK-LABEL: @lshr_pow2_sgt(
+; CHECK-NEXT: [[S:%.*]] = lshr i8 -128, [[X:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[S]], 3
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %s = lshr i8 128, %x
+ %r = icmp sgt i8 %s, 3
+ ret i1 %r
+}
+
declare void @use(i8)
More information about the llvm-commits
mailing list