1 ; RUN: llc < %s -march=avr | FileCheck %s
4 ; CHECK-LABEL: shift_i8_i8_speed
5 define i8 @shift_i8_i8_speed(i8 %a, i8 %b) {
7 ; CHECK-NEXT: brmi .LBB0_2
11 ; CHECK-NEXT: brpl .LBB0_1
12 ; CHECK-NEXT: .LBB0_2:
14 %result = shl i8 %a, %b
18 ; Optimize for size (producing slightly smaller code).
19 ; CHECK-LABEL: shift_i8_i8_size
20 define i8 @shift_i8_i8_size(i8 %a, i8 %b) optsize {
23 ; CHECK-NEXT: brmi .LBB1_3
25 ; CHECK-NEXT: rjmp .LBB1_1
26 ; CHECK-NEXT: .LBB1_3:
28 %result = shl i8 %a, %b
32 ; CHECK-LABEL: shift_i16_i16
33 define i16 @shift_i16_i16(i16 %a, i16 %b) {
35 ; CHECK-NEXT: brmi .LBB2_2
36 ; CHECK-NEXT: .LBB2_1:
40 ; CHECK-NEXT: brpl .LBB2_1
41 ; CHECK-NEXT: .LBB2_2:
43 %result = shl i16 %a, %b
47 ; CHECK-LABEL: shift_i64_i64
48 define i64 @shift_i64_i64(i64 %a, i64 %b) {
49 ; CHECK: call __ashldi3
50 %result = shl i64 %a, %b
54 define i8 @lsl_i8_1(i8 %a) {
55 ; CHECK-LABEL: lsl_i8_1:
61 define i8 @lsl_i8_2(i8 %a) {
62 ; CHECK-LABEL: lsl_i8_2:
69 define i8 @lsl_i8_3(i8 %a) {
70 ; CHECK-LABEL: lsl_i8_3:
78 define i8 @lsl_i8_4(i8 %a) {
79 ; CHECK-LABEL: lsl_i8_4:
81 ; CHECK-NEXT: andi r24, -16
86 define i8 @lsl_i8_5(i8 %a) {
87 ; CHECK-LABEL: lsl_i8_5:
89 ; CHECK-NEXT: andi r24, -16
95 define i8 @lsl_i8_6(i8 %a) {
96 ; CHECK-LABEL: lsl_i8_6:
98 ; CHECK-NEXT: andi r24, -16
100 ; CHECK-NEXT: lsl r24
105 define i8 @lsr_i8_1(i8 %a) {
106 ; CHECK-LABEL: lsr_i8_1:
112 define i8 @lsr_i8_2(i8 %a) {
113 ; CHECK-LABEL: lsr_i8_2:
115 ; CHECK-NEXT: lsr r24
120 define i8 @lsr_i8_3(i8 %a) {
121 ; CHECK-LABEL: lsr_i8_3:
123 ; CHECK-NEXT: lsr r24
124 ; CHECK-NEXT: lsr r24
129 define i8 @lsr_i8_4(i8 %a) {
130 ; CHECK-LABEL: lsr_i8_4:
132 ; CHECK-NEXT: andi r24, 15
137 define i8 @lsr_i8_5(i8 %a) {
138 ; CHECK-LABEL: lsr_i8_5:
140 ; CHECK-NEXT: andi r24, 15
141 ; CHECK-NEXT: lsr r24
146 define i8 @lsr_i8_6(i8 %a) {
147 ; CHECK-LABEL: lsr_i8_6:
149 ; CHECK-NEXT: andi r24, 15
150 ; CHECK-NEXT: lsr r24
151 ; CHECK-NEXT: lsr r24
156 define i8 @lsl_i8_7(i8 %a) {
157 ; CHECK-LABEL: lsl_i8_7
159 ; CHECK-NEXT: clr r24
160 ; CHECK-NEXT: ror r24
161 %result = shl i8 %a, 7
165 define i8 @lsr_i8_7(i8 %a) {
166 ; CHECK-LABEL: lsr_i8_7
168 ; CHECK-NEXT: clr r24
169 ; CHECK-NEXT: rol r24
170 %result = lshr i8 %a, 7
174 define i8 @asr_i8_7(i8 %a) {
175 ; CHECK-LABEL: asr_i8_7
177 ; CHECK-NEXT: sbc r24, r24
178 %result = ashr i8 %a, 7
182 define i16 @lsl_i16_5(i16 %a) {
183 ; CHECK-LABEL: lsl_i16_5
185 ; CHECK-NEXT: swap r24
186 ; CHECK-NEXT: andi r25, 240
187 ; CHECK-NEXT: eor r25, r24
188 ; CHECK-NEXT: andi r24, 240
189 ; CHECK-NEXT: eor r25, r24
190 ; CHECK-NEXT: lsl r24
191 ; CHECK-NEXT: rol r25
193 %result = shl i16 %a, 5
197 define i16 @lsl_i16_6(i16 %a, i16 %b, i16 %c, i16 %d, i16 %e, i16 %f) {
198 ; CHECK-LABEL: lsl_i16_6
199 ; CHECK: mov r24, r14
200 ; CHECK-NEXT: mov r25, r15
201 ; CHECK-NEXT: swap r25
202 ; CHECK-NEXT: swap r24
203 ; CHECK-NEXT: andi r25, 240
204 ; CHECK-NEXT: eor r25, r24
205 ; CHECK-NEXT: andi r24, 240
206 ; CHECK-NEXT: eor r25, r24
207 ; CHECK-NEXT: lsl r24
208 ; CHECK-NEXT: rol r25
209 ; CHECK-NEXT: lsl r24
210 ; CHECK-NEXT: rol r25
212 %result = shl i16 %f, 6
216 define i16 @lsl_i16_9(i16 %a) {
217 ; CHECK-LABEL: lsl_i16_9
218 ; CHECK: mov r25, r24
219 ; CHECK-NEXT: clr r24
220 ; CHECK-NEXT: lsl r24
221 ; CHECK-NEXT: rol r25
223 %result = shl i16 %a, 9
227 define i16 @lsl_i16_13(i16 %a) {
228 ; CHECK-LABEL: lsl_i16_13
229 ; CHECK: mov r25, r24
230 ; CHECK-NEXT: swap r25
231 ; CHECK-NEXT: andi r25, 240
232 ; CHECK-NEXT: clr r24
233 ; CHECK-NEXT: lsl r24
234 ; CHECK-NEXT: rol r25
236 %result = shl i16 %a, 13
240 define i16 @lsr_i16_5(i16 %a) {
241 ; CHECK-LABEL: lsr_i16_5
243 ; CHECK-NEXT: swap r24
244 ; CHECK-NEXT: andi r24, 15
245 ; CHECK-NEXT: eor r24, r25
246 ; CHECK-NEXT: andi r25, 15
247 ; CHECK-NEXT: eor r24, r25
248 ; CHECK-NEXT: lsr r25
249 ; CHECK-NEXT: ror r24
251 %result = lshr i16 %a, 5
255 define i16 @lsr_i16_6(i16 %a, i16 %b, i16 %c, i16 %d, i16 %e, i16 %f) {
256 ; CHECK-LABEL: lsr_i16_6
257 ; CHECK: mov r24, r14
258 ; CHECK-NEXT: mov r25, r15
259 ; CHECK-NEXT: swap r25
260 ; CHECK-NEXT: swap r24
261 ; CHECK-NEXT: andi r24, 15
262 ; CHECK-NEXT: eor r24, r25
263 ; CHECK-NEXT: andi r25, 15
264 ; CHECK-NEXT: eor r24, r25
265 ; CHECK-NEXT: lsr r25
266 ; CHECK-NEXT: ror r24
267 ; CHECK-NEXT: lsr r25
268 ; CHECK-NEXT: ror r24
270 %result = lshr i16 %f, 6
274 define i16 @lsr_i16_9(i16 %a) {
275 ; CHECK-LABEL: lsr_i16_9
276 ; CHECK: mov r24, r25
277 ; CHECK-NEXT: clr r25
278 ; CHECK-NEXT: lsr r25
279 ; CHECK-NEXT: ror r24
281 %result = lshr i16 %a, 9
285 define i16 @lsr_i16_13(i16 %a) {
286 ; CHECK-LABEL: lsr_i16_13
287 ; CHECK: mov r24, r25
288 ; CHECK-NEXT: swap r24
289 ; CHECK-NEXT: andi r24, 15
290 ; CHECK-NEXT: clr r25
291 ; CHECK-NEXT: lsr r25
292 ; CHECK-NEXT: ror r24
294 %result = lshr i16 %a, 13
298 define i16 @asr_i16_9(i16 %a) {
299 ; CHECK-LABEL: asr_i16_9
300 ; CHECK: mov r24, r25
301 ; CHECK-NEXT: lsl r25
302 ; CHECK-NEXT: sbc r25, r25
303 ; CHECK-NEXT: asr r25
304 ; CHECK-NEXT: ror r24
306 %result = ashr i16 %a, 9