1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -O0 -global-isel -stop-after=irtranslator -o - %s | FileCheck %s
4 %type = type [4 x {i8, i32}]
6 define %type* @first_offset_const(%type* %addr) {
8 ; CHECK-LABEL: name: first_offset_const
9 ; CHECK: bb.1 (%ir-block.0):
11 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
12 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
13 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[C]](s64)
14 ; CHECK: %x0 = COPY [[GEP]](p0)
15 ; CHECK: RET_ReallyLR implicit %x0
16 %res = getelementptr %type, %type* %addr, i32 1
20 define %type* @first_offset_trivial(%type* %addr) {
22 ; CHECK-LABEL: name: first_offset_trivial
23 ; CHECK: bb.1 (%ir-block.0):
25 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
26 ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY [[COPY]](p0)
27 ; CHECK: %x0 = COPY [[COPY1]](p0)
28 ; CHECK: RET_ReallyLR implicit %x0
29 %res = getelementptr %type, %type* %addr, i32 0
33 define %type* @first_offset_variable(%type* %addr, i64 %idx) {
35 ; CHECK-LABEL: name: first_offset_variable
36 ; CHECK: bb.1 (%ir-block.0):
37 ; CHECK: liveins: %x0, %x1
38 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
39 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY %x1
40 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
41 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[COPY1]]
42 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
43 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP]](p0)
44 ; CHECK: %x0 = COPY [[COPY2]](p0)
45 ; CHECK: RET_ReallyLR implicit %x0
46 %res = getelementptr %type, %type* %addr, i64 %idx
50 define %type* @first_offset_ext(%type* %addr, i32 %idx) {
52 ; CHECK-LABEL: name: first_offset_ext
53 ; CHECK: bb.1 (%ir-block.0):
54 ; CHECK: liveins: %w1, %x0
55 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
56 ; CHECK: [[COPY1:%[0-9]+]]:_(s32) = COPY %w1
57 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 32
58 ; CHECK: [[SEXT:%[0-9]+]]:_(s64) = G_SEXT [[COPY1]](s32)
59 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[SEXT]]
60 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
61 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP]](p0)
62 ; CHECK: %x0 = COPY [[COPY2]](p0)
63 ; CHECK: RET_ReallyLR implicit %x0
64 %res = getelementptr %type, %type* %addr, i32 %idx
68 %type1 = type [4 x [4 x i32]]
69 define i32* @const_then_var(%type1* %addr, i64 %idx) {
71 ; CHECK-LABEL: name: const_then_var
72 ; CHECK: bb.1 (%ir-block.0):
73 ; CHECK: liveins: %x0, %x1
74 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
75 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY %x1
76 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 272
77 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4
78 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[C]](s64)
79 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C1]], [[COPY1]]
80 ; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_GEP [[GEP]], [[MUL]](s64)
81 ; CHECK: [[COPY2:%[0-9]+]]:_(p0) = COPY [[GEP1]](p0)
82 ; CHECK: %x0 = COPY [[COPY2]](p0)
83 ; CHECK: RET_ReallyLR implicit %x0
84 %res = getelementptr %type1, %type1* %addr, i32 4, i32 1, i64 %idx
88 define i32* @var_then_const(%type1* %addr, i64 %idx) {
90 ; CHECK-LABEL: name: var_then_const
91 ; CHECK: bb.1 (%ir-block.0):
92 ; CHECK: liveins: %x0, %x1
93 ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY %x0
94 ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY %x1
95 ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 64
96 ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 40
97 ; CHECK: [[MUL:%[0-9]+]]:_(s64) = G_MUL [[C]], [[COPY1]]
98 ; CHECK: [[GEP:%[0-9]+]]:_(p0) = G_GEP [[COPY]], [[MUL]](s64)
99 ; CHECK: [[GEP1:%[0-9]+]]:_(p0) = G_GEP [[GEP]], [[C1]](s64)
100 ; CHECK: %x0 = COPY [[GEP1]](p0)
101 ; CHECK: RET_ReallyLR implicit %x0
102 %res = getelementptr %type1, %type1* %addr, i64 %idx, i32 2, i32 2