1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 -verify-machineinstrs | FileCheck %s
4 @CVal = external local_unnamed_addr global i8, align 1
5 @SVal = external local_unnamed_addr global i16, align 2
6 @IVal = external local_unnamed_addr global i32, align 4
7 @LVal = external local_unnamed_addr global i64, align 8
8 @USVal = external local_unnamed_addr global i16, align 2
9 @arr = external local_unnamed_addr global ptr, align 8
10 @arri = external local_unnamed_addr global ptr, align 8
12 ; Test the same constant can be used by different stores.
14 %struct.S = type { i64, i8, i16, i32 }
16 define void @foo(ptr %p) {
20 ; CHECK-NEXT: stb 4, 8(3)
21 ; CHECK-NEXT: std 4, 0(3)
22 ; CHECK-NEXT: sth 4, 10(3)
23 ; CHECK-NEXT: stw 4, 12(3)
25 store i64 0, ptr %p, align 8
26 %c = getelementptr %struct.S, ptr %p, i64 0, i32 1
27 store i8 0, ptr %c, align 8
28 %s = getelementptr %struct.S, ptr %p, i64 0, i32 2
29 store i16 0, ptr %s, align 2
30 %i = getelementptr %struct.S, ptr %p, i64 0, i32 3
31 store i32 0, ptr %i, align 4
36 define void @bar(ptr %p) {
40 ; CHECK-NEXT: stw 4, 12(3)
41 ; CHECK-NEXT: sth 4, 10(3)
42 ; CHECK-NEXT: std 4, 0(3)
43 ; CHECK-NEXT: stb 4, 8(3)
45 %i = getelementptr %struct.S, ptr %p, i64 0, i32 3
46 store i32 2, ptr %i, align 4
47 %s = getelementptr %struct.S, ptr %p, i64 0, i32 2
48 store i16 2, ptr %s, align 2
49 %c = getelementptr %struct.S, ptr %p, i64 0, i32 1
50 store i8 2, ptr %c, align 8
51 store i64 2, ptr %p, align 8
56 ; Function Attrs: norecurse nounwind
57 define void @setSmallNeg() {
58 ; CHECK-LABEL: setSmallNeg:
59 ; CHECK: # %bb.0: # %entry
60 ; CHECK-NEXT: addis 3, 2, .LC0@toc@ha
61 ; CHECK-NEXT: addis 4, 2, .LC1@toc@ha
62 ; CHECK-NEXT: addis 5, 2, .LC2@toc@ha
63 ; CHECK-NEXT: addis 6, 2, .LC3@toc@ha
64 ; CHECK-NEXT: li 7, -7
65 ; CHECK-NEXT: ld 3, .LC0@toc@l(3)
66 ; CHECK-NEXT: ld 4, .LC1@toc@l(4)
67 ; CHECK-NEXT: ld 5, .LC2@toc@l(5)
68 ; CHECK-NEXT: ld 6, .LC3@toc@l(6)
69 ; CHECK-NEXT: stb 7, 0(3)
70 ; CHECK-NEXT: sth 7, 0(4)
71 ; CHECK-NEXT: std 7, 0(6)
72 ; CHECK-NEXT: stw 7, 0(5)
75 store i8 -7, ptr @CVal, align 1
76 store i16 -7, ptr @SVal, align 2
77 store i32 -7, ptr @IVal, align 4
78 store i64 -7, ptr @LVal, align 8
82 ; Function Attrs: norecurse nounwind
83 define void @setSmallPos() {
84 ; CHECK-LABEL: setSmallPos:
85 ; CHECK: # %bb.0: # %entry
86 ; CHECK-NEXT: addis 3, 2, .LC0@toc@ha
87 ; CHECK-NEXT: addis 4, 2, .LC1@toc@ha
88 ; CHECK-NEXT: addis 5, 2, .LC2@toc@ha
89 ; CHECK-NEXT: addis 6, 2, .LC3@toc@ha
91 ; CHECK-NEXT: ld 3, .LC0@toc@l(3)
92 ; CHECK-NEXT: ld 4, .LC1@toc@l(4)
93 ; CHECK-NEXT: ld 5, .LC2@toc@l(5)
94 ; CHECK-NEXT: ld 6, .LC3@toc@l(6)
95 ; CHECK-NEXT: stb 7, 0(3)
96 ; CHECK-NEXT: sth 7, 0(4)
97 ; CHECK-NEXT: std 7, 0(6)
98 ; CHECK-NEXT: stw 7, 0(5)
101 store i8 8, ptr @CVal, align 1
102 store i16 8, ptr @SVal, align 2
103 store i32 8, ptr @IVal, align 4
104 store i64 8, ptr @LVal, align 8
108 ; Function Attrs: norecurse nounwind
109 define void @setMaxNeg() {
110 ; CHECK-LABEL: setMaxNeg:
111 ; CHECK: # %bb.0: # %entry
112 ; CHECK-NEXT: addis 3, 2, .LC1@toc@ha
113 ; CHECK-NEXT: addis 4, 2, .LC2@toc@ha
114 ; CHECK-NEXT: addis 5, 2, .LC3@toc@ha
115 ; CHECK-NEXT: li 6, -32768
116 ; CHECK-NEXT: ld 3, .LC1@toc@l(3)
117 ; CHECK-NEXT: ld 4, .LC2@toc@l(4)
118 ; CHECK-NEXT: ld 5, .LC3@toc@l(5)
119 ; CHECK-NEXT: sth 6, 0(3)
120 ; CHECK-NEXT: stw 6, 0(4)
121 ; CHECK-NEXT: std 6, 0(5)
124 store i16 -32768, ptr @SVal, align 2
125 store i32 -32768, ptr @IVal, align 4
126 store i64 -32768, ptr @LVal, align 8
130 ; Function Attrs: norecurse nounwind
131 define void @setMaxPos() {
132 ; CHECK-LABEL: setMaxPos:
133 ; CHECK: # %bb.0: # %entry
134 ; CHECK-NEXT: addis 3, 2, .LC1@toc@ha
135 ; CHECK-NEXT: addis 4, 2, .LC2@toc@ha
136 ; CHECK-NEXT: addis 5, 2, .LC3@toc@ha
137 ; CHECK-NEXT: li 6, 32767
138 ; CHECK-NEXT: ld 3, .LC1@toc@l(3)
139 ; CHECK-NEXT: ld 4, .LC2@toc@l(4)
140 ; CHECK-NEXT: ld 5, .LC3@toc@l(5)
141 ; CHECK-NEXT: sth 6, 0(3)
142 ; CHECK-NEXT: stw 6, 0(4)
143 ; CHECK-NEXT: std 6, 0(5)
146 store i16 32767, ptr @SVal, align 2
147 store i32 32767, ptr @IVal, align 4
148 store i64 32767, ptr @LVal, align 8
152 ; Function Attrs: norecurse nounwind
153 define void @setExcessiveNeg() {
154 ; CHECK-LABEL: setExcessiveNeg:
155 ; CHECK: # %bb.0: # %entry
156 ; CHECK-NEXT: addis 3, 2, .LC2@toc@ha
157 ; CHECK-NEXT: addis 4, 2, .LC3@toc@ha
158 ; CHECK-NEXT: lis 5, -1
159 ; CHECK-NEXT: ld 3, .LC2@toc@l(3)
160 ; CHECK-NEXT: ld 4, .LC3@toc@l(4)
161 ; CHECK-NEXT: ori 5, 5, 32767
162 ; CHECK-NEXT: stw 5, 0(3)
163 ; CHECK-NEXT: std 5, 0(4)
166 store i32 -32769, ptr @IVal, align 4
167 store i64 -32769, ptr @LVal, align 8
171 ; Function Attrs: norecurse nounwind
172 define void @setExcessivePos() {
173 ; CHECK-LABEL: setExcessivePos:
174 ; CHECK: # %bb.0: # %entry
175 ; CHECK-NEXT: addis 3, 2, .LC4@toc@ha
176 ; CHECK-NEXT: addis 4, 2, .LC2@toc@ha
177 ; CHECK-NEXT: addis 5, 2, .LC3@toc@ha
178 ; CHECK-NEXT: li 6, 0
179 ; CHECK-NEXT: ld 3, .LC4@toc@l(3)
180 ; CHECK-NEXT: ld 4, .LC2@toc@l(4)
181 ; CHECK-NEXT: ld 5, .LC3@toc@l(5)
182 ; CHECK-NEXT: ori 6, 6, 32768
183 ; CHECK-NEXT: sth 6, 0(3)
184 ; CHECK-NEXT: stw 6, 0(4)
185 ; CHECK-NEXT: std 6, 0(5)
188 store i16 -32768, ptr @USVal, align 2
189 store i32 32768, ptr @IVal, align 4
190 store i64 32768, ptr @LVal, align 8
194 define void @SetArr(i32 signext %Len) {
195 ; CHECK-LABEL: SetArr:
196 ; CHECK: # %bb.0: # %entry
197 ; CHECK-NEXT: cmpwi 3, 0
198 ; CHECK-NEXT: blelr 0
199 ; CHECK-NEXT: # %bb.1: # %for.body.lr.ph
200 ; CHECK-NEXT: addis 4, 2, .LC5@toc@ha
201 ; CHECK-NEXT: addis 5, 2, .LC6@toc@ha
202 ; CHECK-NEXT: clrldi 6, 3, 32
203 ; CHECK-NEXT: ld 4, .LC5@toc@l(4)
204 ; CHECK-NEXT: ld 5, .LC6@toc@l(5)
205 ; CHECK-NEXT: ld 4, 0(4)
206 ; CHECK-NEXT: ld 5, 0(5)
207 ; CHECK-NEXT: mtctr 6
208 ; CHECK-NEXT: addi 3, 4, -8
209 ; CHECK-NEXT: addi 4, 5, -4
210 ; CHECK-NEXT: li 5, -7
211 ; CHECK-NEXT: .p2align 4
212 ; CHECK-NEXT: .LBB8_2: # %for.body
214 ; CHECK-NEXT: stdu 5, 8(3)
215 ; CHECK-NEXT: stwu 5, 4(4)
216 ; CHECK-NEXT: bdnz .LBB8_2
217 ; CHECK-NEXT: # %bb.3: # %for.cond.cleanup
220 %cmp7 = icmp sgt i32 %Len, 0
221 br i1 %cmp7, label %for.body.lr.ph, label %for.cond.cleanup
223 for.body.lr.ph: ; preds = %entry
224 %0 = load ptr, ptr @arr, align 8
225 %1 = load ptr, ptr @arri, align 8
226 %wide.trip.count = zext i32 %Len to i64
229 for.cond.cleanup: ; preds = %for.body, %entry
232 for.body: ; preds = %for.body, %for.body.lr.ph
233 %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
234 %arrayidx = getelementptr inbounds i64, ptr %0, i64 %indvars.iv
235 store i64 -7, ptr %arrayidx, align 8
236 %arrayidx2 = getelementptr inbounds i32, ptr %1, i64 %indvars.iv
237 store i32 -7, ptr %arrayidx2, align 4
238 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
239 %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
240 br i1 %exitcond, label %for.cond.cleanup, label %for.body
243 define void @setSameValDiffSizeCI() {
244 ; CHECK-LABEL: setSameValDiffSizeCI:
245 ; CHECK: # %bb.0: # %entry
246 ; CHECK-NEXT: addis 3, 2, .LC2@toc@ha
247 ; CHECK-NEXT: addis 4, 2, .LC0@toc@ha
248 ; CHECK-NEXT: li 5, 255
249 ; CHECK-NEXT: ld 3, .LC2@toc@l(3)
250 ; CHECK-NEXT: ld 4, .LC0@toc@l(4)
251 ; CHECK-NEXT: stw 5, 0(3)
252 ; CHECK-NEXT: stb 5, 0(4)
255 store i32 255, ptr @IVal, align 4
256 store i8 -1, ptr @CVal, align 1
260 define void @setSameValDiffSizeSI() {
261 ; CHECK-LABEL: setSameValDiffSizeSI:
262 ; CHECK: # %bb.0: # %entry
263 ; CHECK-NEXT: addis 3, 2, .LC2@toc@ha
264 ; CHECK-NEXT: addis 4, 2, .LC1@toc@ha
265 ; CHECK-NEXT: li 5, 0
266 ; CHECK-NEXT: ld 3, .LC2@toc@l(3)
267 ; CHECK-NEXT: ld 4, .LC1@toc@l(4)
268 ; CHECK-NEXT: ori 5, 5, 65535
269 ; CHECK-NEXT: stw 5, 0(3)
270 ; CHECK-NEXT: sth 5, 0(4)
273 store i32 65535, ptr @IVal, align 4
274 store i16 -1, ptr @SVal, align 2