1 ; RUN: llc -mtriple=thumb-eabi -mcpu=cortex-a8 %s -o - | FileCheck %s -check-prefix=CHECK-DSP
2 ; RUN: llc -mtriple=thumb-eabi -mcpu=cortex-m3 %s -o - | FileCheck %s -check-prefix=CHECK-NO-DSP
3 ; RUN: llc -mtriple=thumbv7em-eabi %s -o - | FileCheck %s -check-prefix=CHECK-DSP
4 ; RUN: llc -mtriple=thumbv8m.main-none-eabi %s -o - | FileCheck %s -check-prefix=CHECK-NO-DSP
5 ; RUN: llc -mtriple=thumbv8m.main-none-eabi -mattr=+dsp %s -o - | FileCheck %s -check-prefix=CHECK-DSP
7 define i32 @test1(i32 %x) {
9 ; CHECK-DSP: uxtb16 r0, r0
10 ; CHECK-NO-DSP: bic r0, r0, #-16711936
11 %tmp1 = and i32 %x, 16711935 ; <i32> [#uses=1]
16 define i32 @test2(i32 %x) {
18 ; CHECK-DSP: uxtb16 r0, r0, ror #8
19 ; CHECK-NO-DSP: mov.w r1, #16711935
20 ; CHECK-NO-DSP: and.w r0, r1, r0, lsr #8
21 %tmp1 = lshr i32 %x, 8 ; <i32> [#uses=1]
22 %tmp2 = and i32 %tmp1, 16711935 ; <i32> [#uses=1]
26 define i32 @test3(i32 %x) {
28 ; CHECK-DSP: uxtb16 r0, r0, ror #8
29 ; CHECK-NO-DSP: mov.w r1, #16711935
30 ; CHECK-NO-DSP: and.w r0, r1, r0, lsr #8
31 %tmp1 = lshr i32 %x, 8 ; <i32> [#uses=1]
32 %tmp2 = and i32 %tmp1, 16711935 ; <i32> [#uses=1]
36 define i32 @test4(i32 %x) {
38 ; CHECK-DSP: uxtb16 r0, r0, ror #8
39 ; CHECK-NO-DSP: mov.w r1, #16711935
40 ; CHECK-NO-DSP: and.w r0, r1, r0, lsr #8
41 %tmp1 = lshr i32 %x, 8 ; <i32> [#uses=1]
42 %tmp6 = and i32 %tmp1, 16711935 ; <i32> [#uses=1]
46 define i32 @test5(i32 %x) {
48 ; CHECK-DSP: uxtb16 r0, r0, ror #8
49 ; CHECK-NO-DSP: mov.w r1, #16711935
50 ; CHECK-NO-DSP: and.w r0, r1, r0, lsr #8
51 %tmp1 = lshr i32 %x, 8 ; <i32> [#uses=1]
52 %tmp2 = and i32 %tmp1, 16711935 ; <i32> [#uses=1]
56 define i32 @test6(i32 %x) {
58 ; CHECK-DSP: uxtb16 r0, r0, ror #16
59 ; CHECK-NO-DSP: mov.w r1, #16711935
60 ; CHECK-NO-DSP: and.w r0, r1, r0, ror #16
61 %tmp1 = lshr i32 %x, 16 ; <i32> [#uses=1]
62 %tmp2 = and i32 %tmp1, 255 ; <i32> [#uses=1]
63 %tmp4 = shl i32 %x, 16 ; <i32> [#uses=1]
64 %tmp5 = and i32 %tmp4, 16711680 ; <i32> [#uses=1]
65 %tmp6 = or i32 %tmp2, %tmp5 ; <i32> [#uses=1]
69 define i32 @test7(i32 %x) {
71 ; CHECK-DSP: uxtb16 r0, r0, ror #16
72 ; CHECK-NO-DSP: mov.w r1, #16711935
73 ; CHECK-NO-DSP: and.w r0, r1, r0, ror #16
74 %tmp1 = lshr i32 %x, 16 ; <i32> [#uses=1]
75 %tmp2 = and i32 %tmp1, 255 ; <i32> [#uses=1]
76 %tmp4 = shl i32 %x, 16 ; <i32> [#uses=1]
77 %tmp5 = and i32 %tmp4, 16711680 ; <i32> [#uses=1]
78 %tmp6 = or i32 %tmp2, %tmp5 ; <i32> [#uses=1]
82 define i32 @test8(i32 %x) {
84 ; CHECK-DSP: uxtb16 r0, r0, ror #24
85 ; CHECK-NO-DSP: mov.w r1, #16711935
86 ; CHECK-NO-DSP: and.w r0, r1, r0, ror #24
87 %tmp1 = shl i32 %x, 8 ; <i32> [#uses=1]
88 %tmp2 = and i32 %tmp1, 16711680 ; <i32> [#uses=1]
89 %tmp5 = lshr i32 %x, 24 ; <i32> [#uses=1]
90 %tmp6 = or i32 %tmp2, %tmp5 ; <i32> [#uses=1]
94 define i32 @test9(i32 %x) {
96 ; CHECK-DSP: uxtb16 r0, r0, ror #24
97 ; CHECK-NO-DSP: mov.w r1, #16711935
98 ; CHECK-NO-DSP: and.w r0, r1, r0, ror #24
99 %tmp1 = lshr i32 %x, 24 ; <i32> [#uses=1]
100 %tmp4 = shl i32 %x, 8 ; <i32> [#uses=1]
101 %tmp5 = and i32 %tmp4, 16711680 ; <i32> [#uses=1]
102 %tmp6 = or i32 %tmp5, %tmp1 ; <i32> [#uses=1]
106 define i32 @test10(i32 %p0) {
107 ; CHECK-LABEL: test10
108 ; CHECK-DSP: mov.w r1, #16253176
109 ; CHECK-DSP: and.w r0, r1, r0, lsr #7
110 ; CHECK-DSP: lsrs r1, r0, #5
111 ; CHECK-DSP: uxtb16 r1, r1
112 ; CHECk-DSP: adds r0, r1
114 ; CHECK-NO-DSP: mov.w r1, #16253176
115 ; CHECK-NO-DSP: and.w r0, r1, r0, lsr #7
116 ; CHECK-NO-DSP: mov.w r1, #458759
117 ; CHECK-NO-DSP: and.w r1, r1, r0, lsr #5
118 ; CHECK-NO-DSP: add r0, r1
119 %tmp1 = lshr i32 %p0, 7 ; <i32> [#uses=1]
120 %tmp2 = and i32 %tmp1, 16253176 ; <i32> [#uses=2]
121 %tmp4 = lshr i32 %tmp2, 5 ; <i32> [#uses=1]
122 %tmp5 = and i32 %tmp4, 458759 ; <i32> [#uses=1]
123 %tmp7 = or i32 %tmp5, %tmp2 ; <i32> [#uses=1]