1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=thumbv6-eabi %s -o - | FileCheck %s
4 define i32 @test1(i32 %x) {
6 ; CHECK: @ %bb.0: @ %entry
7 ; CHECK-NEXT: lsls r0, r0, #20
8 ; CHECK-NEXT: lsrs r0, r0, #22
12 %shr = and i32 %0, 1023
16 define i32 @test2(i32 %x) {
18 ; CHECK: @ %bb.0: @ %entry
19 ; CHECK-NEXT: lsrs r1, r0, #2
20 ; CHECK-NEXT: ldr r0, .LCPI1_0
21 ; CHECK-NEXT: ands r0, r1
23 ; CHECK-NEXT: .p2align 2
24 ; CHECK-NEXT: @ %bb.1:
25 ; CHECK-NEXT: .LCPI1_0:
26 ; CHECK-NEXT: .long 1022 @ 0x3fe
29 %shr = and i32 %0, 1022
33 define i32 @test3(i32 %x) {
35 ; CHECK: @ %bb.0: @ %entry
36 ; CHECK-NEXT: lsrs r0, r0, #2
37 ; CHECK-NEXT: uxtb r0, r0
41 %shr = and i32 %0, 255
45 define i32 @test4(i32 %x) {
47 ; CHECK: @ %bb.0: @ %entry
48 ; CHECK-NEXT: lsrs r0, r0, #3
49 ; CHECK-NEXT: lsls r0, r0, #7
53 %shr = and i32 %0, -128
57 define i32 @test5(i32 %x) {
59 ; CHECK: @ %bb.0: @ %entry
60 ; CHECK-NEXT: lsls r0, r0, #31
61 ; CHECK-NEXT: lsrs r0, r0, #2
65 %shr = and i32 %0, 536870912
69 define i32 @test6(i32 %x) {
71 ; CHECK: @ %bb.0: @ %entry
72 ; CHECK-NEXT: movs r1, #5
73 ; CHECK-NEXT: lsls r1, r1, #29
74 ; CHECK-NEXT: lsls r0, r0, #29
75 ; CHECK-NEXT: ands r0, r1
79 %shr = and i32 %0, 2684354560
83 define i32 @test7(i32 %x) {
85 ; CHECK: @ %bb.0: @ %entry
86 ; CHECK-NEXT: lsrs r0, r0, #31
87 ; CHECK-NEXT: lsls r0, r0, #2
95 define i32 @test8(i32 %x) {
97 ; CHECK: @ %bb.0: @ %entry
98 ; CHECK-NEXT: lsrs r1, r0, #29
99 ; CHECK-NEXT: movs r0, #5
100 ; CHECK-NEXT: ands r0, r1
108 define i32 @test9(i32 %x) {
109 ; CHECK-LABEL: test9:
110 ; CHECK: @ %bb.0: @ %entry
111 ; CHECK-NEXT: lsrs r0, r0, #3
112 ; CHECK-NEXT: lsls r0, r0, #1
115 %and = lshr i32 %x, 2
116 %shr = and i32 %and, 1073741822
120 define i32 @test10(i32 %x) {
121 ; CHECK-LABEL: test10:
122 ; CHECK: @ %bb.0: @ %entry
123 ; CHECK-NEXT: lsls r0, r0, #2
124 ; CHECK-NEXT: uxtb r0, r0
128 %shr = and i32 %0, 255
132 define i32 @test11(i32 %x) {
133 ; CHECK-LABEL: test11:
134 ; CHECK: @ %bb.0: @ %entry
135 ; CHECK-NEXT: lsrs r0, r0, #24
136 ; CHECK-NEXT: lsls r0, r0, #2
139 %shl = lshr i32 %x, 22
140 %and = and i32 %shl, 1020
144 define i32 @test12(i32 %x) {
145 ; CHECK-LABEL: test12:
146 ; CHECK: @ %bb.0: @ %entry
147 ; CHECK-NEXT: lsrs r0, r0, #3
148 ; CHECK-NEXT: lsls r0, r0, #4
152 %shr = and i32 %0, -16
156 define i32 @test13(i32 %x) {
157 ; CHECK-LABEL: test13:
158 ; CHECK: @ %bb.0: @ %entry
159 ; CHECK-NEXT: lsrs r0, r0, #3
160 ; CHECK-NEXT: lsls r0, r0, #4
163 %shr = lshr i32 %x, 3
164 %shl = shl i32 %shr, 4
168 define i32 @test14(i32 %x) {
169 ; CHECK-LABEL: test14:
170 ; CHECK: @ %bb.0: @ %entry
171 ; CHECK-NEXT: lsrs r0, r0, #6
172 ; CHECK-NEXT: lsls r0, r0, #10
176 %and = and i32 %shl, -1024
180 define i32 @test15(i32 %x) {
181 ; CHECK-LABEL: test15:
182 ; CHECK: @ %bb.0: @ %entry
183 ; CHECK-NEXT: lsrs r0, r0, #4
184 ; CHECK-NEXT: lsls r0, r0, #3
187 %shr = lshr i32 %x, 4
188 %shl = shl i32 %shr, 3
192 define i32 @test16(i32 %x) {
193 ; CHECK-LABEL: test16:
194 ; CHECK: @ %bb.0: @ %entry
195 ; CHECK-NEXT: lsls r0, r0, #28
196 ; CHECK-NEXT: lsrs r0, r0, #26
204 define ptr @test17(ptr %p, i32 %x) {
205 ; CHECK-LABEL: test17:
206 ; CHECK: @ %bb.0: @ %entry
207 ; CHECK-NEXT: lsls r1, r1, #28
208 ; CHECK-NEXT: lsrs r1, r1, #26
209 ; CHECK-NEXT: adds r0, r0, r1
213 %shl = getelementptr i32, ptr %p, i32 %0
217 define ptr @test18(ptr %p, i32 %x) {
218 ; CHECK-LABEL: test18:
219 ; CHECK: @ %bb.0: @ %entry
220 ; CHECK-NEXT: adds r1, r1, #1
221 ; CHECK-NEXT: lsls r1, r1, #28
222 ; CHECK-NEXT: lsrs r1, r1, #26
223 ; CHECK-NEXT: adds r0, r0, r1
228 %shl = getelementptr i32, ptr %p, i32 %0
232 define ptr @test19(ptr %p, i32 %x) {
233 ; CHECK-LABEL: test19:
234 ; CHECK: @ %bb.0: @ %entry
235 ; CHECK-NEXT: subs r1, r1, #1
236 ; CHECK-NEXT: lsls r1, r1, #28
237 ; CHECK-NEXT: lsrs r1, r1, #26
238 ; CHECK-NEXT: adds r0, r0, r1
243 %shl = getelementptr i32, ptr %p, i32 %0
247 define ptr @test20(ptr %p, i32 %x) {
248 ; CHECK-LABEL: test20:
249 ; CHECK: @ %bb.0: @ %entry
250 ; CHECK-NEXT: subs r1, r1, #1
251 ; CHECK-NEXT: lsls r1, r1, #28
252 ; CHECK-NEXT: lsrs r1, r1, #26
253 ; CHECK-NEXT: adds r0, r0, r1
258 %shl = getelementptr i32, ptr %p, i32 %0