1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=avr -mattr=+movw -mattr=+elpm -mattr=+elpmx -mattr=+lpm -mattr=+lpmx -verify-machineinstrs \
4 ; RUN: llc < %s -mtriple=avr -mattr=+movw -mattr=+elpm -mattr=-elpmx -mattr=+lpm -mattr=-lpmx -verify-machineinstrs \
5 ; RUN: | FileCheck --check-prefix=NOX %s
7 @arr0 = addrspace(1) constant [4 x i16] [i16 123, i16 24, i16 56, i16 37], align 1
8 @arr1 = addrspace(2) constant [4 x i16] [i16 123, i16 34, i16 46, i16 27], align 1
9 @arr2 = addrspace(3) constant [4 x i16] [i16 123, i16 23, i16 45, i16 17], align 1
11 define i16 @foo0(i16 %a, i16 %b) {
13 ; CHECK: ; %bb.0: ; %entry
16 ; CHECK-NEXT: subi r22, lo8(-(arr0))
17 ; CHECK-NEXT: sbci r23, hi8(-(arr0))
18 ; CHECK-NEXT: movw r30, r22
19 ; CHECK-NEXT: lpm r18, Z+
20 ; CHECK-NEXT: lpm r19, Z
23 ; CHECK-NEXT: subi r24, lo8(-(arr0))
24 ; CHECK-NEXT: sbci r25, hi8(-(arr0))
25 ; CHECK-NEXT: movw r30, r24
26 ; CHECK-NEXT: lpm r24, Z+
27 ; CHECK-NEXT: lpm r25, Z
28 ; CHECK-NEXT: sub r24, r18
29 ; CHECK-NEXT: sbc r25, r19
33 ; NOX: ; %bb.0: ; %entry
36 ; NOX-NEXT: subi r22, lo8(-(arr0))
37 ; NOX-NEXT: sbci r23, hi8(-(arr0))
38 ; NOX-NEXT: movw r30, r22
40 ; NOX-NEXT: mov r18, r0
41 ; NOX-NEXT: adiw r30, 1
43 ; NOX-NEXT: mov r19, r0
46 ; NOX-NEXT: subi r24, lo8(-(arr0))
47 ; NOX-NEXT: sbci r25, hi8(-(arr0))
48 ; NOX-NEXT: movw r30, r24
50 ; NOX-NEXT: mov r24, r0
51 ; NOX-NEXT: adiw r30, 1
53 ; NOX-NEXT: mov r25, r0
54 ; NOX-NEXT: sub r24, r18
55 ; NOX-NEXT: sbc r25, r19
58 %arrayidx = getelementptr inbounds [4 x i16], [4 x i16] addrspace(1)* @arr0, i16 0, i16 %a
59 %0 = load i16, i16 addrspace(1)* %arrayidx, align 1
60 %arrayidx1 = getelementptr inbounds [4 x i16], [4 x i16] addrspace(1)* @arr0, i16 0, i16 %b
61 %1 = load i16, i16 addrspace(1)* %arrayidx1, align 1
62 %sub = sub nsw i16 %0, %1
66 define i16 @foo1(i16 %a, i16 %b) {
68 ; CHECK: ; %bb.0: ; %entry
71 ; CHECK-NEXT: subi r22, lo8(-(arr1))
72 ; CHECK-NEXT: sbci r23, hi8(-(arr1))
73 ; CHECK-NEXT: movw r30, r22
74 ; CHECK-NEXT: ldi r18, 1
75 ; CHECK-NEXT: out 59, r18
76 ; CHECK-NEXT: elpm r20, Z+
77 ; CHECK-NEXT: elpm r21, Z
80 ; CHECK-NEXT: subi r24, lo8(-(arr0))
81 ; CHECK-NEXT: sbci r25, hi8(-(arr0))
82 ; CHECK-NEXT: movw r30, r24
83 ; CHECK-NEXT: lpm r24, Z+
84 ; CHECK-NEXT: lpm r25, Z
85 ; CHECK-NEXT: sub r24, r20
86 ; CHECK-NEXT: sbc r25, r21
90 ; NOX: ; %bb.0: ; %entry
93 ; NOX-NEXT: subi r22, lo8(-(arr1))
94 ; NOX-NEXT: sbci r23, hi8(-(arr1))
95 ; NOX-NEXT: movw r30, r22
96 ; NOX-NEXT: ldi r18, 1
97 ; NOX-NEXT: out 59, r18
99 ; NOX-NEXT: mov r20, r0
100 ; NOX-NEXT: adiw r30, 1
102 ; NOX-NEXT: mov r21, r0
105 ; NOX-NEXT: subi r24, lo8(-(arr0))
106 ; NOX-NEXT: sbci r25, hi8(-(arr0))
107 ; NOX-NEXT: movw r30, r24
109 ; NOX-NEXT: mov r24, r0
110 ; NOX-NEXT: adiw r30, 1
112 ; NOX-NEXT: mov r25, r0
113 ; NOX-NEXT: sub r24, r20
114 ; NOX-NEXT: sbc r25, r21
117 %arrayidx = getelementptr inbounds [4 x i16], [4 x i16] addrspace(1)* @arr0, i16 0, i16 %a
118 %0 = load i16, i16 addrspace(1)* %arrayidx, align 1
119 %arrayidx1 = getelementptr inbounds [4 x i16], [4 x i16] addrspace(2)* @arr1, i16 0, i16 %b
120 %1 = load i16, i16 addrspace(2)* %arrayidx1, align 1
121 %sub = sub nsw i16 %0, %1
125 define i16 @foo2(i16 %a, i16 %b) {
127 ; CHECK: ; %bb.0: ; %entry
128 ; CHECK-NEXT: lsl r24
129 ; CHECK-NEXT: rol r25
130 ; CHECK-NEXT: subi r24, lo8(-(arr2))
131 ; CHECK-NEXT: sbci r25, hi8(-(arr2))
132 ; CHECK-NEXT: movw r30, r24
133 ; CHECK-NEXT: ldi r18, 2
134 ; CHECK-NEXT: out 59, r18
135 ; CHECK-NEXT: elpm r24, Z+
136 ; CHECK-NEXT: elpm r25, Z
137 ; CHECK-NEXT: lsl r22
138 ; CHECK-NEXT: rol r23
139 ; CHECK-NEXT: subi r22, lo8(-(arr0))
140 ; CHECK-NEXT: sbci r23, hi8(-(arr0))
141 ; CHECK-NEXT: movw r30, r22
142 ; CHECK-NEXT: lpm r18, Z+
143 ; CHECK-NEXT: lpm r19, Z
144 ; CHECK-NEXT: sub r24, r18
145 ; CHECK-NEXT: sbc r25, r19
149 ; NOX: ; %bb.0: ; %entry
152 ; NOX-NEXT: subi r24, lo8(-(arr2))
153 ; NOX-NEXT: sbci r25, hi8(-(arr2))
154 ; NOX-NEXT: movw r30, r24
155 ; NOX-NEXT: ldi r18, 2
156 ; NOX-NEXT: out 59, r18
158 ; NOX-NEXT: mov r24, r0
159 ; NOX-NEXT: adiw r30, 1
161 ; NOX-NEXT: mov r25, r0
164 ; NOX-NEXT: subi r22, lo8(-(arr0))
165 ; NOX-NEXT: sbci r23, hi8(-(arr0))
166 ; NOX-NEXT: movw r30, r22
168 ; NOX-NEXT: mov r18, r0
169 ; NOX-NEXT: adiw r30, 1
171 ; NOX-NEXT: mov r19, r0
172 ; NOX-NEXT: sub r24, r18
173 ; NOX-NEXT: sbc r25, r19
176 %arrayidx = getelementptr inbounds [4 x i16], [4 x i16] addrspace(3)* @arr2, i16 0, i16 %a
177 %0 = load i16, i16 addrspace(3)* %arrayidx, align 1
178 %arrayidx1 = getelementptr inbounds [4 x i16], [4 x i16] addrspace(1)* @arr0, i16 0, i16 %b
179 %1 = load i16, i16 addrspace(1)* %arrayidx1, align 1
180 %sub = sub nsw i16 %0, %1
184 define i16 @foo3(i16 %a, i16 %b) {
186 ; CHECK: ; %bb.0: ; %entry
187 ; CHECK-NEXT: lsl r22
188 ; CHECK-NEXT: rol r23
189 ; CHECK-NEXT: subi r22, lo8(-(arr1))
190 ; CHECK-NEXT: sbci r23, hi8(-(arr1))
191 ; CHECK-NEXT: movw r30, r22
192 ; CHECK-NEXT: ldi r18, 1
193 ; CHECK-NEXT: out 59, r18
194 ; CHECK-NEXT: elpm r20, Z+
195 ; CHECK-NEXT: elpm r21, Z
196 ; CHECK-NEXT: lsl r24
197 ; CHECK-NEXT: rol r25
198 ; CHECK-NEXT: subi r24, lo8(-(arr2))
199 ; CHECK-NEXT: sbci r25, hi8(-(arr2))
200 ; CHECK-NEXT: movw r30, r24
201 ; CHECK-NEXT: ldi r18, 2
202 ; CHECK-NEXT: out 59, r18
203 ; CHECK-NEXT: elpm r24, Z+
204 ; CHECK-NEXT: elpm r25, Z
205 ; CHECK-NEXT: sub r24, r20
206 ; CHECK-NEXT: sbc r25, r21
210 ; NOX: ; %bb.0: ; %entry
213 ; NOX-NEXT: subi r22, lo8(-(arr1))
214 ; NOX-NEXT: sbci r23, hi8(-(arr1))
215 ; NOX-NEXT: movw r30, r22
216 ; NOX-NEXT: ldi r18, 1
217 ; NOX-NEXT: out 59, r18
219 ; NOX-NEXT: mov r20, r0
220 ; NOX-NEXT: adiw r30, 1
222 ; NOX-NEXT: mov r21, r0
225 ; NOX-NEXT: subi r24, lo8(-(arr2))
226 ; NOX-NEXT: sbci r25, hi8(-(arr2))
227 ; NOX-NEXT: movw r30, r24
228 ; NOX-NEXT: ldi r18, 2
229 ; NOX-NEXT: out 59, r18
231 ; NOX-NEXT: mov r24, r0
232 ; NOX-NEXT: adiw r30, 1
234 ; NOX-NEXT: mov r25, r0
235 ; NOX-NEXT: sub r24, r20
236 ; NOX-NEXT: sbc r25, r21
239 %arrayidx = getelementptr inbounds [4 x i16], [4 x i16] addrspace(3)* @arr2, i16 0, i16 %a
240 %0 = load i16, i16 addrspace(3)* %arrayidx, align 1
241 %arrayidx1 = getelementptr inbounds [4 x i16], [4 x i16] addrspace(2)* @arr1, i16 0, i16 %b
242 %1 = load i16, i16 addrspace(2)* %arrayidx1, align 1
243 %sub = sub nsw i16 %0, %1
247 @arrb1 = addrspace(1) constant [4 x i8] c"abcd", align 1
248 @arrb3 = addrspace(3) constant [4 x i8] c"1234", align 1
249 @arrb5 = addrspace(5) constant [4 x i8] c"HJLQ", align 1
251 define signext i8 @foob0(i16 %a, i16 %b) {
252 ; CHECK-LABEL: foob0:
253 ; CHECK: ; %bb.0: ; %entry
254 ; CHECK-NEXT: subi r22, lo8(-(arrb1))
255 ; CHECK-NEXT: sbci r23, hi8(-(arrb1))
256 ; CHECK-NEXT: movw r30, r22
257 ; CHECK-NEXT: lpm r18, Z
258 ; CHECK-NEXT: subi r24, lo8(-(arrb1))
259 ; CHECK-NEXT: sbci r25, hi8(-(arrb1))
260 ; CHECK-NEXT: movw r30, r24
261 ; CHECK-NEXT: lpm r24, Z
262 ; CHECK-NEXT: sub r24, r18
263 ; CHECK-NEXT: mov r25, r24
264 ; CHECK-NEXT: lsl r25
265 ; CHECK-NEXT: sbc r25, r25
269 ; NOX: ; %bb.0: ; %entry
270 ; NOX-NEXT: subi r22, lo8(-(arrb1))
271 ; NOX-NEXT: sbci r23, hi8(-(arrb1))
272 ; NOX-NEXT: movw r30, r22
274 ; NOX-NEXT: mov r18, r0
275 ; NOX-NEXT: subi r24, lo8(-(arrb1))
276 ; NOX-NEXT: sbci r25, hi8(-(arrb1))
277 ; NOX-NEXT: movw r30, r24
279 ; NOX-NEXT: mov r24, r0
280 ; NOX-NEXT: sub r24, r18
281 ; NOX-NEXT: mov r25, r24
283 ; NOX-NEXT: sbc r25, r25
286 %arrayidx = getelementptr inbounds [4 x i8], [4 x i8] addrspace(1)* @arrb1, i16 0, i16 %a
287 %0 = load i8, i8 addrspace(1)* %arrayidx, align 1
288 %arrayidx1 = getelementptr inbounds [4 x i8], [4 x i8] addrspace(1)* @arrb1, i16 0, i16 %b
289 %1 = load i8, i8 addrspace(1)* %arrayidx1, align 1
294 define signext i8 @foob1(i16 %a, i16 %b) {
295 ; CHECK-LABEL: foob1:
296 ; CHECK: ; %bb.0: ; %entry
297 ; CHECK-NEXT: subi r22, lo8(-(arrb3))
298 ; CHECK-NEXT: sbci r23, hi8(-(arrb3))
299 ; CHECK-NEXT: movw r30, r22
300 ; CHECK-NEXT: ldi r18, 2
301 ; CHECK-NEXT: out 59, r18
302 ; CHECK-NEXT: elpm r18, Z
303 ; CHECK-NEXT: subi r24, lo8(-(arrb1))
304 ; CHECK-NEXT: sbci r25, hi8(-(arrb1))
305 ; CHECK-NEXT: movw r30, r24
306 ; CHECK-NEXT: lpm r24, Z
307 ; CHECK-NEXT: sub r24, r18
308 ; CHECK-NEXT: mov r25, r24
309 ; CHECK-NEXT: lsl r25
310 ; CHECK-NEXT: sbc r25, r25
314 ; NOX: ; %bb.0: ; %entry
315 ; NOX-NEXT: subi r22, lo8(-(arrb3))
316 ; NOX-NEXT: sbci r23, hi8(-(arrb3))
317 ; NOX-NEXT: movw r30, r22
318 ; NOX-NEXT: ldi r18, 2
319 ; NOX-NEXT: out 59, r18
321 ; NOX-NEXT: mov r18, r0
322 ; NOX-NEXT: subi r24, lo8(-(arrb1))
323 ; NOX-NEXT: sbci r25, hi8(-(arrb1))
324 ; NOX-NEXT: movw r30, r24
326 ; NOX-NEXT: mov r24, r0
327 ; NOX-NEXT: sub r24, r18
328 ; NOX-NEXT: mov r25, r24
330 ; NOX-NEXT: sbc r25, r25
333 %arrayidx = getelementptr inbounds [4 x i8], [4 x i8] addrspace(1)* @arrb1, i16 0, i16 %a
334 %0 = load i8, i8 addrspace(1)* %arrayidx, align 1
335 %arrayidx1 = getelementptr inbounds [4 x i8], [4 x i8] addrspace(3)* @arrb3, i16 0, i16 %b
336 %1 = load i8, i8 addrspace(3)* %arrayidx1, align 1
341 define signext i8 @foob2(i16 %a, i16 %b) {
342 ; CHECK-LABEL: foob2:
343 ; CHECK: ; %bb.0: ; %entry
344 ; CHECK-NEXT: subi r24, lo8(-(arrb5))
345 ; CHECK-NEXT: sbci r25, hi8(-(arrb5))
346 ; CHECK-NEXT: movw r30, r24
347 ; CHECK-NEXT: ldi r24, 4
348 ; CHECK-NEXT: out 59, r24
349 ; CHECK-NEXT: elpm r24, Z
350 ; CHECK-NEXT: subi r22, lo8(-(arrb1))
351 ; CHECK-NEXT: sbci r23, hi8(-(arrb1))
352 ; CHECK-NEXT: movw r30, r22
353 ; CHECK-NEXT: lpm r25, Z
354 ; CHECK-NEXT: sub r24, r25
355 ; CHECK-NEXT: mov r25, r24
356 ; CHECK-NEXT: lsl r25
357 ; CHECK-NEXT: sbc r25, r25
361 ; NOX: ; %bb.0: ; %entry
362 ; NOX-NEXT: subi r24, lo8(-(arrb5))
363 ; NOX-NEXT: sbci r25, hi8(-(arrb5))
364 ; NOX-NEXT: movw r30, r24
365 ; NOX-NEXT: ldi r24, 4
366 ; NOX-NEXT: out 59, r24
368 ; NOX-NEXT: mov r24, r0
369 ; NOX-NEXT: subi r22, lo8(-(arrb1))
370 ; NOX-NEXT: sbci r23, hi8(-(arrb1))
371 ; NOX-NEXT: movw r30, r22
373 ; NOX-NEXT: mov r25, r0
374 ; NOX-NEXT: sub r24, r25
375 ; NOX-NEXT: mov r25, r24
377 ; NOX-NEXT: sbc r25, r25
380 %arrayidx = getelementptr inbounds [4 x i8], [4 x i8] addrspace(5)* @arrb5, i16 0, i16 %a
381 %0 = load i8, i8 addrspace(5)* %arrayidx, align 1
382 %arrayidx1 = getelementptr inbounds [4 x i8], [4 x i8] addrspace(1)* @arrb1, i16 0, i16 %b
383 %1 = load i8, i8 addrspace(1)* %arrayidx1, align 1
388 define signext i8 @foob3(i16 %a, i16 %b) {
389 ; CHECK-LABEL: foob3:
390 ; CHECK: ; %bb.0: ; %entry
391 ; CHECK-NEXT: subi r22, lo8(-(arrb5))
392 ; CHECK-NEXT: sbci r23, hi8(-(arrb5))
393 ; CHECK-NEXT: movw r30, r22
394 ; CHECK-NEXT: ldi r18, 4
395 ; CHECK-NEXT: out 59, r18
396 ; CHECK-NEXT: elpm r18, Z
397 ; CHECK-NEXT: subi r24, lo8(-(arrb3))
398 ; CHECK-NEXT: sbci r25, hi8(-(arrb3))
399 ; CHECK-NEXT: movw r30, r24
400 ; CHECK-NEXT: ldi r24, 2
401 ; CHECK-NEXT: out 59, r24
402 ; CHECK-NEXT: elpm r24, Z
403 ; CHECK-NEXT: sub r24, r18
404 ; CHECK-NEXT: mov r25, r24
405 ; CHECK-NEXT: lsl r25
406 ; CHECK-NEXT: sbc r25, r25
410 ; NOX: ; %bb.0: ; %entry
411 ; NOX-NEXT: subi r22, lo8(-(arrb5))
412 ; NOX-NEXT: sbci r23, hi8(-(arrb5))
413 ; NOX-NEXT: movw r30, r22
414 ; NOX-NEXT: ldi r18, 4
415 ; NOX-NEXT: out 59, r18
417 ; NOX-NEXT: mov r18, r0
418 ; NOX-NEXT: subi r24, lo8(-(arrb3))
419 ; NOX-NEXT: sbci r25, hi8(-(arrb3))
420 ; NOX-NEXT: movw r30, r24
421 ; NOX-NEXT: ldi r24, 2
422 ; NOX-NEXT: out 59, r24
424 ; NOX-NEXT: mov r24, r0
425 ; NOX-NEXT: sub r24, r18
426 ; NOX-NEXT: mov r25, r24
428 ; NOX-NEXT: sbc r25, r25
431 %arrayidx = getelementptr inbounds [4 x i8], [4 x i8] addrspace(3)* @arrb3, i16 0, i16 %a
432 %0 = load i8, i8 addrspace(3)* %arrayidx, align 1
433 %arrayidx1 = getelementptr inbounds [4 x i8], [4 x i8] addrspace(5)* @arrb5, i16 0, i16 %b
434 %1 = load i8, i8 addrspace(5)* %arrayidx1, align 1
439 define signext i8 @foob4(i16 %a, i16 %b) {
440 ; CHECK-LABEL: foob4:
441 ; CHECK: ; %bb.0: ; %entry
442 ; CHECK-NEXT: subi r22, lo8(-(arrb3))
443 ; CHECK-NEXT: sbci r23, hi8(-(arrb3))
444 ; CHECK-NEXT: movw r30, r22
445 ; CHECK-NEXT: ldi r18, 2
446 ; CHECK-NEXT: out 59, r18
447 ; CHECK-NEXT: elpm r19, Z
448 ; CHECK-NEXT: subi r24, lo8(-(arrb3))
449 ; CHECK-NEXT: sbci r25, hi8(-(arrb3))
450 ; CHECK-NEXT: movw r30, r24
451 ; CHECK-NEXT: out 59, r18
452 ; CHECK-NEXT: elpm r24, Z
453 ; CHECK-NEXT: sub r24, r19
454 ; CHECK-NEXT: mov r25, r24
455 ; CHECK-NEXT: lsl r25
456 ; CHECK-NEXT: sbc r25, r25
460 ; NOX: ; %bb.0: ; %entry
461 ; NOX-NEXT: subi r22, lo8(-(arrb3))
462 ; NOX-NEXT: sbci r23, hi8(-(arrb3))
463 ; NOX-NEXT: movw r30, r22
464 ; NOX-NEXT: ldi r18, 2
465 ; NOX-NEXT: out 59, r18
467 ; NOX-NEXT: mov r19, r0
468 ; NOX-NEXT: subi r24, lo8(-(arrb3))
469 ; NOX-NEXT: sbci r25, hi8(-(arrb3))
470 ; NOX-NEXT: movw r30, r24
471 ; NOX-NEXT: out 59, r18
473 ; NOX-NEXT: mov r24, r0
474 ; NOX-NEXT: sub r24, r19
475 ; NOX-NEXT: mov r25, r24
477 ; NOX-NEXT: sbc r25, r25
480 %arrayidx = getelementptr inbounds [4 x i8], [4 x i8] addrspace(3)* @arrb3, i16 0, i16 %a
481 %0 = load i8, i8 addrspace(3)* %arrayidx, align 1
482 %arrayidx1 = getelementptr inbounds [4 x i8], [4 x i8] addrspace(3)* @arrb3, i16 0, i16 %b
483 %1 = load i8, i8 addrspace(3)* %arrayidx1, align 1