xref: /aosp_15_r20/external/llvm/test/CodeGen/AArch64/fast-isel-gep.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=aarch64-apple-darwin -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker%struct.foo = type { i32, i64, float, double }
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdefine double* @test_struct(%struct.foo* %f) {
6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_struct
7*9880d681SAndroid Build Coastguard Worker; CHECK:       add x0, x0, #24
8*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds %struct.foo, %struct.foo* %f, i64 0, i32 3
9*9880d681SAndroid Build Coastguard Worker  ret double* %1
10*9880d681SAndroid Build Coastguard Worker}
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine i32* @test_array1(i32* %a, i64 %i) {
13*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_array1
14*9880d681SAndroid Build Coastguard Worker; CHECK:       orr [[REG:x[0-9]+]], xzr, #0x4
15*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  madd  x0, x1, [[REG]], x0
16*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds i32, i32* %a, i64 %i
17*9880d681SAndroid Build Coastguard Worker  ret i32* %1
18*9880d681SAndroid Build Coastguard Worker}
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerdefine i32* @test_array2(i32* %a) {
21*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_array2
22*9880d681SAndroid Build Coastguard Worker; CHECK:       add  x0, x0, #16
23*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds i32, i32* %a, i64 4
24*9880d681SAndroid Build Coastguard Worker  ret i32* %1
25*9880d681SAndroid Build Coastguard Worker}
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerdefine i32* @test_array3(i32* %a) {
28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_array3
29*9880d681SAndroid Build Coastguard Worker; CHECK:       add x0, x0, #1, lsl #12
30*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds i32, i32* %a, i64 1024
31*9880d681SAndroid Build Coastguard Worker  ret i32* %1
32*9880d681SAndroid Build Coastguard Worker}
33*9880d681SAndroid Build Coastguard Worker
34*9880d681SAndroid Build Coastguard Workerdefine i32* @test_array4(i32* %a) {
35*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_array4
36*9880d681SAndroid Build Coastguard Worker; CHECK:       mov [[REG:x[0-9]+]], #4104
37*9880d681SAndroid Build Coastguard Worker; CHECK-NEXR:  add x0, x0, [[REG]]
38*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds i32, i32* %a, i64 1026
39*9880d681SAndroid Build Coastguard Worker  ret i32* %1
40*9880d681SAndroid Build Coastguard Worker}
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerdefine i32* @test_array5(i32* %a, i32 %i) {
43*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_array5
44*9880d681SAndroid Build Coastguard Worker; CHECK:       sxtw [[REG1:x[0-9]+]], w1
45*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  orr  [[REG2:x[0-9]+]], xzr, #0x4
46*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:  madd  {{x[0-9]+}}, [[REG1]], [[REG2]], x0
47*9880d681SAndroid Build Coastguard Worker  %1 = getelementptr inbounds i32, i32* %a, i32 %i
48*9880d681SAndroid Build Coastguard Worker  ret i32* %1
49*9880d681SAndroid Build Coastguard Worker}
50