1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=aarch64-linux-gnu -code-model=large -relocation-model=static -run-pass=instruction-select -verify-machineinstrs -O0 %s -o - | FileCheck %s --check-prefix=STATIC
3 # RUN: llc -mtriple=aarch64-linux-gnu -code-model=large -relocation-model=pic -run-pass=instruction-select -verify-machineinstrs -O0 %s -o - | FileCheck %s --check-prefix=PIC
5 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
7 @foo1 = common dso_local global [1073741824 x i32] zeroinitializer, align 4
8 @foo2 = common dso_local global [1073741824 x i32] zeroinitializer, align 4
10 define dso_local i32 @gv_large() {
12 %retval = alloca i32, align 4
13 store i32 0, ptr %retval, align 4
14 %0 = load i32, ptr @foo1, align 4
15 %1 = load i32, ptr @foo2, align 4
16 %add = add nsw i32 %0, %1
26 - { id: 0, name: retval, type: default, offset: 0, size: 4, alignment: 4,
27 stack-id: default, callee-saved-register: '', callee-saved-restored: true,
28 debug-info-variable: '', debug-info-expression: '',
29 debug-info-location: '' }
33 ; STATIC-LABEL: name: gv_large
34 ; STATIC: [[MOVZXi:%[0-9]+]]:gpr64 = MOVZXi target-flags(aarch64-g0, aarch64-nc) @foo1, 0
35 ; STATIC-NEXT: [[MOVKXi:%[0-9]+]]:gpr64 = MOVKXi [[MOVZXi]], target-flags(aarch64-g1, aarch64-nc) @foo1, 16
36 ; STATIC-NEXT: [[MOVKXi1:%[0-9]+]]:gpr64 = MOVKXi [[MOVKXi]], target-flags(aarch64-g2, aarch64-nc) @foo1, 32
37 ; STATIC-NEXT: [[MOVKXi2:%[0-9]+]]:gpr64 = MOVKXi [[MOVKXi1]], target-flags(aarch64-g3) @foo1, 48
38 ; STATIC-NEXT: [[COPY:%[0-9]+]]:gpr64sp = COPY [[MOVKXi2]]
39 ; STATIC-NEXT: [[MOVZXi1:%[0-9]+]]:gpr64 = MOVZXi target-flags(aarch64-g0, aarch64-nc) @foo2, 0
40 ; STATIC-NEXT: [[MOVKXi3:%[0-9]+]]:gpr64 = MOVKXi [[MOVZXi1]], target-flags(aarch64-g1, aarch64-nc) @foo2, 16
41 ; STATIC-NEXT: [[MOVKXi4:%[0-9]+]]:gpr64 = MOVKXi [[MOVKXi3]], target-flags(aarch64-g2, aarch64-nc) @foo2, 32
42 ; STATIC-NEXT: [[MOVKXi5:%[0-9]+]]:gpr64 = MOVKXi [[MOVKXi4]], target-flags(aarch64-g3) @foo2, 48
43 ; STATIC-NEXT: [[COPY1:%[0-9]+]]:gpr64sp = COPY [[MOVKXi5]]
44 ; STATIC-NEXT: STRWui $wzr, %stack.0.retval, 0 :: (store (s32) into %ir.retval)
45 ; STATIC-NEXT: [[LDRWui:%[0-9]+]]:gpr32 = LDRWui [[COPY]], 0 :: (load (s32) from @foo1)
46 ; STATIC-NEXT: [[LDRWui1:%[0-9]+]]:gpr32 = LDRWui [[COPY1]], 0 :: (load (s32) from @foo2)
47 ; STATIC-NEXT: [[ADDWrr:%[0-9]+]]:gpr32 = ADDWrr [[LDRWui]], [[LDRWui1]]
48 ; STATIC-NEXT: $w0 = COPY [[ADDWrr]]
49 ; STATIC-NEXT: RET_ReallyLR implicit $w0
51 ; PIC-LABEL: name: gv_large
52 ; PIC: [[MOVaddr:%[0-9]+]]:gpr64common = MOVaddr target-flags(aarch64-page) @foo1, target-flags(aarch64-pageoff, aarch64-nc) @foo1
53 ; PIC-NEXT: [[COPY:%[0-9]+]]:gpr64sp = COPY [[MOVaddr]]
54 ; PIC-NEXT: [[MOVaddr1:%[0-9]+]]:gpr64common = MOVaddr target-flags(aarch64-page) @foo2, target-flags(aarch64-pageoff, aarch64-nc) @foo2
55 ; PIC-NEXT: [[COPY1:%[0-9]+]]:gpr64sp = COPY [[MOVaddr1]]
56 ; PIC-NEXT: STRWui $wzr, %stack.0.retval, 0 :: (store (s32) into %ir.retval)
57 ; PIC-NEXT: [[LDRWui:%[0-9]+]]:gpr32 = LDRWui [[COPY]], 0 :: (load (s32) from @foo1)
58 ; PIC-NEXT: [[LDRWui1:%[0-9]+]]:gpr32 = LDRWui [[COPY1]], 0 :: (load (s32) from @foo2)
59 ; PIC-NEXT: [[ADDWrr:%[0-9]+]]:gpr32 = ADDWrr [[LDRWui]], [[LDRWui1]]
60 ; PIC-NEXT: $w0 = COPY [[ADDWrr]]
61 ; PIC-NEXT: RET_ReallyLR implicit $w0
62 %1:gpr(s32) = G_CONSTANT i32 0
63 %4:gpr(p0) = G_GLOBAL_VALUE @foo1
64 %3:gpr(p0) = COPY %4(p0)
65 %7:gpr(p0) = G_GLOBAL_VALUE @foo2
66 %6:gpr(p0) = COPY %7(p0)
67 %0:gpr(p0) = G_FRAME_INDEX %stack.0.retval
68 G_STORE %1(s32), %0(p0) :: (store (s32) into %ir.retval)
69 %2:gpr(s32) = G_LOAD %3(p0) :: (load (s32) from @foo1)
70 %5:gpr(s32) = G_LOAD %6(p0) :: (load (s32) from @foo2)
71 %8:gpr(s32) = G_ADD %2, %5
73 RET_ReallyLR implicit $w0