Home | History | Annotate | Download | only in AArch64
      1 ; RUN: llc < %s -mtriple=arm64-linux-gnu | FileCheck %s
      2 
      3 @x1 = external hidden global [2 x i64]
      4 @x2 = external hidden global [16777216 x i64]
      5 @x3 = external hidden global { [9 x i8*], [8 x i8*] }
      6 
      7 define i64 @f1() {
      8   ; CHECK: f1:
      9   ; CHECK: adrp x8, x1+16
     10   ; CHECK: ldr x0, [x8, :lo12:x1+16]
     11   %l = load i64, i64* getelementptr ([2 x i64], [2 x i64]* @x1, i64 0, i64 2)
     12   ret i64 %l
     13 }
     14 
     15 define i64 @f2() {
     16   ; CHECK: f2:
     17   ; CHECK: adrp x8, x1
     18   ; CHECK: add x8, x8, :lo12:x1
     19   ; CHECK: ldr x0, [x8, #24]
     20   %l = load i64, i64* getelementptr ([2 x i64], [2 x i64]* @x1, i64 0, i64 3)
     21   ret i64 %l
     22 }
     23 
     24 define i64 @f3() {
     25   ; CHECK: f3:
     26   ; CHECK: adrp x8, x1+1
     27   ; CHECK: add x8, x8, :lo12:x1+1
     28   ; CHECK: ldr x0, [x8]
     29   %l = load i64, i64* bitcast (i8* getelementptr (i8, i8* bitcast ([2 x i64]* @x1 to i8*), i64 1) to i64*)
     30   ret i64 %l
     31 }
     32 
     33 define [2 x i64] @f4() {
     34   ; CHECK: f4:
     35   ; CHECK: adrp x8, x2+8
     36   ; CHECK: add x8, x8, :lo12:x2+8
     37   ; CHECK: ldp x0, x1, [x8]
     38   %l = load [2 x i64], [2 x i64]* bitcast (i8* getelementptr (i8, i8* bitcast ([16777216 x i64]* @x2 to i8*), i64 8) to [2 x i64]*)
     39   ret [2 x i64] %l
     40 }
     41 
     42 define i64 @f5() {
     43   ; CHECK: f5:
     44   ; CHECK: adrp x8, x2+2097144
     45   ; CHECK: ldr x0, [x8, :lo12:x2+2097144]
     46   ; CHECK: ret
     47   %l = load i64, i64* getelementptr ([16777216 x i64], [16777216 x i64]* @x2, i64 0, i64 262143)
     48   ret i64 %l
     49 }
     50 
     51 define i64 @f6() {
     52   ; CHECK: f6:
     53   ; CHECK: adrp x8, x2
     54   ; CHECK: add x8, x8, :lo12:x2
     55   ; CHECK: orr w9, wzr, #0x200000
     56   ; CHECK: ldr x0, [x8, x9]
     57   ; CHECK: ret
     58   %l = load i64, i64* getelementptr ([16777216 x i64], [16777216 x i64]* @x2, i64 0, i64 262144)
     59   ret i64 %l
     60 }
     61 
     62 define i32 @f7() {
     63 entry:
     64   ; CHECK: f7
     65   ; CHECK: adrp x8, x3+108
     66   ; CHECK: ldr w0, [x8, :lo12:x3+108]
     67   %l = load i32, i32* getelementptr (i32, i32* inttoptr (i64 trunc (i128 lshr (i128 bitcast (<2 x i64> <i64 undef, i64 ptrtoint (i8** getelementptr inbounds ({ [9 x i8*], [8 x i8*] }, { [9 x i8*], [8 x i8*] }* @x3, i64 0, inrange i32 1, i64 2) to i64)> to i128), i128 64) to i64) to i32*), i64 5)
     68   ret i32 %l
     69 }
     70