[llvm] d18b7ea - [InstCombine] add tests for icmp with trunc op; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 3 09:43:23 PDT 2021
Author: Sanjay Patel
Date: 2021-11-03T12:43:15-04:00
New Revision: d18b7ea621613472f9ca95103a82e7d05d17bcef
URL: https://github.com/llvm/llvm-project/commit/d18b7ea621613472f9ca95103a82e7d05d17bcef
DIFF: https://github.com/llvm/llvm-project/commit/d18b7ea621613472f9ca95103a82e7d05d17bcef.diff
LOG: [InstCombine] add tests for icmp with trunc op; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/icmp-trunc.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/icmp-trunc.ll b/llvm/test/Transforms/InstCombine/icmp-trunc.ll
index 4c41892d5cd8..473b020c261a 100644
--- a/llvm/test/Transforms/InstCombine/icmp-trunc.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-trunc.ll
@@ -91,8 +91,6 @@ define <2 x i1> @ult_2044_splat(<2 x i16> %x) {
ret <2 x i1> %r
}
-; negative test - need high-bit-mask constant
-
define i1 @ult_96(i32 %x) {
; CHECK-LABEL: @ult_96(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
@@ -104,8 +102,6 @@ define i1 @ult_96(i32 %x) {
ret i1 %r
}
-; negative test - no extra use allowed
-
define i1 @ult_192_use(i32 %x) {
; CHECK-LABEL: @ult_192_use(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
@@ -119,6 +115,52 @@ define i1 @ult_192_use(i32 %x) {
ret i1 %r
}
+define i1 @ugt_3(i32 %x) {
+; CHECK-LABEL: @ugt_3(
+; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
+; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T]], 3
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %t = trunc i32 %x to i8
+ %r = icmp ugt i8 %t, 3
+ ret i1 %r
+}
+
+define <2 x i1> @ugt_7_splat(<2 x i16> %x) {
+; CHECK-LABEL: @ugt_7_splat(
+; CHECK-NEXT: [[T:%.*]] = trunc <2 x i16> [[X:%.*]] to <2 x i11>
+; CHECK-NEXT: [[R:%.*]] = icmp ugt <2 x i11> [[T]], <i11 7, i11 7>
+; CHECK-NEXT: ret <2 x i1> [[R]]
+;
+ %t = trunc <2 x i16> %x to <2 x i11>
+ %r = icmp ugt <2 x i11> %t, <i11 7, i11 7>
+ ret <2 x i1> %r
+}
+
+define i1 @ugt_4(i32 %x) {
+; CHECK-LABEL: @ugt_4(
+; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
+; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T]], 4
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %t = trunc i32 %x to i8
+ %r = icmp ugt i8 %t, 4
+ ret i1 %r
+}
+
+define i1 @ugt_3_use(i32 %x) {
+; CHECK-LABEL: @ugt_3_use(
+; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
+; CHECK-NEXT: call void @use(i8 [[T]])
+; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T]], 3
+; CHECK-NEXT: ret i1 [[R]]
+;
+ %t = trunc i32 %x to i8
+ call void @use(i8 %t)
+ %r = icmp ugt i8 %t, 3
+ ret i1 %r
+}
+
define i1 @ugt_253(i32 %x) {
; CHECK-LABEL: @ugt_253(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
@@ -141,10 +183,8 @@ define <2 x i1> @ugt_239_splat(<2 x i16> %x) {
ret <2 x i1> %r
}
-; negative test - need inverted power-of-2 constant
-
-define i1 @ugt_3(i32 %x) {
-; CHECK-LABEL: @ugt_3(
+define i1 @ugt_252(i32 %x) {
+; CHECK-LABEL: @ugt_252(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T]], -4
; CHECK-NEXT: ret i1 [[R]]
@@ -154,10 +194,8 @@ define i1 @ugt_3(i32 %x) {
ret i1 %r
}
-; negative test - no extra use allowed
-
-define i1 @ugt_2_use(i32 %x) {
-; CHECK-LABEL: @ugt_2_use(
+define i1 @ugt_253_use(i32 %x) {
+; CHECK-LABEL: @ugt_253_use(
; CHECK-NEXT: [[T:%.*]] = trunc i32 [[X:%.*]] to i8
; CHECK-NEXT: call void @use(i8 [[T]])
; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[T]], -3
More information about the llvm-commits
mailing list