1 # RUN: llc -mtriple=avr -mattr=+lpm -mattr=+elpm -mattr=+lpmx -mattr=+elpmx \
2 # RUN: -mattr=+movw -start-before=greedy %s -o - | FileCheck %s
3 # RUN: llc -mtriple=avr -mattr=+lpm -mattr=+elpm -mattr=-lpmx -mattr=-elpmx \
4 # RUN: -mattr=+addsubiw -mattr=+movw -start-before=greedy %s -o - \
5 # RUN: | FileCheck --check-prefix=NOX %s
6 # RUN: llc -mtriple=avr -mattr=+lpm -mattr=+elpm -mattr=-lpmx -mattr=-elpmx \
7 # RUN: -mattr=-addsubiw -mattr=+movw -start-before=greedy %s -o - \
8 # RUN: | FileCheck --check-prefix=NOADIWNOX %s
10 # This test checks the expansion of the 16-bit ELPM pseudo instruction and that
11 # the register allocator won't use R31R30 as an output register (which would
12 # lead to undefined behavior).
15 target triple = "avr--"
16 define void @test_elpmwrdz() {
20 define void @test_elpmwrdz_2() {
28 tracksRegLiveness: true
33 ; CHECK-LABEL: test_elpmwrdz
35 ; CHECK-NEXT: elpm r25, Z
36 ; CHECK-NEXT: movw r30, r24
38 ; NOX-LABEL: test_elpmwrdz
40 ; NOX-NEXT: ldi r18, 1
43 ; NOX-NEXT: mov r24, r0
44 ; NOX-NEXT: adiw r30, 1
46 ; NOX-NEXT: mov r25, r0
47 ; NOX-NEXT: movw r30, r24
49 ; NOADIWNOX-LABEL: test_elpmwrdz
51 ; NOADIWNOX-NEXT: ldi r18, 1
53 ; NOADIWNOX-NEXT: elpm
54 ; NOADIWNOX-NEXT: mov r24, r0
55 ; NOADIWNOX-NEXT: subi r30, 255
56 ; NOADIWNOX-NEXT: sbci r31, 255
57 ; NOADIWNOX-NEXT: elpm
58 ; NOADIWNOX-NEXT: mov r25, r0
59 ; NOADIWNOX-NEXT: movw r30, r24
61 %1:zreg = COPY killed $r31r30
63 %3:dregs = ELPMWRdZ %1, %2, implicit-def dead $r0
70 tracksRegLiveness: true
75 ; CHECK-LABEL: test_elpmwrdz_2
77 ; CHECK-NEXT: ldi r24, 1
78 ; CHECK-NEXT: out 59, r24
79 ; CHECK-NEXT: elpm r18, Z+
80 ; CHECK-NEXT: elpm r19, Z
81 ; CHECK-NEXT: sbiw r30, 1
84 ; NOX-LABEL: test_elpmwrdz_2
86 ; NOX-NEXT: ldi r24, 1
87 ; NOX-NEXT: out 59, r24
89 ; NOX-NEXT: mov r18, r0
90 ; NOX-NEXT: adiw r30, 1
92 ; NOX-NEXT: mov r19, r0
93 ; NOX-NEXT: sbiw r30, 1
96 ; NOADIWNOX-LABEL: test_elpmwrdz_2
98 ; NOADIWNOX-NEXT: ldi r24, 1
99 ; NOADIWNOX-NEXT: out 59, r24
100 ; NOADIWNOX-NEXT: elpm
101 ; NOADIWNOX-NEXT: mov r18, r0
102 ; NOADIWNOX-NEXT: subi r30, 255
103 ; NOADIWNOX-NEXT: sbci r31, 255
104 ; NOADIWNOX-NEXT: elpm
105 ; NOADIWNOX-NEXT: mov r19, r0
106 ; NOADIWNOX-NEXT: subi r30, 1
107 ; NOADIWNOX-NEXT: sbci r31, 0
109 %1:zreg = COPY $r31r30
111 %3:dregs = ELPMWRdZ %1, %2, implicit-def dead $r0