1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2# RUN: llc -mtriple=aarch64-linux-gnu -code-model=large -run-pass=instruction-select -verify-machineinstrs -O0 %s -o - | FileCheck %s
3--- |
4  target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5
6  @foo1 = common global [1073741824 x i32] zeroinitializer, align 4
7  @foo2 = common global [1073741824 x i32] zeroinitializer, align 4
8
9  define i32 @gv_large() {
10  entry:
11    %retval = alloca i32, align 4
12    store i32 0, i32* %retval, align 4
13    %0 = load i32, i32* getelementptr inbounds ([1073741824 x i32], [1073741824 x i32]* @foo1, i64 0, i64 0), align 4
14    %1 = load i32, i32* getelementptr inbounds ([1073741824 x i32], [1073741824 x i32]* @foo2, i64 0, i64 0), align 4
15    %add = add nsw i32 %0, %1
16    ret i32 %add
17  }
18
19...
20---
21name:            gv_large
22legalized:       true
23regBankSelected: true
24stack:
25  - { id: 0, name: retval, type: default, offset: 0, size: 4, alignment: 4,
26      stack-id: 0, callee-saved-register: '', callee-saved-restored: true,
27      debug-info-variable: '', debug-info-expression: '',
28      debug-info-location: '' }
29constants:
30body:             |
31  bb.1:
32    ; CHECK-LABEL: name: gv_large
33    ; CHECK: [[MOVZXi:%[0-9]+]]:gpr64 = MOVZXi target-flags(aarch64-g0, aarch64-nc) @foo1, 0
34    ; CHECK: [[MOVKXi:%[0-9]+]]:gpr64 = MOVKXi [[MOVZXi]], target-flags(aarch64-g1, aarch64-nc) @foo1, 16
35    ; CHECK: [[MOVKXi1:%[0-9]+]]:gpr64 = MOVKXi [[MOVKXi]], target-flags(aarch64-g2, aarch64-nc) @foo1, 32
36    ; CHECK: [[MOVKXi2:%[0-9]+]]:gpr64 = MOVKXi [[MOVKXi1]], target-flags(aarch64-g3) @foo1, 48
37    ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY [[MOVKXi2]]
38    ; CHECK: [[MOVZXi1:%[0-9]+]]:gpr64 = MOVZXi target-flags(aarch64-g0, aarch64-nc) @foo2, 0
39    ; CHECK: [[MOVKXi3:%[0-9]+]]:gpr64 = MOVKXi [[MOVZXi1]], target-flags(aarch64-g1, aarch64-nc) @foo2, 16
40    ; CHECK: [[MOVKXi4:%[0-9]+]]:gpr64 = MOVKXi [[MOVKXi3]], target-flags(aarch64-g2, aarch64-nc) @foo2, 32
41    ; CHECK: [[MOVKXi5:%[0-9]+]]:gpr64 = MOVKXi [[MOVKXi4]], target-flags(aarch64-g3) @foo2, 48
42    ; CHECK: [[COPY1:%[0-9]+]]:gpr64sp = COPY [[MOVKXi5]]
43    ; CHECK: STRWui $wzr, %stack.0.retval, 0 :: (store 4 into %ir.retval)
44    ; CHECK: [[LDRWui:%[0-9]+]]:gpr32 = LDRWui [[COPY]], 0 :: (load 4 from `i32* getelementptr inbounds ([1073741824 x i32], [1073741824 x i32]* @foo1, i64 0, i64 0)`)
45    ; CHECK: [[LDRWui1:%[0-9]+]]:gpr32 = LDRWui [[COPY1]], 0 :: (load 4 from `i32* getelementptr inbounds ([1073741824 x i32], [1073741824 x i32]* @foo2, i64 0, i64 0)`)
46    ; CHECK: [[ADDWrr:%[0-9]+]]:gpr32 = ADDWrr [[LDRWui]], [[LDRWui1]]
47    ; CHECK: $w0 = COPY [[ADDWrr]]
48    ; CHECK: RET_ReallyLR implicit $w0
49    %1:gpr(s32) = G_CONSTANT i32 0
50    %4:gpr(p0) = G_GLOBAL_VALUE @foo1
51    %3:gpr(p0) = COPY %4(p0)
52    %7:gpr(p0) = G_GLOBAL_VALUE @foo2
53    %6:gpr(p0) = COPY %7(p0)
54    %0:gpr(p0) = G_FRAME_INDEX %stack.0.retval
55    G_STORE %1(s32), %0(p0) :: (store 4 into %ir.retval)
56    %2:gpr(s32) = G_LOAD %3(p0) :: (load 4 from `i32* getelementptr inbounds ([1073741824 x i32], [1073741824 x i32]* @foo1, i64 0, i64 0)`)
57    %5:gpr(s32) = G_LOAD %6(p0) :: (load 4 from `i32* getelementptr inbounds ([1073741824 x i32], [1073741824 x i32]* @foo2, i64 0, i64 0)`)
58    %8:gpr(s32) = G_ADD %2, %5
59    $w0 = COPY %8(s32)
60    RET_ReallyLR implicit $w0
61
62...
63