1 ; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s
3 ; Test that constant offsets can be folded into global addresses.
5 target triple = "wasm32-unknown-unknown"
7 @x = external dso_local global [0 x i32]
8 @y = dso_local global [50 x i32] zeroinitializer
10 ; Test basic constant offsets of both defined and external symbols.
13 ; CHECK-NEXT: .functype test0 () -> (i32){{$}}
14 ; CHECK-NEXT: i32.const $push0=, x+188{{$}}
15 ; CHECK=NEXT: return $pop0{{$}}
16 define dso_local ptr @test0() {
17 ret ptr getelementptr ([0 x i32], ptr @x, i32 0, i32 47)
21 ; CHECK-NEXT: .functype test1 () -> (i32){{$}}
22 ; CHECK-NEXT: i32.const $push0=, y+188{{$}}
23 ; CHECK=NEXT: return $pop0{{$}}
24 define dso_local ptr @test1() {
25 ret ptr getelementptr ([50 x i32], ptr @y, i32 0, i32 47)
31 ; CHECK-NEXT: .functype test2 () -> (i32){{$}}
32 ; CHECK-NEXT: i32.const $push0=, x{{$}}
33 ; CHECK=NEXT: return $pop0{{$}}
34 define dso_local ptr @test2() {
39 ; CHECK-NEXT: .functype test3 () -> (i32){{$}}
40 ; CHECK-NEXT: i32.const $push0=, y{{$}}
41 ; CHECK=NEXT: return $pop0{{$}}
42 define dso_local ptr @test3() {
46 ; Test negative offsets.
49 ; CHECK-NEXT: .functype test4 () -> (i32){{$}}
50 ; CHECK-NEXT: i32.const $push0=, x-188{{$}}
51 ; CHECK=NEXT: return $pop0{{$}}
52 define dso_local ptr @test4() {
53 ret ptr getelementptr ([0 x i32], ptr @x, i32 0, i32 -47)
57 ; CHECK-NEXT: .functype test5 () -> (i32){{$}}
58 ; CHECK-NEXT: i32.const $push0=, y-188{{$}}
59 ; CHECK=NEXT: return $pop0{{$}}
60 define dso_local ptr @test5() {
61 ret ptr getelementptr ([50 x i32], ptr @y, i32 0, i32 -47)