1 ; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -o - %s | FileCheck %s
3 @var32 = dso_local global [3 x i32] zeroinitializer
4 @var64 = dso_local global [3 x i64] zeroinitializer
5 @var32_align64 = dso_local global [3 x i32] zeroinitializer, align 8
6 @alias = dso_local alias [3 x i32], ptr @var32_align64
8 define dso_local i64 @test_align32() {
9 ; CHECK-LABEL: test_align32:
11 ; Since @var32 is only guaranteed to be aligned to 32-bits, it's invalid to
12 ; emit an "LDR x0, [x0, #:lo12:var32] instruction to implement this load.
13 %val = load i64, ptr @var32
14 ; CHECK: adrp [[HIBITS:x[0-9]+]], var32
15 ; CHECK: add x[[ADDR:[0-9]+]], [[HIBITS]], {{#?}}:lo12:var32
16 ; CHECK: ldr x0, [x[[ADDR]]]
21 define dso_local i64 @test_align64() {
22 ; CHECK-LABEL: test_align64:
24 ; However, var64 *is* properly aligned and emitting an adrp/add/ldr would be
26 %val = load i64, ptr @var64
27 ; CHECK: adrp x[[HIBITS:[0-9]+]], var64
28 ; CHECK-NOT: add x[[HIBITS]]
29 ; CHECK: ldr x0, [x[[HIBITS]], {{#?}}:lo12:var64]
34 define dso_local i64 @test_var32_align64() {
35 ; CHECK-LABEL: test_var32_align64:
37 ; Since @var32 is only guaranteed to be aligned to 32-bits, it's invalid to
38 ; emit an "LDR x0, [x0, #:lo12:var32] instruction to implement this load.
39 %val = load i64, ptr @var32_align64
40 ; CHECK: adrp x[[HIBITS:[0-9]+]], var32_align64
41 ; CHECK-NOT: add x[[HIBITS]]
42 ; CHECK: ldr x0, [x[[HIBITS]], {{#?}}:lo12:var32_align64]
47 define dso_local i64 @test_var32_alias() {
48 ; CHECK-LABEL: test_var32_alias:
50 ; We don't know anything about the alignment of aliases.
51 %val = load i64, ptr @alias
52 ; CHECK: adrp x[[HIBITS:[0-9]+]], alias
53 ; CHECK: add x[[ADDR:[0-9]+]], x[[HIBITS]], {{#?}}:lo12:alias
54 ; CHECK: ldr x0, [x[[ADDR]]]
59 @yet_another_var = external dso_local global {i32, i32}
61 define dso_local i64 @test_yet_another_var() {
62 ; CHECK-LABEL: test_yet_another_var:
64 ; @yet_another_var has a preferred alignment of 8, but that's not enough if
65 ; we're going to be linking against other things. Its ABI alignment is only 4
66 ; so we can't fold the load.
67 %val = load i64, ptr @yet_another_var
68 ; CHECK: adrp [[HIBITS:x[0-9]+]], yet_another_var
69 ; CHECK: add x[[ADDR:[0-9]+]], [[HIBITS]], {{#?}}:lo12:yet_another_var
70 ; CHECK: ldr x0, [x[[ADDR]]]
74 define dso_local ptr @test_functions() {
75 ; CHECK-LABEL: test_functions:
76 ret ptr @test_yet_another_var
77 ; CHECK: adrp [[HIBITS:x[0-9]+]], test_yet_another_var
78 ; CHECK: add x0, [[HIBITS]], {{#?}}:lo12:test_yet_another_var