1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; Test vector intrinsics added with z14.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z14 | FileCheck %s
6 declare <2 x i64> @llvm.s390.vbperm(<16 x i8>, <16 x i8>)
7 declare i128 @llvm.s390.vmslg(<2 x i64>, <2 x i64>, i128, i32)
8 declare <16 x i8> @llvm.s390.vlrl(i32, ptr)
9 declare void @llvm.s390.vstrl(<16 x i8>, i32, ptr)
11 declare {<4 x i32>, i32} @llvm.s390.vfcesbs(<4 x float>, <4 x float>)
12 declare {<4 x i32>, i32} @llvm.s390.vfchsbs(<4 x float>, <4 x float>)
13 declare {<4 x i32>, i32} @llvm.s390.vfchesbs(<4 x float>, <4 x float>)
14 declare {<4 x i32>, i32} @llvm.s390.vftcisb(<4 x float>, i32)
15 declare <4 x float> @llvm.s390.vfisb(<4 x float>, i32, i32)
17 declare <2 x double> @llvm.s390.vfmaxdb(<2 x double>, <2 x double>, i32)
18 declare <2 x double> @llvm.s390.vfmindb(<2 x double>, <2 x double>, i32)
19 declare <4 x float> @llvm.s390.vfmaxsb(<4 x float>, <4 x float>, i32)
20 declare <4 x float> @llvm.s390.vfminsb(<4 x float>, <4 x float>, i32)
23 define <2 x i64> @test_vbperm(<16 x i8> %a, <16 x i8> %b) {
24 ; CHECK-LABEL: test_vbperm:
26 ; CHECK-NEXT: vbperm %v24, %v24, %v26
28 %res = call <2 x i64> @llvm.s390.vbperm(<16 x i8> %a, <16 x i8> %b)
32 ; VMSLG with no shifts.
33 define i128 @test_vmslg1(<2 x i64> %a, <2 x i64> %b, i128 %c) {
34 ; CHECK-LABEL: test_vmslg1:
36 ; CHECK-NEXT: vl %v0, 0(%r3), 3
37 ; CHECK-NEXT: vmslg %v0, %v24, %v26, %v0, 0
38 ; CHECK-NEXT: vst %v0, 0(%r2), 3
40 %res = call i128 @llvm.s390.vmslg(<2 x i64> %a, <2 x i64> %b, i128 %c, i32 0)
44 ; VMSLG with both shifts.
45 define i128 @test_vmslg2(<2 x i64> %a, <2 x i64> %b, i128 %c) {
46 ; CHECK-LABEL: test_vmslg2:
48 ; CHECK-NEXT: vl %v0, 0(%r3), 3
49 ; CHECK-NEXT: vmslg %v0, %v24, %v26, %v0, 12
50 ; CHECK-NEXT: vst %v0, 0(%r2), 3
52 %res = call i128 @llvm.s390.vmslg(<2 x i64> %a, <2 x i64> %b, i128 %c, i32 12)
56 ; VLRLR with the lowest in-range displacement.
57 define <16 x i8> @test_vlrlr1(ptr %ptr, i32 %length) {
58 ; CHECK-LABEL: test_vlrlr1:
60 ; CHECK-NEXT: vlrlr %v24, %r3, 0(%r2)
62 %res = call <16 x i8> @llvm.s390.vlrl(i32 %length, ptr %ptr)
66 ; VLRLR with the highest in-range displacement.
67 define <16 x i8> @test_vlrlr2(ptr %base, i32 %length) {
68 ; CHECK-LABEL: test_vlrlr2:
70 ; CHECK-NEXT: vlrlr %v24, %r3, 4095(%r2)
72 %ptr = getelementptr i8, ptr %base, i64 4095
73 %res = call <16 x i8> @llvm.s390.vlrl(i32 %length, ptr %ptr)
77 ; VLRLR with an out-of-range displacement.
78 define <16 x i8> @test_vlrlr3(ptr %base, i32 %length) {
79 ; CHECK-LABEL: test_vlrlr3:
81 ; CHECK-NEXT: aghi %r2, 4096
82 ; CHECK-NEXT: vlrlr %v24, %r3, 0(%r2)
84 %ptr = getelementptr i8, ptr %base, i64 4096
85 %res = call <16 x i8> @llvm.s390.vlrl(i32 %length, ptr %ptr)
89 ; Check that VLRLR doesn't allow an index.
90 define <16 x i8> @test_vlrlr4(ptr %base, i64 %index, i32 %length) {
91 ; CHECK-LABEL: test_vlrlr4:
93 ; CHECK-NEXT: agr %r2, %r3
94 ; CHECK-NEXT: vlrlr %v24, %r4, 0(%r2)
96 %ptr = getelementptr i8, ptr %base, i64 %index
97 %res = call <16 x i8> @llvm.s390.vlrl(i32 %length, ptr %ptr)
101 ; VLRL with the lowest in-range displacement.
102 define <16 x i8> @test_vlrl1(ptr %ptr) {
103 ; CHECK-LABEL: test_vlrl1:
105 ; CHECK-NEXT: vlrl %v24, 0(%r2), 0
106 ; CHECK-NEXT: br %r14
107 %res = call <16 x i8> @llvm.s390.vlrl(i32 0, ptr %ptr)
111 ; VLRL with the highest in-range displacement.
112 define <16 x i8> @test_vlrl2(ptr %base) {
113 ; CHECK-LABEL: test_vlrl2:
115 ; CHECK-NEXT: vlrl %v24, 4095(%r2), 0
116 ; CHECK-NEXT: br %r14
117 %ptr = getelementptr i8, ptr %base, i64 4095
118 %res = call <16 x i8> @llvm.s390.vlrl(i32 0, ptr %ptr)
122 ; VLRL with an out-of-range displacement.
123 define <16 x i8> @test_vlrl3(ptr %base) {
124 ; CHECK-LABEL: test_vlrl3:
126 ; CHECK-NEXT: aghi %r2, 4096
127 ; CHECK-NEXT: vlrl %v24, 0(%r2), 0
128 ; CHECK-NEXT: br %r14
129 %ptr = getelementptr i8, ptr %base, i64 4096
130 %res = call <16 x i8> @llvm.s390.vlrl(i32 0, ptr %ptr)
134 ; Check that VLRL doesn't allow an index.
135 define <16 x i8> @test_vlrl4(ptr %base, i64 %index) {
136 ; CHECK-LABEL: test_vlrl4:
138 ; CHECK-NEXT: agr %r2, %r3
139 ; CHECK-NEXT: vlrl %v24, 0(%r2), 0
140 ; CHECK-NEXT: br %r14
141 %ptr = getelementptr i8, ptr %base, i64 %index
142 %res = call <16 x i8> @llvm.s390.vlrl(i32 0, ptr %ptr)
146 ; VLRL with length >= 15 should become VL.
147 define <16 x i8> @test_vlrl5(ptr %ptr) {
148 ; CHECK-LABEL: test_vlrl5:
150 ; CHECK-NEXT: vl %v24, 0(%r2), 3
151 ; CHECK-NEXT: br %r14
152 %res = call <16 x i8> @llvm.s390.vlrl(i32 15, ptr %ptr)
156 ; VSTRLR with the lowest in-range displacement.
157 define void @test_vstrlr1(<16 x i8> %vec, ptr %ptr, i32 %length) {
158 ; CHECK-LABEL: test_vstrlr1:
160 ; CHECK-NEXT: vstrlr %v24, %r3, 0(%r2)
161 ; CHECK-NEXT: br %r14
162 call void @llvm.s390.vstrl(<16 x i8> %vec, i32 %length, ptr %ptr)
166 ; VSTRLR with the highest in-range displacement.
167 define void @test_vstrlr2(<16 x i8> %vec, ptr %base, i32 %length) {
168 ; CHECK-LABEL: test_vstrlr2:
170 ; CHECK-NEXT: vstrlr %v24, %r3, 4095(%r2)
171 ; CHECK-NEXT: br %r14
172 %ptr = getelementptr i8, ptr %base, i64 4095
173 call void @llvm.s390.vstrl(<16 x i8> %vec, i32 %length, ptr %ptr)
177 ; VSTRLR with an out-of-range displacement.
178 define void @test_vstrlr3(<16 x i8> %vec, ptr %base, i32 %length) {
179 ; CHECK-LABEL: test_vstrlr3:
181 ; CHECK-NEXT: aghi %r2, 4096
182 ; CHECK-NEXT: vstrlr %v24, %r3, 0(%r2)
183 ; CHECK-NEXT: br %r14
184 %ptr = getelementptr i8, ptr %base, i64 4096
185 call void @llvm.s390.vstrl(<16 x i8> %vec, i32 %length, ptr %ptr)
189 ; Check that VSTRLR doesn't allow an index.
190 define void @test_vstrlr4(<16 x i8> %vec, ptr %base, i64 %index, i32 %length) {
191 ; CHECK-LABEL: test_vstrlr4:
193 ; CHECK-NEXT: agr %r2, %r3
194 ; CHECK-NEXT: vstrlr %v24, %r4, 0(%r2)
195 ; CHECK-NEXT: br %r14
196 %ptr = getelementptr i8, ptr %base, i64 %index
197 call void @llvm.s390.vstrl(<16 x i8> %vec, i32 %length, ptr %ptr)
201 ; VSTRL with the lowest in-range displacement.
202 define void @test_vstrl1(<16 x i8> %vec, ptr %ptr) {
203 ; CHECK-LABEL: test_vstrl1:
205 ; CHECK-NEXT: vstrl %v24, 0(%r2), 8
206 ; CHECK-NEXT: br %r14
207 call void @llvm.s390.vstrl(<16 x i8> %vec, i32 8, ptr %ptr)
211 ; VSTRL with the highest in-range displacement.
212 define void @test_vstrl2(<16 x i8> %vec, ptr %base) {
213 ; CHECK-LABEL: test_vstrl2:
215 ; CHECK-NEXT: vstrl %v24, 4095(%r2), 8
216 ; CHECK-NEXT: br %r14
217 %ptr = getelementptr i8, ptr %base, i64 4095
218 call void @llvm.s390.vstrl(<16 x i8> %vec, i32 8, ptr %ptr)
222 ; VSTRL with an out-of-range displacement.
223 define void @test_vstrl3(<16 x i8> %vec, ptr %base) {
224 ; CHECK-LABEL: test_vstrl3:
226 ; CHECK-NEXT: aghi %r2, 4096
227 ; CHECK-NEXT: vstrl %v24, 0(%r2), 8
228 ; CHECK-NEXT: br %r14
229 %ptr = getelementptr i8, ptr %base, i64 4096
230 call void @llvm.s390.vstrl(<16 x i8> %vec, i32 8, ptr %ptr)
234 ; Check that VSTRL doesn't allow an index.
235 define void @test_vstrl4(<16 x i8> %vec, ptr %base, i64 %index) {
236 ; CHECK-LABEL: test_vstrl4:
238 ; CHECK-NEXT: agr %r2, %r3
239 ; CHECK-NEXT: vstrl %v24, 0(%r2), 8
240 ; CHECK-NEXT: br %r14
241 %ptr = getelementptr i8, ptr %base, i64 %index
242 call void @llvm.s390.vstrl(<16 x i8> %vec, i32 8, ptr %ptr)
246 ; VSTRL with length >= 15 should become VST.
247 define void @test_vstrl5(<16 x i8> %vec, ptr %ptr) {
248 ; CHECK-LABEL: test_vstrl5:
250 ; CHECK-NEXT: vst %v24, 0(%r2), 3
251 ; CHECK-NEXT: br %r14
252 call void @llvm.s390.vstrl(<16 x i8> %vec, i32 15, ptr %ptr)
256 ; VFCESBS with no processing of the result.
257 define i32 @test_vfcesbs(<4 x float> %a, <4 x float> %b) {
258 ; CHECK-LABEL: test_vfcesbs:
260 ; CHECK-NEXT: vfcesbs %v0, %v24, %v26
261 ; CHECK-NEXT: ipm %r2
262 ; CHECK-NEXT: srl %r2, 28
263 ; CHECK-NEXT: br %r14
264 %call = call {<4 x i32>, i32} @llvm.s390.vfcesbs(<4 x float> %a,
266 %res = extractvalue {<4 x i32>, i32} %call, 1
270 ; VFCESBS, returning 1 if any elements are equal (CC != 3).
271 define i32 @test_vfcesbs_any_bool(<4 x float> %a, <4 x float> %b) {
272 ; CHECK-LABEL: test_vfcesbs_any_bool:
274 ; CHECK-NEXT: vfcesbs %v0, %v24, %v26
275 ; CHECK-NEXT: lhi %r2, 0
276 ; CHECK-NEXT: lochile %r2, 1
277 ; CHECK-NEXT: br %r14
278 %call = call {<4 x i32>, i32} @llvm.s390.vfcesbs(<4 x float> %a,
280 %res = extractvalue {<4 x i32>, i32} %call, 1
281 %cmp = icmp ne i32 %res, 3
282 %ext = zext i1 %cmp to i32
286 ; VFCESBS, storing to %ptr if any elements are equal.
287 define <4 x i32> @test_vfcesbs_any_store(<4 x float> %a, <4 x float> %b,
288 ; CHECK-LABEL: test_vfcesbs_any_store:
290 ; CHECK-NEXT: vfcesbs %v24, %v24, %v26
291 ; CHECK-NEXT: bor %r14
292 ; CHECK-NEXT: .LBB23_1: # %store
293 ; CHECK-NEXT: mvhi 0(%r2), 0
294 ; CHECK-NEXT: br %r14
296 %call = call {<4 x i32>, i32} @llvm.s390.vfcesbs(<4 x float> %a,
298 %res = extractvalue {<4 x i32>, i32} %call, 0
299 %cc = extractvalue {<4 x i32>, i32} %call, 1
300 %cmp = icmp ule i32 %cc, 2
301 br i1 %cmp, label %store, label %exit
304 store i32 0, ptr %ptr
311 ; VFCHSBS with no processing of the result.
312 define i32 @test_vfchsbs(<4 x float> %a, <4 x float> %b) {
313 ; CHECK-LABEL: test_vfchsbs:
315 ; CHECK-NEXT: vfchsbs %v0, %v24, %v26
316 ; CHECK-NEXT: ipm %r2
317 ; CHECK-NEXT: srl %r2, 28
318 ; CHECK-NEXT: br %r14
319 %call = call {<4 x i32>, i32} @llvm.s390.vfchsbs(<4 x float> %a,
321 %res = extractvalue {<4 x i32>, i32} %call, 1
325 ; VFCHSBS, returning 1 if not all elements are higher.
326 define i32 @test_vfchsbs_notall_bool(<4 x float> %a, <4 x float> %b) {
327 ; CHECK-LABEL: test_vfchsbs_notall_bool:
329 ; CHECK-NEXT: vfchsbs %v0, %v24, %v26
330 ; CHECK-NEXT: lhi %r2, 0
331 ; CHECK-NEXT: lochinhe %r2, 1
332 ; CHECK-NEXT: br %r14
333 %call = call {<4 x i32>, i32} @llvm.s390.vfchsbs(<4 x float> %a,
335 %res = extractvalue {<4 x i32>, i32} %call, 1
336 %cmp = icmp sge i32 %res, 1
337 %ext = zext i1 %cmp to i32
341 ; VFCHSBS, storing to %ptr if not all elements are higher.
342 define <4 x i32> @test_vfchsbs_notall_store(<4 x float> %a, <4 x float> %b,
343 ; CHECK-LABEL: test_vfchsbs_notall_store:
345 ; CHECK-NEXT: vfchsbs %v24, %v24, %v26
346 ; CHECK-NEXT: ber %r14
347 ; CHECK-NEXT: .LBB26_1: # %store
348 ; CHECK-NEXT: mvhi 0(%r2), 0
349 ; CHECK-NEXT: br %r14
351 %call = call {<4 x i32>, i32} @llvm.s390.vfchsbs(<4 x float> %a,
353 %res = extractvalue {<4 x i32>, i32} %call, 0
354 %cc = extractvalue {<4 x i32>, i32} %call, 1
355 %cmp = icmp ugt i32 %cc, 0
356 br i1 %cmp, label %store, label %exit
359 store i32 0, ptr %ptr
366 ; VFCHESBS with no processing of the result.
367 define i32 @test_vfchesbs(<4 x float> %a, <4 x float> %b) {
368 ; CHECK-LABEL: test_vfchesbs:
370 ; CHECK-NEXT: vfchesbs %v0, %v24, %v26
371 ; CHECK-NEXT: ipm %r2
372 ; CHECK-NEXT: srl %r2, 28
373 ; CHECK-NEXT: br %r14
374 %call = call {<4 x i32>, i32} @llvm.s390.vfchesbs(<4 x float> %a,
376 %res = extractvalue {<4 x i32>, i32} %call, 1
380 ; VFCHESBS, returning 1 if neither element is higher or equal.
381 define i32 @test_vfchesbs_none_bool(<4 x float> %a, <4 x float> %b) {
382 ; CHECK-LABEL: test_vfchesbs_none_bool:
384 ; CHECK-NEXT: vfchesbs %v0, %v24, %v26
385 ; CHECK-NEXT: lhi %r2, 0
386 ; CHECK-NEXT: lochio %r2, 1
387 ; CHECK-NEXT: br %r14
388 %call = call {<4 x i32>, i32} @llvm.s390.vfchesbs(<4 x float> %a,
390 %res = extractvalue {<4 x i32>, i32} %call, 1
391 %cmp = icmp eq i32 %res, 3
392 %ext = zext i1 %cmp to i32
396 ; VFCHESBS, storing to %ptr if neither element is higher or equal.
397 define <4 x i32> @test_vfchesbs_none_store(<4 x float> %a, <4 x float> %b,
398 ; CHECK-LABEL: test_vfchesbs_none_store:
400 ; CHECK-NEXT: vfchesbs %v24, %v24, %v26
401 ; CHECK-NEXT: bler %r14
402 ; CHECK-NEXT: .LBB29_1: # %store
403 ; CHECK-NEXT: mvhi 0(%r2), 0
404 ; CHECK-NEXT: br %r14
406 %call = call {<4 x i32>, i32} @llvm.s390.vfchesbs(<4 x float> %a,
408 %res = extractvalue {<4 x i32>, i32} %call, 0
409 %cc = extractvalue {<4 x i32>, i32} %call, 1
410 %cmp = icmp uge i32 %cc, 3
411 br i1 %cmp, label %store, label %exit
414 store i32 0, ptr %ptr
421 ; VFTCISB with the lowest useful class selector and no processing of the result.
422 define i32 @test_vftcisb(<4 x float> %a) {
423 ; CHECK-LABEL: test_vftcisb:
425 ; CHECK-NEXT: vftcisb %v0, %v24, 1
426 ; CHECK-NEXT: ipm %r2
427 ; CHECK-NEXT: srl %r2, 28
428 ; CHECK-NEXT: br %r14
429 %call = call {<4 x i32>, i32} @llvm.s390.vftcisb(<4 x float> %a, i32 1)
430 %res = extractvalue {<4 x i32>, i32} %call, 1
434 ; VFTCISB with the highest useful class selector, returning 1 if all elements
435 ; have the right class (CC == 0).
436 define i32 @test_vftcisb_all_bool(<4 x float> %a) {
437 ; CHECK-LABEL: test_vftcisb_all_bool:
439 ; CHECK-NEXT: vftcisb %v0, %v24, 4094
440 ; CHECK-NEXT: lhi %r2, 0
441 ; CHECK-NEXT: lochie %r2, 1
442 ; CHECK-NEXT: br %r14
443 %call = call {<4 x i32>, i32} @llvm.s390.vftcisb(<4 x float> %a, i32 4094)
444 %res = extractvalue {<4 x i32>, i32} %call, 1
445 %cmp = icmp eq i32 %res, 0
446 %ext = zext i1 %cmp to i32
450 ; VFISB with a rounding mode not usable via standard intrinsics.
451 define <4 x float> @test_vfisb_0_4(<4 x float> %a) {
452 ; CHECK-LABEL: test_vfisb_0_4:
454 ; CHECK-NEXT: vfisb %v24, %v24, 0, 4
455 ; CHECK-NEXT: br %r14
456 %res = call <4 x float> @llvm.s390.vfisb(<4 x float> %a, i32 0, i32 4)
460 ; VFISB with IEEE-inexact exception suppressed.
461 define <4 x float> @test_vfisb_4_0(<4 x float> %a) {
462 ; CHECK-LABEL: test_vfisb_4_0:
464 ; CHECK-NEXT: vfisb %v24, %v24, 4, 0
465 ; CHECK-NEXT: br %r14
466 %res = call <4 x float> @llvm.s390.vfisb(<4 x float> %a, i32 4, i32 0)
471 define <2 x double> @test_vfmaxdb(<2 x double> %a, <2 x double> %b) {
472 ; CHECK-LABEL: test_vfmaxdb:
474 ; CHECK-NEXT: vfmaxdb %v24, %v24, %v26, 4
475 ; CHECK-NEXT: br %r14
476 %res = call <2 x double> @llvm.s390.vfmaxdb(<2 x double> %a, <2 x double> %b, i32 4)
477 ret <2 x double> %res
481 define <2 x double> @test_vfmindb(<2 x double> %a, <2 x double> %b) {
482 ; CHECK-LABEL: test_vfmindb:
484 ; CHECK-NEXT: vfmindb %v24, %v24, %v26, 4
485 ; CHECK-NEXT: br %r14
486 %res = call <2 x double> @llvm.s390.vfmindb(<2 x double> %a, <2 x double> %b, i32 4)
487 ret <2 x double> %res
491 define <4 x float> @test_vfmaxsb(<4 x float> %a, <4 x float> %b) {
492 ; CHECK-LABEL: test_vfmaxsb:
494 ; CHECK-NEXT: vfmaxsb %v24, %v24, %v26, 4
495 ; CHECK-NEXT: br %r14
496 %res = call <4 x float> @llvm.s390.vfmaxsb(<4 x float> %a, <4 x float> %b, i32 4)
501 define <4 x float> @test_vfminsb(<4 x float> %a, <4 x float> %b) {
502 ; CHECK-LABEL: test_vfminsb:
504 ; CHECK-NEXT: vfminsb %v24, %v24, %v26, 4
505 ; CHECK-NEXT: br %r14
506 %res = call <4 x float> @llvm.s390.vfminsb(<4 x float> %a, <4 x float> %b, i32 4)