summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstSimplify
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-05-26 19:03:53 +0000
committerCraig Topper <craig.topper@gmail.com>2017-05-26 19:03:53 +0000
commit1da22c3244273471bdc14247de36e55cde40b08c (patch)
tree66c2c225bfe23a73b97fd9b2a545ef084f06a09f /llvm/test/Transforms/InstSimplify
parent07963bd1d194af32a3065b170084da94ae8ec090 (diff)
downloadbcm5719-llvm-1da22c3244273471bdc14247de36e55cde40b08c.tar.gz
bcm5719-llvm-1da22c3244273471bdc14247de36e55cde40b08c.zip
[InstSimplify] Use m_APInt instead of m_ConstantInt in ((V + N) & C1) | (V & C2) handling in order to support splat vectors.
The tests here are have operands commuted to provide more coverage. I also commuted one of the instructions in the scalar tests so the 4 tests cover the 4 commuted variations Differential Revision: https://reviews.llvm.org/D33599 llvm-svn: 304021
Diffstat (limited to 'llvm/test/Transforms/InstSimplify')
-rw-r--r--llvm/test/Transforms/InstSimplify/or.ll41
1 files changed, 40 insertions, 1 deletions
diff --git a/llvm/test/Transforms/InstSimplify/or.ll b/llvm/test/Transforms/InstSimplify/or.ll
index 2c5b6181bc6..14b08af0064 100644
--- a/llvm/test/Transforms/InstSimplify/or.ll
+++ b/llvm/test/Transforms/InstSimplify/or.ll
@@ -159,7 +159,7 @@ define i399 @test4_apint(i399 %V, i399 %M) {
%A = add i399 %V, %N
%B = and i399 %A, %C1
%D = and i399 %V, 274877906943
- %R = or i399 %B, %D
+ %R = or i399 %D, %B
ret i399 %R
}
@@ -179,3 +179,42 @@ define i117 @test6_apint(i117 %X) {
ret i117 %Y
}
+; Test the case where integer BitWidth <= 64 && BitWidth % 2 != 0.
+; Vector version of test1_apint with the add commuted
+define <2 x i39> @test7_apint(<2 x i39> %V, <2 x i39> %M) {
+; CHECK-LABEL: @test7_apint(
+; CHECK-NEXT: [[N:%.*]] = and <2 x i39> [[M:%.*]], <i39 -274877906944, i39 -274877906944>
+; CHECK-NEXT: [[A:%.*]] = add <2 x i39> [[N]], [[V:%.*]]
+; CHECK-NEXT: ret <2 x i39> [[A]]
+;
+ ;; If we have: ((V + N) & C1) | (V & C2)
+ ;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
+ ;; replace with V+N.
+ %C1 = xor <2 x i39> <i39 274877906943, i39 274877906943>, <i39 -1, i39 -1> ;; C2 = 274877906943
+ %N = and <2 x i39> %M, <i39 274877906944, i39 274877906944>
+ %A = add <2 x i39> %N, %V
+ %B = and <2 x i39> %A, %C1
+ %D = and <2 x i39> %V, <i39 274877906943, i39 274877906943>
+ %R = or <2 x i39> %B, %D
+ ret <2 x i39> %R
+}
+
+; Test the case where Integer BitWidth > 64 && BitWidth <= 1024.
+; Vector version of test4_apint with the add and the or commuted
+define <2 x i399> @test8_apint(<2 x i399> %V, <2 x i399> %M) {
+; CHECK-LABEL: @test8_apint(
+; CHECK-NEXT: [[N:%.*]] = and <2 x i399> [[M:%.*]], <i399 18446742974197923840, i399 18446742974197923840>
+; CHECK-NEXT: [[A:%.*]] = add <2 x i399> [[N]], [[V:%.*]]
+; CHECK-NEXT: ret <2 x i399> [[A]]
+;
+ ;; If we have: ((V + N) & C1) | (V & C2)
+ ;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
+ ;; replace with V+N.
+ %C1 = xor <2 x i399> <i399 274877906943, i399 274877906943>, <i399 -1, i399 -1> ;; C2 = 274877906943
+ %N = and <2 x i399> %M, <i399 18446742974197923840, i399 18446742974197923840>
+ %A = add <2 x i399> %N, %V
+ %B = and <2 x i399> %A, %C1
+ %D = and <2 x i399> %V, <i399 274877906943, i399 274877906943>
+ %R = or <2 x i399> %D, %B
+ ret <2 x i399> %R
+}
OpenPOWER on IntegriCloud