[llvm] r275995 - add tests related to PR28466
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 19 10:07:36 PDT 2016
Author: spatel
Date: Tue Jul 19 12:07:35 2016
New Revision: 275995
URL: http://llvm.org/viewvc/llvm-project?rev=275995&view=rev
Log:
add tests related to PR28466
Modified:
llvm/trunk/test/Transforms/InstSimplify/select.ll
Modified: llvm/trunk/test/Transforms/InstSimplify/select.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/select.ll?rev=275995&r1=275994&r2=275995&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/select.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/select.ll Tue Jul 19 12:07:35 2016
@@ -132,7 +132,21 @@ define i32 @select_icmp_and_8_eq_0_or_8(
}
; PR28466: https://llvm.org/bugs/show_bug.cgi?id=28466
-; InstSimplify needs to recognize variations of this pattern.
+
+define i32 @select_icmp_trunc_8_eq_0_or_8(i32 %x) {
+; CHECK-LABEL: @select_icmp_trunc_8_eq_0_or_8(
+; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 %x to i8
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[TRUNC]], 0
+; CHECK-NEXT: [[OR:%.*]] = or i32 %x, 128
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[OR]], i32 %x
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %trunc = trunc i32 %x to i8
+ %cmp = icmp slt i8 %trunc, 0
+ %or = or i32 %x, 128
+ %sel = select i1 %cmp, i32 %or, i32 %x
+ ret i32 %sel
+}
define i32 @select_icmp_and_8_ne_0_or_128(i32 %x) {
; CHECK-LABEL: @select_icmp_and_8_ne_0_or_128(
@@ -145,6 +159,21 @@ define i32 @select_icmp_and_8_ne_0_or_12
ret i32 %or.x
}
+define i32 @select_icmp_trunc_8_ne_0_or_128(i32 %x) {
+; CHECK-LABEL: @select_icmp_trunc_8_ne_0_or_128(
+; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 %x to i8
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[TRUNC]], 0
+; CHECK-NEXT: [[OR:%.*]] = or i32 %x, 128
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 %x, i32 [[OR]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %trunc = trunc i32 %x to i8
+ %cmp = icmp slt i8 %trunc, 0
+ %or = or i32 %x, 128
+ %sel = select i1 %cmp, i32 %x, i32 %or
+ ret i32 %sel
+}
+
define i32 @select_icmp_and_8_ne_0_and_not_8(i32 %x) {
; CHECK-LABEL: @select_icmp_and_8_ne_0_and_not_8(
; CHECK-NEXT: [[AND1:%.*]] = and i32 %x, -9
@@ -157,6 +186,21 @@ define i32 @select_icmp_and_8_ne_0_and_n
ret i32 %x.and1
}
+define i32 @select_icmp_trunc_8_ne_0_and_not_8(i32 %x) {
+; CHECK-LABEL: @select_icmp_trunc_8_ne_0_and_not_8(
+; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 %x to i4
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i4 [[TRUNC]], 0
+; CHECK-NEXT: [[AND:%.*]] = and i32 %x, -9
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 %x, i32 [[AND]]
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %trunc = trunc i32 %x to i4
+ %cmp = icmp slt i4 %trunc, 0
+ %and = and i32 %x, -9
+ %sel = select i1 %cmp, i32 %x, i32 %and
+ ret i32 %sel
+}
+
define i32 @select_icmp_and_8_eq_0_and_not_8(i32 %x) {
; CHECK-LABEL: @select_icmp_and_8_eq_0_and_not_8(
; CHECK-NEXT: ret i32 %x
@@ -168,6 +212,21 @@ define i32 @select_icmp_and_8_eq_0_and_n
ret i32 %and1.x
}
+define i32 @select_icmp_trunc_8_eq_0_and_not_8(i32 %x) {
+; CHECK-LABEL: @select_icmp_trunc_8_eq_0_and_not_8(
+; CHECK-NEXT: [[TRUNC:%.*]] = trunc i32 %x to i4
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i4 [[TRUNC]], 0
+; CHECK-NEXT: [[AND:%.*]] = and i32 %x, -9
+; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[AND]], i32 %x
+; CHECK-NEXT: ret i32 [[SEL]]
+;
+ %trunc = trunc i32 %x to i4
+ %cmp = icmp slt i4 %trunc, 0
+ %and = and i32 %x, -9
+ %sel = select i1 %cmp, i32 %and, i32 %x
+ ret i32 %sel
+}
+
define i64 @select_icmp_x_and_8_eq_0_y_and_not_8(i32 %x, i64 %y) {
; CHECK-LABEL: @select_icmp_x_and_8_eq_0_y_and_not_8(
; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 8
More information about the llvm-commits
mailing list