summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorArnold Schwaighofer <aschwaighofer@apple.com>2013-07-05 18:28:39 +0000
committerArnold Schwaighofer <aschwaighofer@apple.com>2013-07-05 18:28:39 +0000
commit50b76b522686a7efd079ca4178cad517757d3b06 (patch)
tree18ee330d095cae1994a12143c30f8223c1fe6434 /llvm/test
parentabb160e68964ddf534e240e3ea0bf90af53f894d (diff)
downloadbcm5719-llvm-50b76b522686a7efd079ca4178cad517757d3b06.tar.gz
bcm5719-llvm-50b76b522686a7efd079ca4178cad517757d3b06.zip
ARM: Fix incorrect pack pattern
A "pkhtb x, x, y asr #num" uses the lower 16 bits of "y asr #num" and packs them in the bottom half of "x". An arithmetic and logic shift are only equivalent in this context if the shift amount is 16. We would be shifting in ones into the bottom 16bits instead of zeros if "y" is negative. radar://14338767 llvm-svn: 185712
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/ARM/pack.ll15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/test/CodeGen/ARM/pack.ll b/llvm/test/CodeGen/ARM/pack.ll
index 90151767b91..b94414328ca 100644
--- a/llvm/test/CodeGen/ARM/pack.ll
+++ b/llvm/test/CodeGen/ARM/pack.ll
@@ -78,11 +78,24 @@ define i32 @test7(i32 %X, i32 %Y) {
ret i32 %tmp57
}
+; Arithmetic and logic right shift does not have the same semantics if shifting
+; by more than 16 in this context.
+
; CHECK: test8
-; CHECK: pkhtb r0, r0, r1, asr #22
+; CHECK-NOT: pkhtb r0, r0, r1, asr #22
define i32 @test8(i32 %X, i32 %Y) {
%tmp1 = and i32 %X, -65536
%tmp3 = lshr i32 %Y, 22
%tmp57 = or i32 %tmp3, %tmp1
ret i32 %tmp57
}
+
+; CHECK: test9:
+; CHECK: pkhtb r0, r0, r1, asr #16
+define i32 @test9(i32 %src1, i32 %src2) {
+entry:
+ %tmp = and i32 %src1, -65536
+ %tmp2 = lshr i32 %src2, 16
+ %tmp3 = or i32 %tmp, %tmp2
+ ret i32 %tmp3
+}
OpenPOWER on IntegriCloud