• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mattr=avr6,sram < %s -march=avr | FileCheck %s
2
3define i8 @load8(i8* %x) {
4; CHECK-LABEL: load8:
5; CHECK: ld r24, {{[XYZ]}}
6  %1 = load i8, i8* %x
7  ret i8 %1
8}
9
10define i16 @load16(i16* %x) {
11; CHECK-LABEL: load16:
12; CHECK: ld r24, {{[XYZ]}}+
13; CHECK: ld r25, {{[XYZ]}}
14  %1 = load i16, i16* %x
15  ret i16 %1
16}
17
18define i8 @load8disp(i8* %x) {
19; CHECK-LABEL: load8disp:
20; CHECK: ldd r24, {{[YZ]}}+63
21  %1 = getelementptr inbounds i8, i8* %x, i64 63
22  %2 = load i8, i8* %1
23  ret i8 %2
24}
25
26define 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
33  %2 = load i8, i8* %1
34  ret i8 %2
35}
36
37define i16 @load16disp(i16* %x) {
38; CHECK-LABEL: load16disp:
39; CHECK: ldd r24, {{[YZ]}}+62
40; CHECK: ldd r25, {{[YZ]}}+63
41  %1 = getelementptr inbounds i16, i16* %x, i64 31
42  %2 = load i16, i16* %1
43  ret i16 %2
44}
45
46define i16 @load16nodisp(i16* %x) {
47; CHECK-LABEL: load16nodisp:
48; CHECK: movw r26, r24
49; CHECK: subi r26, 192
50; CHECK: sbci r27, 255
51; CHECK: ld r24, {{[XYZ]}}+
52; CHECK: ld r25, {{[XYZ]}}
53  %1 = getelementptr inbounds i16, i16* %x, i64 32
54  %2 = load i16, i16* %1
55  ret i16 %2
56}
57
58define i8 @load8postinc(i8* %x, i8 %y) {
59; CHECK-LABEL: load8postinc:
60; CHECK: ld {{.*}}, {{[XYZ]}}+
61entry:
62  %tobool6 = icmp eq i8 %y, 0
63  br i1 %tobool6, label %while.end, label %while.body
64while.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
74while.end:                                        ; preds = %while.body, %entry
75  %r.0.lcssa = phi i8 [ 0, %entry ], [ %add, %while.body ]
76  ret i8 %r.0.lcssa
77}
78
79define i16 @load16postinc(i16* %x, i16 %y) {
80; CHECK-LABEL: load16postinc:
81; CHECK: ld {{.*}}, {{[XYZ]}}+
82; CHECK: ld {{.*}}, {{[XYZ]}}+
83entry:
84  %tobool2 = icmp eq i16 %y, 0
85  br i1 %tobool2, label %while.end, label %while.body
86while.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
96while.end:                                        ; preds = %while.body, %entry
97  %r.0.lcssa = phi i16 [ 0, %entry ], [ %add, %while.body ]
98  ret i16 %r.0.lcssa
99}
100
101define i8 @load8predec(i8* %x, i8 %y) {
102; CHECK-LABEL: load8predec:
103; CHECK: ld {{.*}}, -{{[XYZ]}}
104entry:
105  %tobool6 = icmp eq i8 %y, 0
106  br i1 %tobool6, label %while.end, label %while.body
107while.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
117while.end:                                        ; preds = %while.body, %entry
118  %r.0.lcssa = phi i8 [ 0, %entry ], [ %add, %while.body ]
119  ret i8 %r.0.lcssa
120}
121
122define i16 @load16predec(i16* %x, i16 %y) {
123; CHECK-LABEL: load16predec:
124; CHECK: ld {{.*}}, -{{[XYZ]}}
125; CHECK: ld {{.*}}, -{{[XYZ]}}
126entry:
127  %tobool2 = icmp eq i16 %y, 0
128  br i1 %tobool2, label %while.end, label %while.body
129while.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
139while.end:                                        ; preds = %while.body, %entry
140  %r.0.lcssa = phi i16 [ 0, %entry ], [ %add, %while.body ]
141  ret i16 %r.0.lcssa
142}
143