[llvm] 60682a0 - [InstCombine] add tests for icmp with sdiv operand; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 13:19:30 PDT 2022
Author: Sanjay Patel
Date: 2022-05-26T16:19:15-04:00
New Revision: 60682a0b85d5bdd74dd7e4a46bc88c901d884c75
URL: https://github.com/llvm/llvm-project/commit/60682a0b85d5bdd74dd7e4a46bc88c901d884c75
DIFF: https://github.com/llvm/llvm-project/commit/60682a0b85d5bdd74dd7e4a46bc88c901d884c75.diff
LOG: [InstCombine] add tests for icmp with sdiv operand; NFC
Adapted from unsigned division tests from:
ea6171c108c47c1ee4863
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-div-constant.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-div-constant.ll b/llvm/test/Transforms/InstCombine/icmp-div-constant.ll
index e9b26e6b4bca6..9d7f25fecfd2c 100644
--- a/llvm/test/Transforms/InstCombine/icmp-div-constant.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-div-constant.ll
@@ -284,3 +284,82 @@ define i1 @udiv_eq_umax_use(i32 %x, i32 %y) {
%r = icmp eq i32 %d, -1
ret i1 %r
}
+
+define i1 @sdiv_eq_smin(i8 %x, i8 %y) {
+; CHECK-LABEL: @sdiv_eq_smin(
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[D]], -128
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = sdiv i8 %x, %y
+ %r = icmp eq i8 %d, -128
+ ret i1 %r
+}
+
+define <2 x i1> @sdiv_ne_smin(<2 x i5> %x, <2 x i5> %y) {
+; CHECK-LABEL: @sdiv_ne_smin(
+; CHECK-NEXT: [[D:%.*]] = sdiv <2 x i5> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i5> [[D]], <i5 -16, i5 -16>
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %d = sdiv <2 x i5> %x, %y
+ %r = icmp ne <2 x i5> %d, <i5 -16, i5 -16>
+ ret <2 x i1> %r
+}
+
+define i1 @sdiv_eq_small(i8 %x, i8 %y) {
+; CHECK-LABEL: @sdiv_eq_small(
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[D]], -127
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = sdiv i8 %x, %y
+ %r = icmp eq i8 %d, -127
+ ret i1 %r
+}
+
+define i1 @sdiv_ne_big(i8 %x, i8 %y) {
+; CHECK-LABEL: @sdiv_ne_big(
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[D]], 127
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = sdiv i8 %x, %y
+ %r = icmp ne i8 %d, 127
+ ret i1 %r
+}
+
+define i1 @sdiv_eq_not_big(i8 %x, i8 %y) {
+; CHECK-LABEL: @sdiv_eq_not_big(
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[D]], 100
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = sdiv i8 %x, %y
+ %r = icmp eq i8 %d, 100
+ ret i1 %r
+}
+
+define i1 @sdiv_ult_smin(i8 %x, i8 %y) {
+; CHECK-LABEL: @sdiv_ult_smin(
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[D]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = sdiv i8 %x, %y
+ %r = icmp ult i8 %d, 128
+ ret i1 %r
+}
+
+define i1 @sdiv_eq_smin_use(i32 %x, i32 %y) {
+; CHECK-LABEL: @sdiv_eq_smin_use(
+; CHECK-NEXT: [[D:%.*]] = sdiv i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: call void @use(i32 [[D]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[D]], -2147483648
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = sdiv i32 %x, %y
+ call void @use(i32 %d)
+ %r = icmp eq i32 %d, -2147483648
+ ret i1 %r
+}
More information about the llvm-commits
mailing list