1 ; Test vector extraction to memory.
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
5 ; Test v16i8 extraction from the first element.
6 define void @f1(<16 x i8> %val, ptr %ptr) {
8 ; CHECK: vsteb %v24, 0(%r2), 0
10 %element = extractelement <16 x i8> %val, i32 0
11 store i8 %element, ptr %ptr
15 ; Test v16i8 extraction from the last element.
16 define void @f2(<16 x i8> %val, ptr %ptr) {
18 ; CHECK: vsteb %v24, 0(%r2), 15
20 %element = extractelement <16 x i8> %val, i32 15
21 store i8 %element, ptr %ptr
25 ; Test v16i8 extraction of an invalid element. This must compile,
26 ; but we don't care what it does.
27 define void @f3(<16 x i8> %val, ptr %ptr) {
29 ; CHECK-NOT: vsteb %v24, 0(%r2), 16
31 %element = extractelement <16 x i8> %val, i32 16
32 store i8 %element, ptr %ptr
36 ; Test v16i8 extraction with the highest in-range offset.
37 define void @f4(<16 x i8> %val, ptr %base) {
39 ; CHECK: vsteb %v24, 4095(%r2), 10
41 %ptr = getelementptr i8, ptr %base, i32 4095
42 %element = extractelement <16 x i8> %val, i32 10
43 store i8 %element, ptr %ptr
47 ; Test v16i8 extraction with the first ouf-of-range offset.
48 define void @f5(<16 x i8> %val, ptr %base) {
50 ; CHECK: aghi %r2, 4096
51 ; CHECK: vsteb %v24, 0(%r2), 5
53 %ptr = getelementptr i8, ptr %base, i32 4096
54 %element = extractelement <16 x i8> %val, i32 5
55 store i8 %element, ptr %ptr
59 ; Test v16i8 extraction from a variable element.
60 define void @f6(<16 x i8> %val, ptr %ptr, i32 %index) {
64 %element = extractelement <16 x i8> %val, i32 %index
65 store i8 %element, ptr %ptr
69 ; Test v8i16 extraction from the first element.
70 define void @f7(<8 x i16> %val, ptr %ptr) {
72 ; CHECK: vsteh %v24, 0(%r2), 0
74 %element = extractelement <8 x i16> %val, i32 0
75 store i16 %element, ptr %ptr
79 ; Test v8i16 extraction from the last element.
80 define void @f8(<8 x i16> %val, ptr %ptr) {
82 ; CHECK: vsteh %v24, 0(%r2), 7
84 %element = extractelement <8 x i16> %val, i32 7
85 store i16 %element, ptr %ptr
89 ; Test v8i16 extraction of an invalid element. This must compile,
90 ; but we don't care what it does.
91 define void @f9(<8 x i16> %val, ptr %ptr) {
93 ; CHECK-NOT: vsteh %v24, 0(%r2), 8
95 %element = extractelement <8 x i16> %val, i32 8
96 store i16 %element, ptr %ptr
100 ; Test v8i16 extraction with the highest in-range offset.
101 define void @f10(<8 x i16> %val, ptr %base) {
103 ; CHECK: vsteh %v24, 4094(%r2), 5
105 %ptr = getelementptr i16, ptr %base, i32 2047
106 %element = extractelement <8 x i16> %val, i32 5
107 store i16 %element, ptr %ptr
111 ; Test v8i16 extraction with the first ouf-of-range offset.
112 define void @f11(<8 x i16> %val, ptr %base) {
114 ; CHECK: aghi %r2, 4096
115 ; CHECK: vsteh %v24, 0(%r2), 1
117 %ptr = getelementptr i16, ptr %base, i32 2048
118 %element = extractelement <8 x i16> %val, i32 1
119 store i16 %element, ptr %ptr
123 ; Test v8i16 extraction from a variable element.
124 define void @f12(<8 x i16> %val, ptr %ptr, i32 %index) {
128 %element = extractelement <8 x i16> %val, i32 %index
129 store i16 %element, ptr %ptr
133 ; Test v4i32 extraction from the first element.
134 define void @f13(<4 x i32> %val, ptr %ptr) {
136 ; CHECK: vstef %v24, 0(%r2), 0
138 %element = extractelement <4 x i32> %val, i32 0
139 store i32 %element, ptr %ptr
143 ; Test v4i32 extraction from the last element.
144 define void @f14(<4 x i32> %val, ptr %ptr) {
146 ; CHECK: vstef %v24, 0(%r2), 3
148 %element = extractelement <4 x i32> %val, i32 3
149 store i32 %element, ptr %ptr
153 ; Test v4i32 extraction of an invalid element. This must compile,
154 ; but we don't care what it does.
155 define void @f15(<4 x i32> %val, ptr %ptr) {
157 ; CHECK-NOT: vstef %v24, 0(%r2), 4
159 %element = extractelement <4 x i32> %val, i32 4
160 store i32 %element, ptr %ptr
164 ; Test v4i32 extraction with the highest in-range offset.
165 define void @f16(<4 x i32> %val, ptr %base) {
167 ; CHECK: vstef %v24, 4092(%r2), 2
169 %ptr = getelementptr i32, ptr %base, i32 1023
170 %element = extractelement <4 x i32> %val, i32 2
171 store i32 %element, ptr %ptr
175 ; Test v4i32 extraction with the first ouf-of-range offset.
176 define void @f17(<4 x i32> %val, ptr %base) {
178 ; CHECK: aghi %r2, 4096
179 ; CHECK: vstef %v24, 0(%r2), 1
181 %ptr = getelementptr i32, ptr %base, i32 1024
182 %element = extractelement <4 x i32> %val, i32 1
183 store i32 %element, ptr %ptr
187 ; Test v4i32 extraction from a variable element.
188 define void @f18(<4 x i32> %val, ptr %ptr, i32 %index) {
192 %element = extractelement <4 x i32> %val, i32 %index
193 store i32 %element, ptr %ptr
197 ; Test v2i64 extraction from the first element.
198 define void @f19(<2 x i64> %val, ptr %ptr) {
200 ; CHECK: vsteg %v24, 0(%r2), 0
202 %element = extractelement <2 x i64> %val, i32 0
203 store i64 %element, ptr %ptr
207 ; Test v2i64 extraction from the last element.
208 define void @f20(<2 x i64> %val, ptr %ptr) {
210 ; CHECK: vsteg %v24, 0(%r2), 1
212 %element = extractelement <2 x i64> %val, i32 1
213 store i64 %element, ptr %ptr
217 ; Test v2i64 extraction of an invalid element. This must compile,
218 ; but we don't care what it does.
219 define void @f21(<2 x i64> %val, ptr %ptr) {
221 ; CHECK-NOT: vsteg %v24, 0(%r2), 2
223 %element = extractelement <2 x i64> %val, i32 2
224 store i64 %element, ptr %ptr
228 ; Test v2i64 extraction with the highest in-range offset.
229 define void @f22(<2 x i64> %val, ptr %base) {
231 ; CHECK: vsteg %v24, 4088(%r2), 1
233 %ptr = getelementptr i64, ptr %base, i32 511
234 %element = extractelement <2 x i64> %val, i32 1
235 store i64 %element, ptr %ptr
239 ; Test v2i64 extraction with the first ouf-of-range offset.
240 define void @f23(<2 x i64> %val, ptr %base) {
242 ; CHECK: aghi %r2, 4096
243 ; CHECK: vsteg %v24, 0(%r2), 0
245 %ptr = getelementptr i64, ptr %base, i32 512
246 %element = extractelement <2 x i64> %val, i32 0
247 store i64 %element, ptr %ptr
251 ; Test v2i64 extraction from a variable element.
252 define void @f24(<2 x i64> %val, ptr %ptr, i32 %index) {
256 %element = extractelement <2 x i64> %val, i32 %index
257 store i64 %element, ptr %ptr
261 ; Test v4f32 extraction from the first element.
262 define void @f25(<4 x float> %val, ptr %ptr) {
264 ; CHECK: vstef %v24, 0(%r2), 0
266 %element = extractelement <4 x float> %val, i32 0
267 store float %element, ptr %ptr
271 ; Test v4f32 extraction from the last element.
272 define void @f26(<4 x float> %val, ptr %ptr) {
274 ; CHECK: vstef %v24, 0(%r2), 3
276 %element = extractelement <4 x float> %val, i32 3
277 store float %element, ptr %ptr
281 ; Test v4f32 extraction of an invalid element. This must compile,
282 ; but we don't care what it does.
283 define void @f27(<4 x float> %val, ptr %ptr) {
285 ; CHECK-NOT: vstef %v24, 0(%r2), 4
287 %element = extractelement <4 x float> %val, i32 4
288 store float %element, ptr %ptr
292 ; Test v4f32 extraction with the highest in-range offset.
293 define void @f28(<4 x float> %val, ptr %base) {
295 ; CHECK: vstef %v24, 4092(%r2), 2
297 %ptr = getelementptr float, ptr %base, i32 1023
298 %element = extractelement <4 x float> %val, i32 2
299 store float %element, ptr %ptr
303 ; Test v4f32 extraction with the first ouf-of-range offset.
304 define void @f29(<4 x float> %val, ptr %base) {
306 ; CHECK: aghi %r2, 4096
307 ; CHECK: vstef %v24, 0(%r2), 1
309 %ptr = getelementptr float, ptr %base, i32 1024
310 %element = extractelement <4 x float> %val, i32 1
311 store float %element, ptr %ptr
315 ; Test v4f32 extraction from a variable element.
316 define void @f30(<4 x float> %val, ptr %ptr, i32 %index) {
320 %element = extractelement <4 x float> %val, i32 %index
321 store float %element, ptr %ptr
325 ; Test v2f64 extraction from the first element.
326 define void @f32(<2 x double> %val, ptr %ptr) {
328 ; CHECK: vsteg %v24, 0(%r2), 0
330 %element = extractelement <2 x double> %val, i32 0
331 store double %element, ptr %ptr
335 ; Test v2f64 extraction from the last element.
336 define void @f33(<2 x double> %val, ptr %ptr) {
338 ; CHECK: vsteg %v24, 0(%r2), 1
340 %element = extractelement <2 x double> %val, i32 1
341 store double %element, ptr %ptr
345 ; Test v2f64 extraction with the highest in-range offset.
346 define void @f34(<2 x double> %val, ptr %base) {
348 ; CHECK: vsteg %v24, 4088(%r2), 1
350 %ptr = getelementptr double, ptr %base, i32 511
351 %element = extractelement <2 x double> %val, i32 1
352 store double %element, ptr %ptr
356 ; Test v2f64 extraction with the first ouf-of-range offset.
357 define void @f35(<2 x double> %val, ptr %base) {
359 ; CHECK: aghi %r2, 4096
360 ; CHECK: vsteg %v24, 0(%r2), 0
362 %ptr = getelementptr double, ptr %base, i32 512
363 %element = extractelement <2 x double> %val, i32 0
364 store double %element, ptr %ptr
368 ; Test v2f64 extraction from a variable element.
369 define void @f36(<2 x double> %val, ptr %ptr, i32 %index) {
373 %element = extractelement <2 x double> %val, i32 %index
374 store double %element, ptr %ptr
378 ; Test a v4i32 scatter of the first element.
379 define void @f37(<4 x i32> %val, <4 x i32> %index, i64 %base) {
381 ; CHECK: vscef %v24, 0(%v26,%r2), 0
383 %elem = extractelement <4 x i32> %index, i32 0
384 %ext = zext i32 %elem to i64
385 %add = add i64 %base, %ext
386 %ptr = inttoptr i64 %add to ptr
387 %element = extractelement <4 x i32> %val, i32 0
388 store i32 %element, ptr %ptr
392 ; Test a v4i32 scatter of the last element.
393 define void @f38(<4 x i32> %val, <4 x i32> %index, i64 %base) {
395 ; CHECK: vscef %v24, 0(%v26,%r2), 3
397 %elem = extractelement <4 x i32> %index, i32 3
398 %ext = zext i32 %elem to i64
399 %add = add i64 %base, %ext
400 %ptr = inttoptr i64 %add to ptr
401 %element = extractelement <4 x i32> %val, i32 3
402 store i32 %element, ptr %ptr
406 ; Test a v4i32 scatter with the highest in-range offset.
407 define void @f39(<4 x i32> %val, <4 x i32> %index, i64 %base) {
409 ; CHECK: vscef %v24, 4095(%v26,%r2), 1
411 %elem = extractelement <4 x i32> %index, i32 1
412 %ext = zext i32 %elem to i64
413 %add1 = add i64 %base, %ext
414 %add2 = add i64 %add1, 4095
415 %ptr = inttoptr i64 %add2 to ptr
416 %element = extractelement <4 x i32> %val, i32 1
417 store i32 %element, ptr %ptr
421 ; Test a v2i64 scatter of the first element.
422 define void @f40(<2 x i64> %val, <2 x i64> %index, i64 %base) {
424 ; CHECK: vsceg %v24, 0(%v26,%r2), 0
426 %elem = extractelement <2 x i64> %index, i32 0
427 %add = add i64 %base, %elem
428 %ptr = inttoptr i64 %add to ptr
429 %element = extractelement <2 x i64> %val, i32 0
430 store i64 %element, ptr %ptr
434 ; Test a v2i64 scatter of the last element.
435 define void @f41(<2 x i64> %val, <2 x i64> %index, i64 %base) {
437 ; CHECK: vsceg %v24, 0(%v26,%r2), 1
439 %elem = extractelement <2 x i64> %index, i32 1
440 %add = add i64 %base, %elem
441 %ptr = inttoptr i64 %add to ptr
442 %element = extractelement <2 x i64> %val, i32 1
443 store i64 %element, ptr %ptr
447 ; Test a v4f32 scatter of the first element.
448 define void @f42(<4 x float> %val, <4 x i32> %index, i64 %base) {
450 ; CHECK: vscef %v24, 0(%v26,%r2), 0
452 %elem = extractelement <4 x i32> %index, i32 0
453 %ext = zext i32 %elem to i64
454 %add = add i64 %base, %ext
455 %ptr = inttoptr i64 %add to ptr
456 %element = extractelement <4 x float> %val, i32 0
457 store float %element, ptr %ptr
461 ; Test a v4f32 scatter of the last element.
462 define void @f43(<4 x float> %val, <4 x i32> %index, i64 %base) {
464 ; CHECK: vscef %v24, 0(%v26,%r2), 3
466 %elem = extractelement <4 x i32> %index, i32 3
467 %ext = zext i32 %elem to i64
468 %add = add i64 %base, %ext
469 %ptr = inttoptr i64 %add to ptr
470 %element = extractelement <4 x float> %val, i32 3
471 store float %element, ptr %ptr
475 ; Test a v2f64 scatter of the first element.
476 define void @f44(<2 x double> %val, <2 x i64> %index, i64 %base) {
478 ; CHECK: vsceg %v24, 0(%v26,%r2), 0
480 %elem = extractelement <2 x i64> %index, i32 0
481 %add = add i64 %base, %elem
482 %ptr = inttoptr i64 %add to ptr
483 %element = extractelement <2 x double> %val, i32 0
484 store double %element, ptr %ptr
488 ; Test a v2f64 scatter of the last element.
489 define void @f45(<2 x double> %val, <2 x i64> %index, i64 %base) {
491 ; CHECK: vsceg %v24, 0(%v26,%r2), 1
493 %elem = extractelement <2 x i64> %index, i32 1
494 %add = add i64 %base, %elem
495 %ptr = inttoptr i64 %add to ptr
496 %element = extractelement <2 x double> %val, i32 1
497 store double %element, ptr %ptr