xref: /llvm-project/llvm/test/CodeGen/AArch64/fast-isel-gep.ll (revision db158c7c830807caeeb0691739c41f1d522029e9)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=aarch64-apple-darwin -fast-isel -fast-isel-abort=1 -verify-machineinstrs < %s | FileCheck %s
3
4%struct.foo = type { i32, i64, float, double }
5
6define ptr @test_struct(ptr %f) {
7; CHECK-LABEL: test_struct:
8; CHECK:       ; %bb.0:
9; CHECK-NEXT:    add x0, x0, #24
10; CHECK-NEXT:    ret
11  %1 = getelementptr inbounds %struct.foo, ptr %f, i64 0, i32 3
12  ret ptr %1
13}
14
15define ptr @test_array1(ptr %a, i64 %i) {
16; CHECK-LABEL: test_array1:
17; CHECK:       ; %bb.0:
18; CHECK-NEXT:    mov x8, #4 ; =0x4
19; CHECK-NEXT:    madd x0, x1, x8, x0
20; CHECK-NEXT:    ret
21  %1 = getelementptr inbounds i32, ptr %a, i64 %i
22  ret ptr %1
23}
24
25define ptr @test_array2(ptr %a) {
26; CHECK-LABEL: test_array2:
27; CHECK:       ; %bb.0:
28; CHECK-NEXT:    add x0, x0, #16
29; CHECK-NEXT:    ret
30  %1 = getelementptr inbounds i32, ptr %a, i64 4
31  ret ptr %1
32}
33
34define ptr @test_array3(ptr %a) {
35; CHECK-LABEL: test_array3:
36; CHECK:       ; %bb.0:
37; CHECK-NEXT:    add x0, x0, #1, lsl #12 ; =4096
38; CHECK-NEXT:    ret
39  %1 = getelementptr inbounds i32, ptr %a, i64 1024
40  ret ptr %1
41}
42
43define ptr @test_array4(ptr %a) {
44; CHECK-LABEL: test_array4:
45; CHECK:       ; %bb.0:
46; CHECK-NEXT:    mov x8, #4104 ; =0x1008
47; CHECK-NEXT:    add x0, x0, x8
48; CHECK-NEXT:    ret
49  %1 = getelementptr inbounds i32, ptr %a, i64 1026
50  ret ptr %1
51}
52
53define ptr @test_array5(ptr %a, i32 %i) {
54; CHECK-LABEL: test_array5:
55; CHECK:       ; %bb.0:
56; CHECK-NEXT:    ; kill: def $w1 killed $w1 def $x1
57; CHECK-NEXT:    sxtw x8, w1
58; CHECK-NEXT:    mov x9, #4 ; =0x4
59; CHECK-NEXT:    madd x0, x8, x9, x0
60; CHECK-NEXT:    ret
61  %1 = getelementptr inbounds i32, ptr %a, i32 %i
62  ret ptr %1
63}
64