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: ands r1, r0
74 ; CHECK-NEXT: lsls r0, r1, #29
78 %shr = and i32 %0, 2684354560
82 define i32 @test7(i32 %x) {
84 ; CHECK: @ %bb.0: @ %entry
85 ; CHECK-NEXT: lsrs r0, r0, #31
86 ; CHECK-NEXT: lsls r0, r0, #2
94 define i32 @test8(i32 %x) {
96 ; CHECK: @ %bb.0: @ %entry
97 ; CHECK-NEXT: lsrs r1, r0, #29
98 ; CHECK-NEXT: movs r0, #5
99 ; CHECK-NEXT: ands r0, r1
107 define i32 @test9(i32 %x) {
108 ; CHECK-LABEL: test9:
109 ; CHECK: @ %bb.0: @ %entry
110 ; CHECK-NEXT: lsrs r0, r0, #3
111 ; CHECK-NEXT: lsls r0, r0, #1
114 %and = lshr i32 %x, 2
115 %shr = and i32 %and, 1073741822
119 define i32 @test10(i32 %x) {
120 ; CHECK-LABEL: test10:
121 ; CHECK: @ %bb.0: @ %entry
122 ; CHECK-NEXT: lsls r0, r0, #2
123 ; CHECK-NEXT: uxtb r0, r0
127 %shr = and i32 %0, 255
131 define i32 @test11(i32 %x) {
132 ; CHECK-LABEL: test11:
133 ; CHECK: @ %bb.0: @ %entry
134 ; CHECK-NEXT: lsrs r0, r0, #24
135 ; CHECK-NEXT: lsls r0, r0, #2
138 %shl = lshr i32 %x, 22
139 %and = and i32 %shl, 1020
143 define i32 @test12(i32 %x) {
144 ; CHECK-LABEL: test12:
145 ; CHECK: @ %bb.0: @ %entry
146 ; CHECK-NEXT: lsrs r0, r0, #3
147 ; CHECK-NEXT: lsls r0, r0, #4
151 %shr = and i32 %0, -16
155 define i32 @test13(i32 %x) {
156 ; CHECK-LABEL: test13:
157 ; CHECK: @ %bb.0: @ %entry
158 ; CHECK-NEXT: lsrs r0, r0, #3
159 ; CHECK-NEXT: lsls r0, r0, #4
162 %shr = lshr i32 %x, 3
163 %shl = shl i32 %shr, 4
167 define i32 @test14(i32 %x) {
168 ; CHECK-LABEL: test14:
169 ; CHECK: @ %bb.0: @ %entry
170 ; CHECK-NEXT: lsrs r0, r0, #6
171 ; CHECK-NEXT: lsls r0, r0, #10
175 %and = and i32 %shl, -1024
179 define i32 @test15(i32 %x) {
180 ; CHECK-LABEL: test15:
181 ; CHECK: @ %bb.0: @ %entry
182 ; CHECK-NEXT: lsrs r0, r0, #4
183 ; CHECK-NEXT: lsls r0, r0, #3
186 %shr = lshr i32 %x, 4
187 %shl = shl i32 %shr, 3
191 define i32 @test16(i32 %x) {
192 ; CHECK-LABEL: test16:
193 ; CHECK: @ %bb.0: @ %entry
194 ; CHECK-NEXT: lsls r0, r0, #28
195 ; CHECK-NEXT: lsrs r0, r0, #26
203 define ptr @test17(ptr %p, i32 %x) {
204 ; CHECK-LABEL: test17:
205 ; CHECK: @ %bb.0: @ %entry
206 ; CHECK-NEXT: lsls r1, r1, #28
207 ; CHECK-NEXT: lsrs r1, r1, #26
208 ; CHECK-NEXT: adds r0, r0, r1
212 %shl = getelementptr i32, ptr %p, i32 %0
216 define ptr @test18(ptr %p, i32 %x) {
217 ; CHECK-LABEL: test18:
218 ; CHECK: @ %bb.0: @ %entry
219 ; CHECK-NEXT: adds r1, r1, #1
220 ; CHECK-NEXT: lsls r1, r1, #28
221 ; CHECK-NEXT: lsrs r1, r1, #26
222 ; CHECK-NEXT: adds r0, r0, r1
227 %shl = getelementptr i32, ptr %p, i32 %0
231 define ptr @test19(ptr %p, i32 %x) {
232 ; CHECK-LABEL: test19:
233 ; CHECK: @ %bb.0: @ %entry
234 ; CHECK-NEXT: subs r1, r1, #1
235 ; CHECK-NEXT: lsls r1, r1, #28
236 ; CHECK-NEXT: lsrs r1, r1, #26
237 ; CHECK-NEXT: adds r0, r0, r1
242 %shl = getelementptr i32, ptr %p, i32 %0
246 define ptr @test20(ptr %p, i32 %x) {
247 ; CHECK-LABEL: test20:
248 ; CHECK: @ %bb.0: @ %entry
249 ; CHECK-NEXT: subs r1, r1, #1
250 ; CHECK-NEXT: lsls r1, r1, #28
251 ; CHECK-NEXT: lsrs r1, r1, #26
252 ; CHECK-NEXT: adds r0, r0, r1
257 %shl = getelementptr i32, ptr %p, i32 %0