1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -relocation-model=pic | FileCheck %s -check-prefixes=CHECK,PIC
4 ; Test folding constant offsets and symbols into load and store addresses under
5 ; a variety of circumstances.
7 target triple = "wasm32-unknown-emscripten"
9 @g = external global [0 x i32], align 4
11 ; CHECK-LABEL: load_test0:
12 ; CHECK-NEXT: .functype load_test0 () -> (i32){{$}}
13 ; PIC-NEXT: global.get $push0=, g@GOT{{$}}
14 ; PIC-NEXT: i32.load $push1=, 40($pop0){{$}}
15 ; CHECK-NEXT: return $pop1{{$}}
16 define i32 @load_test0() {
17 %t = load i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @g, i32 0, i32 10), align 4
21 ; CHECK-LABEL: load_test0_noinbounds:
22 ; CHECK-NEXT: .functype load_test0_noinbounds () -> (i32){{$}}
23 ; PIC-NEXT: global.get $push0=, g@GOT{{$}}
24 ; PIC-NEXT: i32.load $push1=, 40($pop0){{$}}
25 ; CHECK-NEXT: return $pop1{{$}}
26 define i32 @load_test0_noinbounds() {
27 %t = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @g, i32 0, i32 10), align 4
31 ; TODO: load_test1 - load_test8 are disabled because folding GA+reg is disabled
32 ; (there are cases where the value in the reg can be negative).
33 ; Likewise for stores.
35 ; CHECK-LABEL: load_test1:
36 ; CHECK-NEXT: .functype load_test1 (i32) -> (i32){{$}}
37 ; CHECK-NEX T: i32.const $push0=, 2{{$}}
38 ; CHECK-NEX T: i32.shl $push1=, $0, $pop0{{$}}
39 ; CHECK-NEX T: i32.load $push2=, g+40($pop1){{$}}
40 ; CHECK-NEX T: return $pop2{{$}}
41 define i32 @load_test1(i32 %n) {
42 %add = add nsw i32 %n, 10
43 %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
44 %t = load i32, i32* %arrayidx, align 4
48 ; CHECK-LABEL: load_test2:
49 ; CHECK-NEXT: .functype load_test2 (i32) -> (i32){{$}}
50 ; CHECK-NEX T: i32.const $push0=, 2{{$}}
51 ; CHECK-NEX T: i32.shl $push1=, $0, $pop0{{$}}
52 ; CHECK-NEX T: i32.load $push2=, g+40($pop1){{$}}
53 ; CHECK-NEX T: return $pop2{{$}}
54 define i32 @load_test2(i32 %n) {
55 %add = add nsw i32 10, %n
56 %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
57 %t = load i32, i32* %arrayidx, align 4
61 ; CHECK-LABEL: load_test3:
62 ; CHECK-NEXT: .functype load_test3 (i32) -> (i32){{$}}
63 ; CHECK-NEX T: i32.const $push0=, 2{{$}}
64 ; CHECK-NEX T: i32.shl $push1=, $0, $pop0{{$}}
65 ; CHECK-NEX T: i32.load $push2=, g+40($pop1){{$}}
66 ; CHECK-NEX T: return $pop2{{$}}
67 define i32 @load_test3(i32 %n) {
68 %add.ptr = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %n
69 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 10
70 %t = load i32, i32* %add.ptr1, align 4
74 ; CHECK-LABEL: load_test4:
75 ; CHECK-NEXT: .functype load_test4 (i32) -> (i32){{$}}
76 ; CHECK-NEX T: i32.const $push0=, 2{{$}}
77 ; CHECK-NEX T: i32.shl $push1=, $0, $pop0{{$}}
78 ; CHECK-NEX T: i32.load $push2=, g+40($pop1){{$}}
79 ; CHECK-NEX T: return $pop2{{$}}
80 define i32 @load_test4(i32 %n) {
81 %add.ptr = getelementptr inbounds i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @g, i32 0, i32 10), i32 %n
82 %t = load i32, i32* %add.ptr, align 4
86 ; CHECK-LABEL: load_test5:
87 ; CHECK-NEXT: .functype load_test5 (i32) -> (i32){{$}}
88 ; CHECK-NEX T: i32.const $push0=, 2{{$}}
89 ; CHECK-NEX T: i32.shl $push1=, $0, $pop0{{$}}
90 ; CHECK-NEX T: i32.load $push2=, g+40($pop1){{$}}
91 ; CHECK-NEX T: return $pop2{{$}}
92 define i32 @load_test5(i32 %n) {
93 %add.ptr = getelementptr inbounds i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @g, i32 0, i32 10), i32 %n
94 %t = load i32, i32* %add.ptr, align 4
98 ; CHECK-LABEL: load_test6:
99 ; CHECK-NEXT: .functype load_test6 (i32) -> (i32){{$}}
100 ; CHECK-NEX T: i32.const $push0=, 2{{$}}
101 ; CHECK-NEX T: i32.shl $push1=, $0, $pop0{{$}}
102 ; CHECK-NEX T: i32.load $push2=, g+40($pop1){{$}}
103 ; CHECK-NEX T: return $pop2{{$}}
104 define i32 @load_test6(i32 %n) {
105 %add = add nsw i32 %n, 10
106 %add.ptr = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
107 %t = load i32, i32* %add.ptr, align 4
111 ; CHECK-LABEL: load_test7:
112 ; CHECK-NEXT: .functype load_test7 (i32) -> (i32){{$}}
113 ; CHECK-NEX T: i32.const $push0=, 2{{$}}
114 ; CHECK-NEX T: i32.shl $push1=, $0, $pop0{{$}}
115 ; CHECK-NEX T: i32.load $push2=, g+40($pop1){{$}}
116 ; CHECK-NEX T: return $pop2{{$}}
117 define i32 @load_test7(i32 %n) {
118 %add.ptr = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %n
119 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 10
120 %t = load i32, i32* %add.ptr1, align 4
124 ; CHECK-LABEL: load_test8:
125 ; CHECK-NEXT: .functype load_test8 (i32) -> (i32){{$}}
126 ; CHECK-NEX T: i32.const $push0=, 2{{$}}
127 ; CHECK-NEX T: i32.shl $push1=, $0, $pop0{{$}}
128 ; CHECK-NEX T: i32.load $push2=, g+40($pop1){{$}}
129 ; CHECK-NEX T: return $pop2{{$}}
130 define i32 @load_test8(i32 %n) {
131 %add = add nsw i32 10, %n
132 %add.ptr = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
133 %t = load i32, i32* %add.ptr, align 4
137 ; CHECK-LABEL: load_test9:
138 ; CHECK-NEXT: .functype load_test9 () -> (i32){{$}}
140 ; PIC-NEXT: global.get $push1=, g@GOT{{$}}
141 ; PIC-NEXT: i32.const $push0=, -40{{$}}
142 ; PIC-NEXT: i32.add $push2=, $pop1, $pop0{{$}}
143 ; PIC-NEXT: i32.load $push3=, 0($pop2)
144 ; PIC-NEXT: return $pop3{{$}}
145 define i32 @load_test9() {
146 %t = load i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @g, i32 0, i32 1073741814), align 4
150 ; CHECK-LABEL: load_test10:
151 ; CHECK-NEXT: .functype load_test10 (i32) -> (i32){{$}}
153 ; PIC-NEXT: i32.const $push0=, 2{{$}}
154 ; PIC-NEXT: i32.shl $push1=, $0, $pop0{{$}}
155 ; PIC-NEXT: global.get $push2=, g@GOT{{$}}
156 ; PIC-NEXT: i32.add $push3=, $pop1, $pop2{{$}}
157 ; PIC-NEXT: i32.const $push4=, -40{{$}}
158 ; PIC-NEXT: i32.add $push5=, $pop3, $pop4{{$}}
159 ; PIC-NEXT: i32.load $push6=, 0($pop5){{$}}
160 ; PIC-NEXT: return $pop6{{$}}
161 define i32 @load_test10(i32 %n) {
162 %add = add nsw i32 %n, -10
163 %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
164 %t = load i32, i32* %arrayidx, align 4
168 ; CHECK-LABEL: load_test11:
169 ; CHECK-NEXT: .functype load_test11 (i32) -> (i32){{$}}
170 ; CHECK-NEXT: i32.load $push0=, 40($0){{$}}
171 ; CHECK-NEXT: return $pop0{{$}}
172 define i32 @load_test11(i32* %p) {
173 %arrayidx = getelementptr inbounds i32, i32* %p, i32 10
174 %t = load i32, i32* %arrayidx, align 4
178 ; CHECK-LABEL: load_test11_noinbounds:
179 ; CHECK-NEXT: .functype load_test11_noinbounds (i32) -> (i32){{$}}
180 ; CHECK-NEXT: i32.const $push0=, 40{{$}}
181 ; CHECK-NEXT: i32.add $push1=, $0, $pop0{{$}}
182 ; CHECK-NEXT: i32.load $push2=, 0($pop1){{$}}
183 ; CHECK-NEXT: return $pop2{{$}}
184 define i32 @load_test11_noinbounds(i32* %p) {
185 %arrayidx = getelementptr i32, i32* %p, i32 10
186 %t = load i32, i32* %arrayidx, align 4
190 ; CHECK-LABEL: load_test12:
191 ; CHECK-NEXT: .functype load_test12 (i32, i32) -> (i32){{$}}
192 ; CHECK-NEXT: i32.const $push0=, 2{{$}}
193 ; CHECK-NEXT: i32.shl $push1=, $1, $pop0{{$}}
194 ; CHECK-NEXT: i32.add $push2=, $pop1, $0{{$}}
195 ; CHECK-NEXT: i32.const $push3=, 40{{$}}
196 ; CHECK-NEXT: i32.add $push4=, $pop2, $pop3{{$}}
197 ; CHECK-NEXT: i32.load $push5=, 0($pop4){{$}}
198 ; CHECK-NEXT: return $pop5{{$}}
199 define i32 @load_test12(i32* %p, i32 %n) {
200 %add = add nsw i32 %n, 10
201 %arrayidx = getelementptr inbounds i32, i32* %p, i32 %add
202 %t = load i32, i32* %arrayidx, align 4
206 ; CHECK-LABEL: load_test13:
207 ; CHECK-NEXT: .functype load_test13 (i32, i32) -> (i32){{$}}
208 ; CHECK-NEXT: i32.const $push0=, 2{{$}}
209 ; CHECK-NEXT: i32.shl $push1=, $1, $pop0{{$}}
210 ; CHECK-NEXT: i32.add $push2=, $pop1, $0{{$}}
211 ; CHECK-NEXT: i32.const $push3=, 40{{$}}
212 ; CHECK-NEXT: i32.add $push4=, $pop2, $pop3{{$}}
213 ; CHECK-NEXT: i32.load $push5=, 0($pop4){{$}}
214 ; CHECK-NEXT: return $pop5{{$}}
215 define i32 @load_test13(i32* %p, i32 %n) {
216 %add = add nsw i32 10, %n
217 %arrayidx = getelementptr inbounds i32, i32* %p, i32 %add
218 %t = load i32, i32* %arrayidx, align 4
222 ; CHECK-LABEL: load_test14:
223 ; CHECK-NEXT: .functype load_test14 (i32, i32) -> (i32){{$}}
224 ; CHECK-NEXT: i32.const $push0=, 2{{$}}
225 ; CHECK-NEXT: i32.shl $push1=, $1, $pop0{{$}}
226 ; CHECK-NEXT: i32.add $push2=, $0, $pop1{{$}}
227 ; CHECK-NEXT: i32.load $push3=, 40($pop2){{$}}
228 ; CHECK-NEXT: return $pop3{{$}}
229 define i32 @load_test14(i32* %p, i32 %n) {
230 %add.ptr = getelementptr inbounds i32, i32* %p, i32 %n
231 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 10
232 %t = load i32, i32* %add.ptr1, align 4
236 ; CHECK-LABEL: load_test15:
237 ; CHECK-NEXT: .functype load_test15 (i32, i32) -> (i32){{$}}
238 ; CHECK-NEXT: i32.const $push0=, 2{{$}}
239 ; CHECK-NEXT: i32.shl $push1=, $1, $pop0{{$}}
240 ; CHECK-NEXT: i32.add $push2=, $0, $pop1{{$}}
241 ; CHECK-NEXT: i32.const $push3=, 40{{$}}
242 ; CHECK-NEXT: i32.add $push4=, $pop2, $pop3{{$}}
243 ; CHECK-NEXT: i32.load $push5=, 0($pop4){{$}}
244 ; CHECK-NEXT: return $pop5{{$}}
245 define i32 @load_test15(i32* %p, i32 %n) {
246 %add.ptr = getelementptr inbounds i32, i32* %p, i32 10
247 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 %n
248 %t = load i32, i32* %add.ptr1, align 4
252 ; CHECK-LABEL: load_test16:
253 ; CHECK-NEXT: .functype load_test16 (i32, i32) -> (i32){{$}}
254 ; CHECK-NEXT: i32.const $push0=, 2{{$}}
255 ; CHECK-NEXT: i32.shl $push1=, $1, $pop0{{$}}
256 ; CHECK-NEXT: i32.add $push2=, $0, $pop1{{$}}
257 ; CHECK-NEXT: i32.const $push3=, 40{{$}}
258 ; CHECK-NEXT: i32.add $push4=, $pop2, $pop3{{$}}
259 ; CHECK-NEXT: i32.load $push5=, 0($pop4){{$}}
260 ; CHECK-NEXT: return $pop5{{$}}
261 define i32 @load_test16(i32* %p, i32 %n) {
262 %add.ptr = getelementptr inbounds i32, i32* %p, i32 10
263 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 %n
264 %t = load i32, i32* %add.ptr1, align 4
268 ; CHECK-LABEL: load_test17:
269 ; CHECK-NEXT: .functype load_test17 (i32, i32) -> (i32){{$}}
270 ; CHECK-NEXT: i32.const $push0=, 2{{$}}
271 ; CHECK-NEXT: i32.shl $push1=, $1, $pop0{{$}}
272 ; CHECK-NEXT: i32.add $push2=, $pop1, $0{{$}}
273 ; CHECK-NEXT: i32.const $push3=, 40{{$}}
274 ; CHECK-NEXT: i32.add $push4=, $pop2, $pop3{{$}}
275 ; CHECK-NEXT: i32.load $push5=, 0($pop4){{$}}
276 ; CHECK-NEXT: return $pop5{{$}}
277 define i32 @load_test17(i32* %p, i32 %n) {
278 %add = add nsw i32 %n, 10
279 %add.ptr = getelementptr inbounds i32, i32* %p, i32 %add
280 %t = load i32, i32* %add.ptr, align 4
284 ; CHECK-LABEL: load_test18:
285 ; CHECK-NEXT: .functype load_test18 (i32, i32) -> (i32){{$}}
286 ; CHECK-NEXT: i32.const $push0=, 2{{$}}
287 ; CHECK-NEXT: i32.shl $push1=, $1, $pop0{{$}}
288 ; CHECK-NEXT: i32.add $push2=, $0, $pop1{{$}}
289 ; CHECK-NEXT: i32.load $push3=, 40($pop2){{$}}
290 ; CHECK-NEXT: return $pop3{{$}}
291 define i32 @load_test18(i32* %p, i32 %n) {
292 %add.ptr = getelementptr inbounds i32, i32* %p, i32 %n
293 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 10
294 %t = load i32, i32* %add.ptr1, align 4
298 ; CHECK-LABEL: load_test19:
299 ; CHECK-NEXT: .functype load_test19 (i32, i32) -> (i32){{$}}
300 ; CHECK-NEXT: i32.const $push0=, 2{{$}}
301 ; CHECK-NEXT: i32.shl $push1=, $1, $pop0{{$}}
302 ; CHECK-NEXT: i32.add $push2=, $pop1, $0{{$}}
303 ; CHECK-NEXT: i32.const $push3=, 40{{$}}
304 ; CHECK-NEXT: i32.add $push4=, $pop2, $pop3{{$}}
305 ; CHECK-NEXT: i32.load $push5=, 0($pop4){{$}}
306 ; CHECK-NEXT: return $pop5{{$}}
307 define i32 @load_test19(i32* %p, i32 %n) {
308 %add = add nsw i32 10, %n
309 %add.ptr = getelementptr inbounds i32, i32* %p, i32 %add
310 %t = load i32, i32* %add.ptr, align 4
314 ; CHECK-LABEL: load_test20:
315 ; CHECK-NEXT: .functype load_test20 (i32) -> (i32){{$}}
316 ; CHECK-NEXT: i32.const $push0=, -40{{$}}
317 ; CHECK-NEXT: i32.add $push1=, $0, $pop0{{$}}
318 ; CHECK-NEXT: i32.load $push2=, 0($pop1){{$}}
319 ; CHECK-NEXT: return $pop2{{$}}
320 define i32 @load_test20(i32* %p) {
321 %arrayidx = getelementptr inbounds i32, i32* %p, i32 -10
322 %t = load i32, i32* %arrayidx, align 4
326 ; CHECK-LABEL: load_test21:
327 ; CHECK-NEXT: .functype load_test21 (i32, i32) -> (i32){{$}}
328 ; CHECK-NEXT: i32.const $push0=, 2{{$}}
329 ; CHECK-NEXT: i32.shl $push1=, $1, $pop0{{$}}
330 ; CHECK-NEXT: i32.add $push2=, $pop1, $0{{$}}
331 ; CHECK-NEXT: i32.const $push3=, -40{{$}}
332 ; CHECK-NEXT: i32.add $push4=, $pop2, $pop3{{$}}
333 ; CHECK-NEXT: i32.load $push5=, 0($pop4){{$}}
334 ; CHECK-NEXT: return $pop5{{$}}
335 define i32 @load_test21(i32* %p, i32 %n) {
336 %add = add nsw i32 %n, -10
337 %arrayidx = getelementptr inbounds i32, i32* %p, i32 %add
338 %t = load i32, i32* %arrayidx, align 4
342 ; CHECK-LABEL: store_test0:
343 ; CHECK-NEXT: .functype store_test0 (i32) -> (){{$}}
344 ; PIC-NEXT: global.get $push0=, g@GOT{{$}}
345 ; PIC-NEXT: i32.store 40($pop0), $0
346 ; CHECK-NEXT: return{{$}}
347 define void @store_test0(i32 %i) {
348 store i32 %i, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @g, i32 0, i32 10), align 4
352 ; CHECK-LABEL: store_test0_noinbounds:
353 ; CHECK-NEXT: .functype store_test0_noinbounds (i32) -> (){{$}}
354 ; PIC-NEXT: global.get $push0=, g@GOT{{$}}
355 ; PIC-NEXT: i32.store 40($pop0), $0{{$}}
356 ; CHECK-NEXT: return{{$}}
357 define void @store_test0_noinbounds(i32 %i) {
358 store i32 %i, i32* getelementptr ([0 x i32], [0 x i32]* @g, i32 0, i32 10), align 4
362 ; CHECK-LABEL: store_test1:
363 ; CHECK-NEXT: .functype store_test1 (i32, i32) -> (){{$}}
364 ; CHECK-NEX T: i32.store g+40($pop1), $1{{$}}
365 ; CHECK-NEX T: return{{$}}
366 define void @store_test1(i32 %n, i32 %i) {
367 %add = add nsw i32 %n, 10
368 %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
369 store i32 %i, i32* %arrayidx, align 4
373 ; CHECK-LABEL: store_test2:
374 ; CHECK-NEXT: .functype store_test2 (i32, i32) -> (){{$}}
375 ; CHECK-NEX T: i32.store g+40($pop1), $1{{$}}
376 ; CHECK-NEX T: return{{$}}
377 define void @store_test2(i32 %n, i32 %i) {
378 %add = add nsw i32 10, %n
379 %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
380 store i32 %i, i32* %arrayidx, align 4
384 ; CHECK-LABEL: store_test3:
385 ; CHECK-NEXT: .functype store_test3 (i32, i32) -> (){{$}}
386 ; CHECK-NEX T: i32.store g+40($pop1), $1{{$}}
387 ; CHECK-NEX T: return{{$}}
388 define void @store_test3(i32 %n, i32 %i) {
389 %add.ptr = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %n
390 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 10
391 store i32 %i, i32* %add.ptr1, align 4
395 ; CHECK-LABEL: store_test4:
396 ; CHECK-NEXT: .functype store_test4 (i32, i32) -> (){{$}}
397 ; CHECK-NEX T: i32.store g+40($pop1), $1{{$}}
398 ; CHECK-NEX T: return{{$}}
399 define void @store_test4(i32 %n, i32 %i) {
400 %add.ptr = getelementptr inbounds i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @g, i32 0, i32 10), i32 %n
401 store i32 %i, i32* %add.ptr, align 4
405 ; CHECK-LABEL: store_test5:
406 ; CHECK-NEXT: .functype store_test5 (i32, i32) -> (){{$}}
407 ; CHECK-NEX T: i32.store g+40($pop1), $1{{$}}
408 ; CHECK-NEX T: return{{$}}
409 define void @store_test5(i32 %n, i32 %i) {
410 %add.ptr = getelementptr inbounds i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @g, i32 0, i32 10), i32 %n
411 store i32 %i, i32* %add.ptr, align 4
415 ; CHECK-LABEL: store_test6:
416 ; CHECK-NEXT: .functype store_test6 (i32, i32) -> (){{$}}
417 ; CHECK-NEX T: i32.store g+40($pop1), $1{{$}}
418 ; CHECK-NEX T: return{{$}}
419 define void @store_test6(i32 %n, i32 %i) {
420 %add = add nsw i32 %n, 10
421 %add.ptr = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
422 store i32 %i, i32* %add.ptr, align 4
426 ; CHECK-LABEL: store_test7:
427 ; CHECK-NEXT: .functype store_test7 (i32, i32) -> (){{$}}
428 ; CHECK-NEX T: i32.store g+40($pop1), $1{{$}}
429 ; CHECK-NEX T: return{{$}}
430 define void @store_test7(i32 %n, i32 %i) {
431 %add.ptr = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %n
432 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 10
433 store i32 %i, i32* %add.ptr1, align 4
437 ; CHECK-LABEL: store_test8:
438 ; CHECK-NEXT: .functype store_test8 (i32, i32) -> (){{$}}
439 ; CHECK-NEX T: i32.store g+40($pop1), $1{{$}}
440 ; CHECK-NEX T: return{{$}}
441 define void @store_test8(i32 %n, i32 %i) {
442 %add = add nsw i32 10, %n
443 %add.ptr = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
444 store i32 %i, i32* %add.ptr, align 4
448 ; CHECK-LABEL: store_test9:
449 ; CHECK-NEXT: .functype store_test9 (i32) -> (){{$}}
450 ; PIC-NEXT: global.get $push1=, g@GOT{{$}}
451 ; PIC-NEXT: i32.const $push0=, -40{{$}}
452 ; PIC-NEXT: i32.add $push2=, $pop1, $pop0{{$}}
453 ; PIC-NEXT: i32.store 0($pop2), $0
454 ; CHECK-NEXT: return{{$}}
455 define void @store_test9(i32 %i) {
456 store i32 %i, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @g, i32 0, i32 1073741814), align 4
460 ; CHECK-LABEL: store_test10:
461 ; CHECK-NEXT: .functype store_test10 (i32, i32) -> (){{$}}
462 ; PIC-NEXT: i32.const $push0=, 2{{$}}
463 ; PIC-NEXT: i32.shl $push1=, $0, $pop0{{$}}
464 ; PIC-NEXT: global.get $push2=, g@GOT{{$}}
465 ; PIC-NEXT: i32.add $push3=, $pop1, $pop2{{$}}
466 ; PIC-NEXT: i32.const $push4=, -40{{$}}
467 ; PIC-NEXT: i32.add $push5=, $pop3, $pop4{{$}}
468 ; PIC-NEXT: i32.store 0($pop5), $1{{$}}
469 ; CHECK-NEXT: return{{$}}
470 define void @store_test10(i32 %n, i32 %i) {
471 %add = add nsw i32 %n, -10
472 %arrayidx = getelementptr inbounds [0 x i32], [0 x i32]* @g, i32 0, i32 %add
473 store i32 %i, i32* %arrayidx, align 4
477 ; CHECK-LABEL: store_test11:
478 ; CHECK-NEXT: .functype store_test11 (i32, i32) -> (){{$}}
479 ; CHECK-NEXT: i32.store 40($0), $1{{$}}
480 ; CHECK-NEXT: return{{$}}
481 define void @store_test11(i32* %p, i32 %i) {
482 %arrayidx = getelementptr inbounds i32, i32* %p, i32 10
483 store i32 %i, i32* %arrayidx, align 4
487 ; CHECK-LABEL: store_test11_noinbounds:
488 ; CHECK-NEXT: .functype store_test11_noinbounds (i32, i32) -> (){{$}}
489 ; CHECK-NEXT: i32.const $push0=, 40{{$}}
490 ; CHECK-NEXT: i32.add $push1=, $0, $pop0{{$}}
491 ; CHECK-NEXT: i32.store 0($pop1), $1{{$}}
492 ; CHECK-NEXT: return{{$}}
493 define void @store_test11_noinbounds(i32* %p, i32 %i) {
494 %arrayidx = getelementptr i32, i32* %p, i32 10
495 store i32 %i, i32* %arrayidx, align 4
499 ; CHECK-LABEL: store_test12:
500 ; CHECK-NEXT: .functype store_test12 (i32, i32, i32) -> (){{$}}
501 define void @store_test12(i32* %p, i32 %n, i32 %i) {
502 %add = add nsw i32 %n, 10
503 %arrayidx = getelementptr inbounds i32, i32* %p, i32 %add
504 store i32 %i, i32* %arrayidx, align 4
508 ; CHECK-LABEL: store_test13:
509 ; CHECK-NEXT: .functype store_test13 (i32, i32, i32) -> (){{$}}
510 define void @store_test13(i32* %p, i32 %n, i32 %i) {
511 %add = add nsw i32 10, %n
512 %arrayidx = getelementptr inbounds i32, i32* %p, i32 %add
513 store i32 %i, i32* %arrayidx, align 4
517 ; CHECK-LABEL: store_test14:
518 ; CHECK-NEXT: .functype store_test14 (i32, i32, i32) -> (){{$}}
519 define void @store_test14(i32* %p, i32 %n, i32 %i) {
520 %add.ptr = getelementptr inbounds i32, i32* %p, i32 %n
521 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 10
522 store i32 %i, i32* %add.ptr1, align 4
526 ; CHECK-LABEL: store_test15:
527 ; CHECK-NEXT: .functype store_test15 (i32, i32, i32) -> (){{$}}
528 define void @store_test15(i32* %p, i32 %n, i32 %i) {
529 %add.ptr = getelementptr inbounds i32, i32* %p, i32 10
530 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 %n
531 store i32 %i, i32* %add.ptr1, align 4
535 ; CHECK-LABEL: store_test16:
536 ; CHECK-NEXT: .functype store_test16 (i32, i32, i32) -> (){{$}}
537 define void @store_test16(i32* %p, i32 %n, i32 %i) {
538 %add.ptr = getelementptr inbounds i32, i32* %p, i32 10
539 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 %n
540 store i32 %i, i32* %add.ptr1, align 4
544 ; CHECK-LABEL: store_test17:
545 ; CHECK-NEXT: .functype store_test17 (i32, i32, i32) -> (){{$}}
546 define void @store_test17(i32* %p, i32 %n, i32 %i) {
547 %add = add nsw i32 %n, 10
548 %add.ptr = getelementptr inbounds i32, i32* %p, i32 %add
549 store i32 %i, i32* %add.ptr, align 4
553 ; CHECK-LABEL: store_test18:
554 ; CHECK-NEXT: .functype store_test18 (i32, i32, i32) -> (){{$}}
555 define void @store_test18(i32* %p, i32 %n, i32 %i) {
556 %add.ptr = getelementptr inbounds i32, i32* %p, i32 %n
557 %add.ptr1 = getelementptr inbounds i32, i32* %add.ptr, i32 10
558 store i32 %i, i32* %add.ptr1, align 4
562 ; CHECK-LABEL: store_test19:
563 ; CHECK-NEXT: .functype store_test19 (i32, i32, i32) -> (){{$}}
564 define void @store_test19(i32* %p, i32 %n, i32 %i) {
565 %add = add nsw i32 10, %n
566 %add.ptr = getelementptr inbounds i32, i32* %p, i32 %add
567 store i32 %i, i32* %add.ptr, align 4
571 ; CHECK-LABEL: store_test20:
572 ; CHECK-NEXT: .functype store_test20 (i32, i32) -> (){{$}}
573 define void @store_test20(i32* %p, i32 %i) {
574 %arrayidx = getelementptr inbounds i32, i32* %p, i32 -10
575 store i32 %i, i32* %arrayidx, align 4
579 ; CHECK-LABEL: store_test21:
580 ; CHECK-NEXT: .functype store_test21 (i32, i32, i32) -> (){{$}}
581 define void @store_test21(i32* %p, i32 %n, i32 %i) {
582 %add = add nsw i32 %n, -10
583 %arrayidx = getelementptr inbounds i32, i32* %p, i32 %add
584 store i32 %i, i32* %arrayidx, align 4