ARMv8 IfConversion must skip narrow instructions that a) define CPSR and b) wouldn...
[oota-llvm.git] / test / CodeGen / Thumb2 / thumb2-pack.ll
index b3be923ab1e9ca4af377d5eb87dbe113d6c0b235..9a0d8892ccea363c4703a3678821f3f7f077d758 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: llc < %s -march=thumb -mattr=+thumb2,+t2xtpk | FileCheck %s
+; RUN: llc < %s -march=thumb -mcpu=arm1156t2-s -mattr=+thumb2,+t2xtpk | FileCheck %s
 
 ; CHECK: test1
 ; CHECK: pkhbt   r0, r0, r1, lsl #16
@@ -38,7 +38,7 @@ define i32 @test3(i32 %X, i32 %Y) {
 }
 
 ; CHECK: test4
-; CHECK: pkhbt   r0, r0, r1, lsl #0
+; CHECK: pkhbt   r0, r0, r1
 define i32 @test4(i32 %X, i32 %Y) {
        %tmp1 = and i32 %X, 65535               ; <i32> [#uses=1]
        %tmp3 = and i32 %Y, -65536              ; <i32> [#uses=1]
@@ -86,3 +86,35 @@ define i32 @test7(i32 %X, i32 %Y) {
        %tmp57 = or i32 %tmp4, %tmp1            ; <i32> [#uses=1]
        ret i32 %tmp57
 }
+
+; CHECK: test8
+; CHECK-NOT: pkhtb   r0, r0, r1, asr #22
+;   pkhtb does an arithmetic shift, not a logical shift. Make sure we don't
+;   use it for problematic cases when whether sign bits would be shifted in
+;   would matter.
+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-LABEL: 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
+}
+
+; CHECK: test10
+; CHECK: pkhtb   r0, r0, r1, asr #22
+define i32 @test10(i32 %X, i32 %Y) {
+       %tmp1 = and i32 %X, -65536
+       %tmp3 = ashr i32 %Y, 22
+       %tmp57 = or i32 %tmp3, %tmp1
+       ret i32 %tmp57
+}
+