[llvm] r278726 - [InstCombine] add tests for vector icmp folds
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 15 12:58:22 PDT 2016
Author: spatel
Date: Mon Aug 15 14:58:21 2016
New Revision: 278726
URL: http://llvm.org/viewvc/llvm-project?rev=278726&view=rev
Log:
[InstCombine] add tests for vector icmp folds
Modified:
llvm/trunk/test/Transforms/InstCombine/exact.ll
Modified: llvm/trunk/test/Transforms/InstCombine/exact.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/exact.ll?rev=278726&r1=278725&r2=278726&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/exact.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/exact.ll Mon Aug 15 14:58:21 2016
@@ -157,6 +157,16 @@ define i1 @udiv_icmp1(i64 %X) {
ret i1 %B
}
+define <2 x i1> @udiv_icmp1_vec(<2 x i64> %X) {
+; CHECK-LABEL: @udiv_icmp1_vec(
+; CHECK-NEXT: [[B:%.*]] = icmp ugt <2 x i64> %X, <i64 4, i64 4>
+; CHECK-NEXT: ret <2 x i1> [[B]]
+;
+ %A = udiv exact <2 x i64> %X, <i64 5, i64 5>
+ %B = icmp ne <2 x i64> %A, zeroinitializer
+ ret <2 x i1> %B
+}
+
define i1 @udiv_icmp2(i64 %X) {
; CHECK-LABEL: @udiv_icmp2(
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 %X, 0
@@ -167,6 +177,16 @@ define i1 @udiv_icmp2(i64 %X) {
ret i1 %B
}
+define <2 x i1> @udiv_icmp2_vec(<2 x i64> %X) {
+; CHECK-LABEL: @udiv_icmp2_vec(
+; CHECK-NEXT: [[B:%.*]] = icmp ult <2 x i64> %X, <i64 5, i64 5>
+; CHECK-NEXT: ret <2 x i1> [[B]]
+;
+ %A = udiv exact <2 x i64> %X, <i64 5, i64 5>
+ %B = icmp eq <2 x i64> %A, zeroinitializer
+ ret <2 x i1> %B
+}
+
define i1 @sdiv_icmp1(i64 %X) {
; CHECK-LABEL: @sdiv_icmp1(
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 %X, 0
@@ -177,6 +197,18 @@ define i1 @sdiv_icmp1(i64 %X) {
ret i1 %B
}
+; FIXME: Vectors should fold too.
+define <2 x i1> @sdiv_icmp1_vec(<2 x i64> %X) {
+; CHECK-LABEL: @sdiv_icmp1_vec(
+; CHECK-NEXT: [[A:%.*]] = sdiv exact <2 x i64> %X, <i64 5, i64 5>
+; CHECK-NEXT: [[B:%.*]] = icmp eq <2 x i64> [[A]], zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[B]]
+;
+ %A = sdiv exact <2 x i64> %X, <i64 5, i64 5>
+ %B = icmp eq <2 x i64> %A, zeroinitializer
+ ret <2 x i1> %B
+}
+
define i1 @sdiv_icmp2(i64 %X) {
; CHECK-LABEL: @sdiv_icmp2(
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 %X, 5
@@ -187,6 +219,18 @@ define i1 @sdiv_icmp2(i64 %X) {
ret i1 %B
}
+; FIXME: Vectors should fold too.
+define <2 x i1> @sdiv_icmp2_vec(<2 x i64> %X) {
+; CHECK-LABEL: @sdiv_icmp2_vec(
+; CHECK-NEXT: [[A:%.*]] = sdiv exact <2 x i64> %X, <i64 5, i64 5>
+; CHECK-NEXT: [[B:%.*]] = icmp eq <2 x i64> [[A]], <i64 1, i64 1>
+; CHECK-NEXT: ret <2 x i1> [[B]]
+;
+ %A = sdiv exact <2 x i64> %X, <i64 5, i64 5>
+ %B = icmp eq <2 x i64> %A, <i64 1, i64 1>
+ ret <2 x i1> %B
+}
+
define i1 @sdiv_icmp3(i64 %X) {
; CHECK-LABEL: @sdiv_icmp3(
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 %X, -5
@@ -197,6 +241,18 @@ define i1 @sdiv_icmp3(i64 %X) {
ret i1 %B
}
+; FIXME: Vectors should fold too.
+define <2 x i1> @sdiv_icmp3_vec(<2 x i64> %X) {
+; CHECK-LABEL: @sdiv_icmp3_vec(
+; CHECK-NEXT: [[A:%.*]] = sdiv exact <2 x i64> %X, <i64 5, i64 5>
+; CHECK-NEXT: [[B:%.*]] = icmp eq <2 x i64> [[A]], <i64 -1, i64 -1>
+; CHECK-NEXT: ret <2 x i1> [[B]]
+;
+ %A = sdiv exact <2 x i64> %X, <i64 5, i64 5>
+ %B = icmp eq <2 x i64> %A, <i64 -1, i64 -1>
+ ret <2 x i1> %B
+}
+
define i1 @sdiv_icmp4(i64 %X) {
; CHECK-LABEL: @sdiv_icmp4(
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 %X, 0
@@ -207,6 +263,18 @@ define i1 @sdiv_icmp4(i64 %X) {
ret i1 %B
}
+; FIXME: Vectors should fold too.
+define <2 x i1> @sdiv_icmp4_vec(<2 x i64> %X) {
+; CHECK-LABEL: @sdiv_icmp4_vec(
+; CHECK-NEXT: [[A:%.*]] = sdiv exact <2 x i64> %X, <i64 -5, i64 -5>
+; CHECK-NEXT: [[B:%.*]] = icmp eq <2 x i64> [[A]], zeroinitializer
+; CHECK-NEXT: ret <2 x i1> [[B]]
+;
+ %A = sdiv exact <2 x i64> %X, <i64 -5, i64 -5>
+ %B = icmp eq <2 x i64> %A, zeroinitializer
+ ret <2 x i1> %B
+}
+
define i1 @sdiv_icmp5(i64 %X) {
; CHECK-LABEL: @sdiv_icmp5(
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 %X, -5
@@ -217,13 +285,37 @@ define i1 @sdiv_icmp5(i64 %X) {
ret i1 %B
}
+; FIXME: Vectors should fold too.
+define <2 x i1> @sdiv_icmp5_vec(<2 x i64> %X) {
+; CHECK-LABEL: @sdiv_icmp5_vec(
+; CHECK-NEXT: [[A:%.*]] = sdiv exact <2 x i64> %X, <i64 -5, i64 -5>
+; CHECK-NEXT: [[B:%.*]] = icmp eq <2 x i64> [[A]], <i64 1, i64 1>
+; CHECK-NEXT: ret <2 x i1> [[B]]
+;
+ %A = sdiv exact <2 x i64> %X, <i64 -5, i64 -5>
+ %B = icmp eq <2 x i64> %A, <i64 1, i64 1>
+ ret <2 x i1> %B
+}
+
define i1 @sdiv_icmp6(i64 %X) {
; CHECK-LABEL: @sdiv_icmp6(
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 %X, 5
; CHECK-NEXT: ret i1 [[TMP1]]
;
- %A = sdiv exact i64 %X, -5 ; X/-5 == 1 --> x == 5
+ %A = sdiv exact i64 %X, -5 ; X/-5 == -1 --> x == 5
%B = icmp eq i64 %A, -1
ret i1 %B
}
+; FIXME: Vectors should fold too.
+define <2 x i1> @sdiv_icmp6_vec(<2 x i64> %X) {
+; CHECK-LABEL: @sdiv_icmp6_vec(
+; CHECK-NEXT: [[A:%.*]] = sdiv exact <2 x i64> %X, <i64 -5, i64 -5>
+; CHECK-NEXT: [[B:%.*]] = icmp eq <2 x i64> [[A]], <i64 -1, i64 -1>
+; CHECK-NEXT: ret <2 x i1> [[B]]
+;
+ %A = sdiv exact <2 x i64> %X, <i64 -5, i64 -5>
+ %B = icmp eq <2 x i64> %A, <i64 -1, i64 -1>
+ ret <2 x i1> %B
+}
+
More information about the llvm-commits
mailing list