[llvm] ea6171c - [InstCombine] add tests for icmp with udiv operand; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 06:10:15 PDT 2022
Author: Sanjay Patel
Date: 2022-05-26T09:08:47-04:00
New Revision: ea6171c108c47c1ee486388adfa106e13e280e33
URL: https://github.com/llvm/llvm-project/commit/ea6171c108c47c1ee486388adfa106e13e280e33
DIFF: https://github.com/llvm/llvm-project/commit/ea6171c108c47c1ee486388adfa106e13e280e33.diff
LOG: [InstCombine] add tests for icmp with udiv operand; NFC
This covers a generalization of one of the transforms
suggested in #55695.
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 aab916c4c7a0..ff587dc347a8 100644
--- a/llvm/test/Transforms/InstCombine/icmp-div-constant.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-div-constant.ll
@@ -196,3 +196,81 @@ exit:
ret i32 %add
}
+define i1 @udiv_eq_umax(i8 %x, i8 %y) {
+; CHECK-LABEL: @udiv_eq_umax(
+; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[D]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = udiv i8 %x, %y
+ %r = icmp eq i8 %d, 255
+ ret i1 %r
+}
+
+define <2 x i1> @udiv_ne_umax(<2 x i5> %x, <2 x i5> %y) {
+; CHECK-LABEL: @udiv_ne_umax(
+; CHECK-NEXT: [[D:%.*]] = udiv <2 x i5> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i5> [[D]], <i5 -1, i5 -1>
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %d = udiv <2 x i5> %x, %y
+ %r = icmp ne <2 x i5> %d, <i5 -1, i5 -1>
+ ret <2 x i1> %r
+}
+
+define i1 @udiv_eq_big(i8 %x, i8 %y) {
+; CHECK-LABEL: @udiv_eq_big(
+; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[D]], -128
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = udiv i8 %x, %y
+ %r = icmp eq i8 %d, 128
+ ret i1 %r
+}
+
+define i1 @udiv_ne_big(i8 %x, i8 %y) {
+; CHECK-LABEL: @udiv_ne_big(
+; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[D]], -128
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = udiv i8 %x, %y
+ %r = icmp ne i8 %d, 128
+ ret i1 %r
+}
+
+define i1 @udiv_eq_not_big(i8 %x, i8 %y) {
+; CHECK-LABEL: @udiv_eq_not_big(
+; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[D]], 127
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = udiv i8 %x, %y
+ %r = icmp eq i8 %d, 127
+ ret i1 %r
+}
+
+define i1 @udiv_slt_umax(i8 %x, i8 %y) {
+; CHECK-LABEL: @udiv_slt_umax(
+; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[D]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = udiv i8 %x, %y
+ %r = icmp slt i8 %d, 255
+ ret i1 %r
+}
+
+define i1 @udiv_eq_umax_use(i32 %x, i32 %y) {
+; CHECK-LABEL: @udiv_eq_umax_use(
+; CHECK-NEXT: [[D:%.*]] = udiv i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: call void @use(i32 [[D]])
+; CHECK-NEXT: [[R:%.*]] = icmp eq i32 [[D]], -1
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %d = udiv i32 %x, %y
+ call void @use(i32 %d)
+ %r = icmp eq i32 %d, -1
+ ret i1 %r
+}
More information about the llvm-commits
mailing list