1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
4 define ptr @scalar_of_scalable_1(ptr %base) {
5 ; CHECK-LABEL: scalar_of_scalable_1:
7 ; CHECK-NEXT: rdvl x8, #4
8 ; CHECK-NEXT: add x0, x0, x8
10 %d = getelementptr <vscale x 2 x i64>, ptr %base, i64 4
14 define ptr @scalar_of_scalable_2(ptr %base, i64 %offset) {
15 ; CHECK-LABEL: scalar_of_scalable_2:
17 ; CHECK-NEXT: rdvl x8, #1
18 ; CHECK-NEXT: madd x0, x1, x8, x0
20 %d = getelementptr <vscale x 2 x i64>, ptr %base, i64 %offset
24 define ptr @scalar_of_scalable_3(ptr %base, i64 %offset) {
25 ; CHECK-LABEL: scalar_of_scalable_3:
28 ; CHECK-NEXT: madd x0, x1, x8, x0
30 %d = getelementptr <vscale x 2 x i32>, ptr %base, i64 %offset
34 define <2 x ptr> @fixed_of_scalable_1(ptr %base) {
35 ; CHECK-LABEL: fixed_of_scalable_1:
37 ; CHECK-NEXT: rdvl x8, #1
38 ; CHECK-NEXT: dup v1.2d, x0
39 ; CHECK-NEXT: dup v0.2d, x8
40 ; CHECK-NEXT: add v0.2d, v1.2d, v0.2d
42 %d = getelementptr <vscale x 2 x i64>, ptr %base, <2 x i64> <i64 1, i64 1>
46 define <2 x ptr> @fixed_of_scalable_2(<2 x ptr> %base) {
47 ; CHECK-LABEL: fixed_of_scalable_2:
49 ; CHECK-NEXT: rdvl x8, #1
50 ; CHECK-NEXT: dup v1.2d, x8
51 ; CHECK-NEXT: add v0.2d, v0.2d, v1.2d
53 %d = getelementptr <vscale x 2 x i64>, <2 x ptr> %base, <2 x i64> <i64 1, i64 1>
57 define <vscale x 2 x ptr> @scalable_of_fixed_1(ptr %base) {
58 ; CHECK-LABEL: scalable_of_fixed_1:
60 ; CHECK-NEXT: add x8, x0, #1
61 ; CHECK-NEXT: mov z0.d, x8
63 %idx = shufflevector <vscale x 2 x i64> insertelement (<vscale x 2 x i64> undef, i64 1, i32 0), <vscale x 2 x i64> zeroinitializer, <vscale x 2 x i32> zeroinitializer
64 %d = getelementptr i8, ptr %base, <vscale x 2 x i64> %idx
65 ret <vscale x 2 x ptr> %d
68 define <vscale x 2 x ptr> @scalable_of_fixed_2(<vscale x 2 x ptr> %base) {
69 ; CHECK-LABEL: scalable_of_fixed_2:
71 ; CHECK-NEXT: add z0.d, z0.d, #1 // =0x1
73 %idx = shufflevector <vscale x 2 x i64> insertelement (<vscale x 2 x i64> undef, i64 1, i32 0), <vscale x 2 x i64> zeroinitializer, <vscale x 2 x i32> zeroinitializer
74 %d = getelementptr i8, <vscale x 2 x ptr> %base, <vscale x 2 x i64> %idx
75 ret <vscale x 2 x ptr> %d
78 define <vscale x 2 x ptr> @scalable_of_fixed_3_i8(ptr %base, <vscale x 2 x i64> %idx) {
79 ; CHECK-LABEL: scalable_of_fixed_3_i8:
81 ; CHECK-NEXT: mov z1.d, x0
82 ; CHECK-NEXT: add z0.d, z1.d, z0.d
84 %d = getelementptr i8, ptr %base, <vscale x 2 x i64> %idx
85 ret <vscale x 2 x ptr> %d
88 define <vscale x 2 x ptr> @scalable_of_fixed_3_i16(ptr %base, <vscale x 2 x i64> %idx) {
89 ; CHECK-LABEL: scalable_of_fixed_3_i16:
91 ; CHECK-NEXT: mov z1.d, x0
92 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, lsl #1]
94 %d = getelementptr i16, ptr %base, <vscale x 2 x i64> %idx
95 ret <vscale x 2 x ptr> %d
98 define <vscale x 2 x ptr> @scalable_of_fixed_3_i32(ptr %base, <vscale x 2 x i64> %idx) {
99 ; CHECK-LABEL: scalable_of_fixed_3_i32:
101 ; CHECK-NEXT: mov z1.d, x0
102 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, lsl #2]
104 %d = getelementptr i32, ptr %base, <vscale x 2 x i64> %idx
105 ret <vscale x 2 x ptr> %d
108 define <vscale x 2 x ptr> @scalable_of_fixed_3_i64(ptr %base, <vscale x 2 x i64> %idx) {
109 ; CHECK-LABEL: scalable_of_fixed_3_i64:
111 ; CHECK-NEXT: mov z1.d, x0
112 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, lsl #3]
114 %d = getelementptr i64, ptr %base, <vscale x 2 x i64> %idx
115 ret <vscale x 2 x ptr> %d
118 define <vscale x 2 x ptr> @scalable_of_fixed_4_i8(ptr %base, <vscale x 2 x i32> %idx) {
119 ; CHECK-LABEL: scalable_of_fixed_4_i8:
121 ; CHECK-NEXT: mov z1.d, x0
122 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, sxtw]
124 %d = getelementptr i8, ptr %base, <vscale x 2 x i32> %idx
125 ret <vscale x 2 x ptr> %d
128 define <vscale x 2 x ptr> @scalable_of_fixed_4_i16(ptr %base, <vscale x 2 x i32> %idx) {
129 ; CHECK-LABEL: scalable_of_fixed_4_i16:
131 ; CHECK-NEXT: mov z1.d, x0
132 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, sxtw #1]
134 %d = getelementptr i16, ptr %base, <vscale x 2 x i32> %idx
135 ret <vscale x 2 x ptr> %d
138 define <vscale x 2 x ptr> @scalable_of_fixed_4_i32(ptr %base, <vscale x 2 x i32> %idx) {
139 ; CHECK-LABEL: scalable_of_fixed_4_i32:
141 ; CHECK-NEXT: mov z1.d, x0
142 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, sxtw #2]
144 %d = getelementptr i32, ptr %base, <vscale x 2 x i32> %idx
145 ret <vscale x 2 x ptr> %d
148 define <vscale x 2 x ptr> @scalable_of_fixed_4_i64(ptr %base, <vscale x 2 x i32> %idx) {
149 ; CHECK-LABEL: scalable_of_fixed_4_i64:
151 ; CHECK-NEXT: mov z1.d, x0
152 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, sxtw #3]
154 %d = getelementptr i64, ptr %base, <vscale x 2 x i32> %idx
155 ret <vscale x 2 x ptr> %d
158 define <vscale x 2 x ptr> @scalable_of_fixed_5(ptr %base, <vscale x 2 x i32> %idx) {
159 ; CHECK-LABEL: scalable_of_fixed_5:
161 ; CHECK-NEXT: mov z1.d, x0
162 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, uxtw]
164 %idxZext = zext <vscale x 2 x i32> %idx to <vscale x 2 x i64>
165 %d = getelementptr i8, ptr %base, <vscale x 2 x i64> %idxZext
166 ret <vscale x 2 x ptr> %d
169 define <vscale x 2 x ptr> @scalable_of_fixed_5_i16(ptr %base, <vscale x 2 x i32> %idx) {
170 ; CHECK-LABEL: scalable_of_fixed_5_i16:
172 ; CHECK-NEXT: mov z1.d, x0
173 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, uxtw #1]
175 %idxZext = zext <vscale x 2 x i32> %idx to <vscale x 2 x i64>
176 %d = getelementptr i16, ptr %base, <vscale x 2 x i64> %idxZext
177 ret <vscale x 2 x ptr> %d
180 define <vscale x 2 x ptr> @scalable_of_fixed_5_i32(ptr %base, <vscale x 2 x i32> %idx) {
181 ; CHECK-LABEL: scalable_of_fixed_5_i32:
183 ; CHECK-NEXT: mov z1.d, x0
184 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, uxtw #2]
186 %idxZext = zext <vscale x 2 x i32> %idx to <vscale x 2 x i64>
187 %d = getelementptr i32, ptr %base, <vscale x 2 x i64> %idxZext
188 ret <vscale x 2 x ptr> %d
192 define <vscale x 2 x ptr> @scalable_of_fixed_5_i64(ptr %base, <vscale x 2 x i32> %idx) {
193 ; CHECK-LABEL: scalable_of_fixed_5_i64:
195 ; CHECK-NEXT: mov z1.d, x0
196 ; CHECK-NEXT: adr z0.d, [z1.d, z0.d, uxtw #3]
198 %idxZext = zext <vscale x 2 x i32> %idx to <vscale x 2 x i64>
199 %d = getelementptr i64, ptr %base, <vscale x 2 x i64> %idxZext
200 ret <vscale x 2 x ptr> %d
203 define <vscale x 2 x ptr> @scalable_of_scalable_1(ptr %base) {
204 ; CHECK-LABEL: scalable_of_scalable_1:
206 ; CHECK-NEXT: rdvl x8, #1
207 ; CHECK-NEXT: add x8, x0, x8
208 ; CHECK-NEXT: mov z0.d, x8
210 %idx = shufflevector <vscale x 2 x i64> insertelement (<vscale x 2 x i64> undef, i64 1, i32 0), <vscale x 2 x i64> zeroinitializer, <vscale x 2 x i32> zeroinitializer
211 %d = getelementptr <vscale x 2 x i64>, ptr %base, <vscale x 2 x i64> %idx
212 ret <vscale x 2 x ptr> %d
215 define <vscale x 2 x ptr> @scalable_of_scalable_2(<vscale x 2 x ptr> %base) {
216 ; CHECK-LABEL: scalable_of_scalable_2:
218 ; CHECK-NEXT: incd z0.d, all, mul #8
220 %idx = shufflevector <vscale x 2 x i64> insertelement (<vscale x 2 x i64> undef, i64 1, i32 0), <vscale x 2 x i64> zeroinitializer, <vscale x 2 x i32> zeroinitializer
221 %d = getelementptr <vscale x 2 x i64>, <vscale x 2 x ptr> %base, <vscale x 2 x i64> %idx
222 ret <vscale x 2 x ptr> %d
225 define <vscale x 2 x ptr> @scalable_of_scalable_3(<vscale x 2 x ptr> %base, <vscale x 2 x i32> %idx) {
226 ; CHECK-LABEL: scalable_of_scalable_3:
228 ; CHECK-NEXT: ptrue p0.d
229 ; CHECK-NEXT: rdvl x8, #1
230 ; CHECK-NEXT: mov z2.d, x8
231 ; CHECK-NEXT: sxtw z1.d, p0/m, z1.d
232 ; CHECK-NEXT: mla z0.d, p0/m, z1.d, z2.d
234 %d = getelementptr <vscale x 2 x i64>, <vscale x 2 x ptr> %base, <vscale x 2 x i32> %idx
235 ret <vscale x 2 x ptr> %d