[LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)
[llvm-project.git] / llvm / test / CodeGen / AArch64 / tagged-globals-pic.ll
blob3c4274abdd5636046eb7b8140a413a0f99fe6754
1 ; RUN: llc --relocation-model=pic < %s \
2 ; RUN:   | FileCheck %s --check-prefix=CHECK-PIC
4 ; Ensure that GlobalISel lowers correctly. GlobalISel is the default ISel for
5 ; -O0 on aarch64. GlobalISel lowers the instruction sequence in the static
6 ; relocation model different to SelectionDAGISel. GlobalISel does the lowering
7 ; of AddLow *after* legalization, and thus doesn't differentiate between
8 ; address-taken-only vs. address-taken-for-loadstore. Hence, we generate a movk
9 ; instruction for load/store instructions as well with GlobalISel. GlobalISel
10 ; also doesn't have the scaffolding to correctly check the bounds of the global
11 ; offset, and cannot fold the lo12 bits into the load/store. Neither of these
12 ; things are a problem as GlobalISel is only used by default at -O0, so we don't
13 ; mind the code size and performance increase.
15 ; RUN: llc --aarch64-enable-global-isel-at-O=0 -O0 --relocation-model=pic < %s \
16 ; RUN:   | FileCheck %s --check-prefix=CHECK-PIC
18 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
19 target triple = "aarch64-unknown-linux-android"
21 @global = external global i32
22 declare void @func()
24 define ptr @global_addr() #0 {
25   ; CHECK-PIC: global_addr:
26   ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:global
27   ; CHECK-PIC: ldr x0, [[[REG]], :got_lo12:global]
28   ; CHECK-PIC: ret
30   ret ptr @global
33 define i32 @global_load() #0 {
34   ; CHECK-PIC: global_load:
35   ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:global
36   ; CHECK-PIC: ldr  [[REG]], [[[REG]], :got_lo12:global]
37   ; CHECK-PIC: ldr w0, [[[REG]]]
38   ; CHECK-PIC: ret
40   %load = load i32, ptr @global
41   ret i32 %load
44 define void @global_store() #0 {
45   ; CHECK-PIC: global_store:
46   ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:global
47   ; CHECK-PIC: ldr  [[REG]], [[[REG]], :got_lo12:global]
48   ; CHECK-PIC: str wzr, [[[REG]]]
49   ; CHECK-PIC: ret
51   store i32 0, ptr @global
52   ret void
55 define ptr @func_addr() #0 {
56   ; CHECK-PIC: func_addr:
57   ; CHECK-PIC: adrp [[REG:x[0-9]+]], :got:func
58   ; CHECK-PIC: ldr  x0, [[[REG]], :got_lo12:func]
59   ; CHECK-PIC: ret
61   ret ptr @func
64 attributes #0 = { "target-features"="+tagged-globals" }