1 ; RUN: llc -mattr=avr6,sram < %s -march=avr | FileCheck %s
3 define i8 @load8(i8* %x) {
5 ; CHECK: ld r24, {{[XYZ]}}
10 define i16 @load16(i16* %x) {
11 ; CHECK-LABEL: load16:
12 ; CHECK: ld r24, [[PTR:[YZ]]]
13 ; CHECK: ldd r25, [[PTR]]+1
14 %1 = load i16, i16* %x
18 define i8 @load8disp(i8* %x) {
19 ; CHECK-LABEL: load8disp:
20 ; CHECK: ldd r24, {{[YZ]}}+63
21 %1 = getelementptr inbounds i8, i8* %x, i64 63
26 define i8 @load8nodisp(i8* %x) {
27 ; CHECK-LABEL: load8nodisp:
28 ; CHECK: movw r26, r24
29 ; CHECK: subi r26, 192
30 ; CHECK: sbci r27, 255
31 ; CHECK: ld r24, {{[XYZ]}}
32 %1 = getelementptr inbounds i8, i8* %x, i64 64
37 define i16 @load16disp(i16* %x) {
38 ; CHECK-LABEL: load16disp:
39 ; CHECK: ldd r24, [[PTR:[YZ]]]+62
40 ; CHECK: ldd r25, [[PTR]]+63
41 %1 = getelementptr inbounds i16, i16* %x, i64 31
42 %2 = load i16, i16* %1
46 define i16 @load16nodisp(i16* %x) {
47 ; CHECK-LABEL: load16nodisp:
48 ; CHECK: subi r24, 192
49 ; CHECK: sbci r25, 255
50 ; CHECK: movw r30, r24
51 ; CHECK: ld r24, [[PTR:[YZ]]]
52 ; CHECK: ldd r25, [[PTR]]+1
53 %1 = getelementptr inbounds i16, i16* %x, i64 32
54 %2 = load i16, i16* %1
58 define i8 @load8postinc(i8* %x, i8 %y) {
59 ; CHECK-LABEL: load8postinc:
60 ; CHECK: ld {{.*}}, {{[XYZ]}}+
62 %tobool6 = icmp eq i8 %y, 0
63 br i1 %tobool6, label %while.end, label %while.body
64 while.body: ; preds = %entry, %while.body
65 %r.09 = phi i8 [ %add, %while.body ], [ 0, %entry ]
66 %y.addr.08 = phi i8 [ %dec, %while.body ], [ %y, %entry ]
67 %x.addr.07 = phi i8* [ %incdec.ptr, %while.body ], [ %x, %entry ]
68 %dec = add i8 %y.addr.08, -1
69 %incdec.ptr = getelementptr inbounds i8, i8* %x.addr.07, i16 1
70 %0 = load i8, i8* %x.addr.07
71 %add = add i8 %0, %r.09
72 %tobool = icmp eq i8 %dec, 0
73 br i1 %tobool, label %while.end, label %while.body
74 while.end: ; preds = %while.body, %entry
75 %r.0.lcssa = phi i8 [ 0, %entry ], [ %add, %while.body ]
79 define i16 @load16postinc(i16* %x, i16 %y) {
80 ; CHECK-LABEL: load16postinc:
81 ; CHECK: ld {{.*}}, {{[XYZ]}}+
82 ; CHECK: ld {{.*}}, {{[XYZ]}}+
84 %tobool2 = icmp eq i16 %y, 0
85 br i1 %tobool2, label %while.end, label %while.body
86 while.body: ; preds = %entry, %while.body
87 %r.05 = phi i16 [ %add, %while.body ], [ 0, %entry ]
88 %y.addr.04 = phi i16 [ %dec, %while.body ], [ %y, %entry ]
89 %x.addr.03 = phi i16* [ %incdec.ptr, %while.body ], [ %x, %entry ]
90 %dec = add nsw i16 %y.addr.04, -1
91 %incdec.ptr = getelementptr inbounds i16, i16* %x.addr.03, i16 1
92 %0 = load i16, i16* %x.addr.03
93 %add = add nsw i16 %0, %r.05
94 %tobool = icmp eq i16 %dec, 0
95 br i1 %tobool, label %while.end, label %while.body
96 while.end: ; preds = %while.body, %entry
97 %r.0.lcssa = phi i16 [ 0, %entry ], [ %add, %while.body ]
101 define i8 @load8predec(i8* %x, i8 %y) {
102 ; CHECK-LABEL: load8predec:
103 ; CHECK: ld {{.*}}, -{{[XYZ]}}
105 %tobool6 = icmp eq i8 %y, 0
106 br i1 %tobool6, label %while.end, label %while.body
107 while.body: ; preds = %entry, %while.body
108 %r.09 = phi i8 [ %add, %while.body ], [ 0, %entry ]
109 %y.addr.08 = phi i8 [ %dec, %while.body ], [ %y, %entry ]
110 %x.addr.07 = phi i8* [ %incdec.ptr, %while.body ], [ %x, %entry ]
111 %dec = add i8 %y.addr.08, -1
112 %incdec.ptr = getelementptr inbounds i8, i8* %x.addr.07, i16 -1
113 %0 = load i8, i8* %incdec.ptr
114 %add = add i8 %0, %r.09
115 %tobool = icmp eq i8 %dec, 0
116 br i1 %tobool, label %while.end, label %while.body
117 while.end: ; preds = %while.body, %entry
118 %r.0.lcssa = phi i8 [ 0, %entry ], [ %add, %while.body ]
122 define i16 @load16predec(i16* %x, i16 %y) {
123 ; CHECK-LABEL: load16predec:
124 ; CHECK: ld {{.*}}, -{{[XYZ]}}
125 ; CHECK: ld {{.*}}, -{{[XYZ]}}
127 %tobool2 = icmp eq i16 %y, 0
128 br i1 %tobool2, label %while.end, label %while.body
129 while.body: ; preds = %entry, %while.body
130 %r.05 = phi i16 [ %add, %while.body ], [ 0, %entry ]
131 %y.addr.04 = phi i16 [ %dec, %while.body ], [ %y, %entry ]
132 %x.addr.03 = phi i16* [ %incdec.ptr, %while.body ], [ %x, %entry ]
133 %dec = add nsw i16 %y.addr.04, -1
134 %incdec.ptr = getelementptr inbounds i16, i16* %x.addr.03, i16 -1
135 %0 = load i16, i16* %incdec.ptr
136 %add = add nsw i16 %0, %r.05
137 %tobool = icmp eq i16 %dec, 0
138 br i1 %tobool, label %while.end, label %while.body
139 while.end: ; preds = %while.body, %entry
140 %r.0.lcssa = phi i16 [ 0, %entry ], [ %add, %while.body ]