1 ; RUN: llc -mattr=avr6,sram < %s -march=avr | FileCheck %s
3 define void @store8(i8* %x, i8 %y) {
5 ; CHECK: st {{[XYZ]}}, r22
10 define void @store16(i16* %x, i16 %y) {
11 ; CHECK-LABEL: store16:
12 ; CHECK: std {{[YZ]}}+1, r23
13 ; CHECK: st {{[YZ]}}, r22
18 define void @store8disp(i8* %x, i8 %y) {
19 ; CHECK-LABEL: store8disp:
20 ; CHECK: std {{[YZ]}}+63, r22
21 %arrayidx = getelementptr inbounds i8, i8* %x, i16 63
22 store i8 %y, i8* %arrayidx
26 define void @store8nodisp(i8* %x, i8 %y) {
27 ; CHECK-LABEL: store8nodisp:
28 ; CHECK: movw r26, r24
29 ; CHECK: subi r26, 192
30 ; CHECK: sbci r27, 255
31 ; CHECK: st {{[XYZ]}}, r22
32 %arrayidx = getelementptr inbounds i8, i8* %x, i16 64
33 store i8 %y, i8* %arrayidx
37 define void @store16disp(i16* %x, i16 %y) {
38 ; CHECK-LABEL: store16disp:
39 ; CHECK: std {{[YZ]}}+63, r23
40 ; CHECK: std {{[YZ]}}+62, r22
41 %arrayidx = getelementptr inbounds i16, i16* %x, i16 31
42 store i16 %y, i16* %arrayidx
46 define void @store16nodisp(i16* %x, i16 %y) {
47 ; CHECK-LABEL: store16nodisp:
48 ; CHECK: subi r24, 192
49 ; CHECK: sbci r25, 255
50 ; CHECK: movw r30, r24
51 ; CHECK: std {{[YZ]}}+1, r23
52 ; CHECK: st {{[YZ]}}, r22
53 %arrayidx = getelementptr inbounds i16, i16* %x, i16 32
54 store i16 %y, i16* %arrayidx
58 define void @store8postinc(i8* %x, i8 %y) {
59 ; CHECK-LABEL: store8postinc:
60 ; CHECK: st {{[XYZ]}}+, {{.*}}
62 %tobool3 = icmp eq i8 %y, 0
63 br i1 %tobool3, label %while.end, label %while.body
64 while.body: ; preds = %entry, %while.body
65 %dec5.in = phi i8 [ %dec5, %while.body ], [ %y, %entry ]
66 %x.addr.04 = phi i8* [ %incdec.ptr, %while.body ], [ %x, %entry ]
67 %dec5 = add i8 %dec5.in, -1
68 %incdec.ptr = getelementptr inbounds i8, i8* %x.addr.04, i16 1
69 store i8 %dec5, i8* %x.addr.04
70 %tobool = icmp eq i8 %dec5, 0
71 br i1 %tobool, label %while.end, label %while.body
72 while.end: ; preds = %while.body, %entry
76 define void @store16postinc(i16* %x, i16 %y) {
77 ; CHECK-LABEL: store16postinc:
78 ; CHECK: std {{[XYZ]}}+1, {{.*}}
79 ; CHECK: st {{[XYZ]}}, {{.*}}
81 %tobool3 = icmp eq i16 %y, 0
82 br i1 %tobool3, label %while.end, label %while.body
83 while.body: ; preds = %entry, %while.body
84 %dec5.in = phi i16 [ %dec5, %while.body ], [ %y, %entry ]
85 %x.addr.04 = phi i16* [ %incdec.ptr, %while.body ], [ %x, %entry ]
86 %dec5 = add nsw i16 %dec5.in, -1
87 %incdec.ptr = getelementptr inbounds i16, i16* %x.addr.04, i16 1
88 store i16 %dec5, i16* %x.addr.04
89 %tobool = icmp eq i16 %dec5, 0
90 br i1 %tobool, label %while.end, label %while.body
91 while.end: ; preds = %while.body, %entry
95 define void @store8predec(i8* %x, i8 %y) {
96 ; CHECK-LABEL: store8predec:
97 ; CHECK: st -{{[XYZ]}}, {{.*}}
99 %tobool3 = icmp eq i8 %y, 0
100 br i1 %tobool3, label %while.end, label %while.body
101 while.body: ; preds = %entry, %while.body
102 %dec5.in = phi i8 [ %dec5, %while.body ], [ %y, %entry ]
103 %x.addr.04 = phi i8* [ %incdec.ptr, %while.body ], [ %x, %entry ]
104 %dec5 = add i8 %dec5.in, -1
105 %incdec.ptr = getelementptr inbounds i8, i8* %x.addr.04, i16 -1
106 store i8 %dec5, i8* %incdec.ptr
107 %tobool = icmp eq i8 %dec5, 0
108 br i1 %tobool, label %while.end, label %while.body
109 while.end: ; preds = %while.body, %entry
113 define void @store16predec(i16* %x, i16 %y) {
114 ; CHECK-LABEL: store16predec:
115 ; CHECK: st -{{[XYZ]}}, {{.*}}
116 ; CHECK: st -{{[XYZ]}}, {{.*}}
118 %tobool3 = icmp eq i16 %y, 0
119 br i1 %tobool3, label %while.end, label %while.body
120 while.body: ; preds = %entry, %while.body
121 %dec5.in = phi i16 [ %dec5, %while.body ], [ %y, %entry ]
122 %x.addr.04 = phi i16* [ %incdec.ptr, %while.body ], [ %x, %entry ]
123 %dec5 = add nsw i16 %dec5.in, -1
124 %incdec.ptr = getelementptr inbounds i16, i16* %x.addr.04, i16 -1
125 store i16 %dec5, i16* %incdec.ptr
126 %tobool = icmp eq i16 %dec5, 0
127 br i1 %tobool, label %while.end, label %while.body
128 while.end: ; preds = %while.body, %entry