1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
3 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
4 ; RUN: FileCheck %s --check-prefixes=CHECK,CHECK-LE
5 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
6 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
7 ; RUN: FileCheck %s --check-prefixes=CHECK,CHECK-BE
8 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O0 \
9 ; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
10 ; RUN: FileCheck %s --check-prefixes=CHECK,CHECK-O0
12 ; These test cases aims to test the builtins for the Power10 VSX vector
13 ; instructions introduced in ISA 3.1.
15 declare i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8>, i32)
17 define signext i32 @test_vec_test_lsbb_all_ones(<16 x i8> %vuca) {
18 ; CHECK-LABEL: test_vec_test_lsbb_all_ones:
19 ; CHECK: # %bb.0: # %entry
20 ; CHECK-NEXT: xvtlsbb cr0, v2
21 ; CHECK-NEXT: mfocrf r3, 128
22 ; CHECK-NEXT: srwi r3, r3, 31
23 ; CHECK-NEXT: extsw r3, r3
26 %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 1)
30 define signext i32 @test_vec_test_lsbb_all_zeros(<16 x i8> %vuca) {
31 ; CHECK-LABEL: test_vec_test_lsbb_all_zeros:
32 ; CHECK: # %bb.0: # %entry
33 ; CHECK-NEXT: xvtlsbb cr0, v2
34 ; CHECK-NEXT: mfocrf r3, 128
35 ; CHECK-NEXT: rlwinm r3, r3, 3, 31, 31
36 ; CHECK-NEXT: extsw r3, r3
39 %0 = tail call i32 @llvm.ppc.vsx.xvtlsbb(<16 x i8> %vuca, i32 0)
43 define void @vec_xst_trunc_sc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
44 ; CHECK-LE-LABEL: vec_xst_trunc_sc:
45 ; CHECK-LE: # %bb.0: # %entry
46 ; CHECK-LE-NEXT: stxvrbx v2, r6, r5
49 ; CHECK-BE-LABEL: vec_xst_trunc_sc:
50 ; CHECK-BE: # %bb.0: # %entry
51 ; CHECK-BE-NEXT: vsldoi v2, v2, v2, 9
52 ; CHECK-BE-NEXT: stxsibx v2, r6, r5
55 ; CHECK-O0-LABEL: vec_xst_trunc_sc:
56 ; CHECK-O0: # %bb.0: # %entry
57 ; CHECK-O0-NEXT: li r3, 0
58 ; CHECK-O0-NEXT: vextubrx r3, r3, v2
59 ; CHECK-O0-NEXT: # kill: def $r3 killed $r3 killed $x3
60 ; CHECK-O0-NEXT: add r4, r6, r5
61 ; CHECK-O0-NEXT: stb r3, 0(r4)
64 %0 = bitcast <1 x i128> %__vec to <16 x i8>
65 %conv = extractelement <16 x i8> %0, i32 0
66 %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
67 store i8 %conv, i8* %add.ptr, align 1
71 define void @vec_xst_trunc_uc(<1 x i128> %__vec, i64 %__offset, i8* nocapture %__ptr) {
72 ; CHECK-LE-LABEL: vec_xst_trunc_uc:
73 ; CHECK-LE: # %bb.0: # %entry
74 ; CHECK-LE-NEXT: stxvrbx v2, r6, r5
77 ; CHECK-BE-LABEL: vec_xst_trunc_uc:
78 ; CHECK-BE: # %bb.0: # %entry
79 ; CHECK-BE-NEXT: vsldoi v2, v2, v2, 9
80 ; CHECK-BE-NEXT: stxsibx v2, r6, r5
83 ; CHECK-O0-LABEL: vec_xst_trunc_uc:
84 ; CHECK-O0: # %bb.0: # %entry
85 ; CHECK-O0-NEXT: li r3, 0
86 ; CHECK-O0-NEXT: vextubrx r3, r3, v2
87 ; CHECK-O0-NEXT: # kill: def $r3 killed $r3 killed $x3
88 ; CHECK-O0-NEXT: add r4, r6, r5
89 ; CHECK-O0-NEXT: stb r3, 0(r4)
92 %0 = bitcast <1 x i128> %__vec to <16 x i8>
93 %conv = extractelement <16 x i8> %0, i32 0
94 %add.ptr = getelementptr inbounds i8, i8* %__ptr, i64 %__offset
95 store i8 %conv, i8* %add.ptr, align 1
99 define void @vec_xst_trunc_ss(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
100 ; CHECK-LE-LABEL: vec_xst_trunc_ss:
101 ; CHECK-LE: # %bb.0: # %entry
102 ; CHECK-LE-NEXT: sldi r3, r5, 1
103 ; CHECK-LE-NEXT: stxvrhx v2, r6, r3
106 ; CHECK-BE-LABEL: vec_xst_trunc_ss:
107 ; CHECK-BE: # %bb.0: # %entry
108 ; CHECK-BE-NEXT: vsldoi v2, v2, v2, 10
109 ; CHECK-BE-NEXT: sldi r3, r5, 1
110 ; CHECK-BE-NEXT: stxsihx v2, r6, r3
113 ; CHECK-O0-LABEL: vec_xst_trunc_ss:
114 ; CHECK-O0: # %bb.0: # %entry
115 ; CHECK-O0-NEXT: li r3, 0
116 ; CHECK-O0-NEXT: vextuhrx r3, r3, v2
117 ; CHECK-O0-NEXT: # kill: def $r3 killed $r3 killed $x3
118 ; CHECK-O0-NEXT: sldi r4, r5, 1
119 ; CHECK-O0-NEXT: add r4, r6, r4
120 ; CHECK-O0-NEXT: sth r3, 0(r4)
123 %0 = bitcast <1 x i128> %__vec to <8 x i16>
124 %conv = extractelement <8 x i16> %0, i32 0
125 %add.ptr = getelementptr inbounds i16, i16* %__ptr, i64 %__offset
126 store i16 %conv, i16* %add.ptr, align 2
130 define void @vec_xst_trunc_us(<1 x i128> %__vec, i64 %__offset, i16* nocapture %__ptr) {
131 ; CHECK-LE-LABEL: vec_xst_trunc_us:
132 ; CHECK-LE: # %bb.0: # %entry
133 ; CHECK-LE-NEXT: sldi r3, r5, 1
134 ; CHECK-LE-NEXT: stxvrhx v2, r6, r3
137 ; CHECK-BE-LABEL: vec_xst_trunc_us:
138 ; CHECK-BE: # %bb.0: # %entry
139 ; CHECK-BE-NEXT: vsldoi v2, v2, v2, 10
140 ; CHECK-BE-NEXT: sldi r3, r5, 1
141 ; CHECK-BE-NEXT: stxsihx v2, r6, r3
144 ; CHECK-O0-LABEL: vec_xst_trunc_us:
145 ; CHECK-O0: # %bb.0: # %entry
146 ; CHECK-O0-NEXT: li r3, 0
147 ; CHECK-O0-NEXT: vextuhrx r3, r3, v2
148 ; CHECK-O0-NEXT: # kill: def $r3 killed $r3 killed $x3
149 ; CHECK-O0-NEXT: sldi r4, r5, 1
150 ; CHECK-O0-NEXT: add r4, r6, r4
151 ; CHECK-O0-NEXT: sth r3, 0(r4)
154 %0 = bitcast <1 x i128> %__vec to <8 x i16>
155 %conv = extractelement <8 x i16> %0, i32 0
156 %add.ptr = getelementptr inbounds i16, i16* %__ptr, i64 %__offset
157 store i16 %conv, i16* %add.ptr, align 2
161 define void @vec_xst_trunc_si(<1 x i128> %__vec, i64 %__offset, i32* nocapture %__ptr) {
162 ; CHECK-LE-LABEL: vec_xst_trunc_si:
163 ; CHECK-LE: # %bb.0: # %entry
164 ; CHECK-LE-NEXT: sldi r3, r5, 2
165 ; CHECK-LE-NEXT: stxvrwx v2, r6, r3
168 ; CHECK-BE-LABEL: vec_xst_trunc_si:
169 ; CHECK-BE: # %bb.0: # %entry
170 ; CHECK-BE-NEXT: xxsldwi vs0, v2, v2, 3
171 ; CHECK-BE-NEXT: sldi r3, r5, 2
172 ; CHECK-BE-NEXT: stfiwx f0, r6, r3
175 ; CHECK-O0-LABEL: vec_xst_trunc_si:
176 ; CHECK-O0: # %bb.0: # %entry
177 ; CHECK-O0-NEXT: li r3, 0
178 ; CHECK-O0-NEXT: vextuwrx r3, r3, v2
179 ; CHECK-O0-NEXT: # kill: def $r3 killed $r3 killed $x3
180 ; CHECK-O0-NEXT: sldi r4, r5, 2
181 ; CHECK-O0-NEXT: add r4, r6, r4
182 ; CHECK-O0-NEXT: stw r3, 0(r4)
185 %0 = bitcast <1 x i128> %__vec to <4 x i32>
186 %conv = extractelement <4 x i32> %0, i32 0
187 %add.ptr = getelementptr inbounds i32, i32* %__ptr, i64 %__offset
188 store i32 %conv, i32* %add.ptr, align 4
192 define void @vec_xst_trunc_ui(<1 x i128> %__vec, i64 %__offset, i32* nocapture %__ptr) {
193 ; CHECK-LE-LABEL: vec_xst_trunc_ui:
194 ; CHECK-LE: # %bb.0: # %entry
195 ; CHECK-LE-NEXT: sldi r3, r5, 2
196 ; CHECK-LE-NEXT: stxvrwx v2, r6, r3
199 ; CHECK-BE-LABEL: vec_xst_trunc_ui:
200 ; CHECK-BE: # %bb.0: # %entry
201 ; CHECK-BE-NEXT: xxsldwi vs0, v2, v2, 3
202 ; CHECK-BE-NEXT: sldi r3, r5, 2
203 ; CHECK-BE-NEXT: stfiwx f0, r6, r3
206 ; CHECK-O0-LABEL: vec_xst_trunc_ui:
207 ; CHECK-O0: # %bb.0: # %entry
208 ; CHECK-O0-NEXT: li r3, 0
209 ; CHECK-O0-NEXT: vextuwrx r3, r3, v2
210 ; CHECK-O0-NEXT: # kill: def $r3 killed $r3 killed $x3
211 ; CHECK-O0-NEXT: sldi r4, r5, 2
212 ; CHECK-O0-NEXT: add r4, r6, r4
213 ; CHECK-O0-NEXT: stw r3, 0(r4)
216 %0 = bitcast <1 x i128> %__vec to <4 x i32>
217 %conv = extractelement <4 x i32> %0, i32 0
218 %add.ptr = getelementptr inbounds i32, i32* %__ptr, i64 %__offset
219 store i32 %conv, i32* %add.ptr, align 4
223 define void @vec_xst_trunc_sll(<1 x i128> %__vec, i64 %__offset, i64* nocapture %__ptr) {
224 ; CHECK-LE-LABEL: vec_xst_trunc_sll:
225 ; CHECK-LE: # %bb.0: # %entry
226 ; CHECK-LE-NEXT: sldi r3, r5, 3
227 ; CHECK-LE-NEXT: stxvrdx v2, r6, r3
230 ; CHECK-BE-LABEL: vec_xst_trunc_sll:
231 ; CHECK-BE: # %bb.0: # %entry
232 ; CHECK-BE-NEXT: sldi r3, r5, 3
233 ; CHECK-BE-NEXT: stxsdx v2, r6, r3
236 ; CHECK-O0-LABEL: vec_xst_trunc_sll:
237 ; CHECK-O0: # %bb.0: # %entry
238 ; CHECK-O0-NEXT: mfvsrld r3, v2
239 ; CHECK-O0-NEXT: sldi r4, r5, 3
240 ; CHECK-O0-NEXT: add r4, r6, r4
241 ; CHECK-O0-NEXT: std r3, 0(r4)
244 %0 = bitcast <1 x i128> %__vec to <2 x i64>
245 %conv = extractelement <2 x i64> %0, i32 0
246 %add.ptr = getelementptr inbounds i64, i64* %__ptr, i64 %__offset
247 store i64 %conv, i64* %add.ptr, align 8
251 define void @vec_xst_trunc_ull(<1 x i128> %__vec, i64 %__offset, i64* nocapture %__ptr) {
252 ; CHECK-LE-LABEL: vec_xst_trunc_ull:
253 ; CHECK-LE: # %bb.0: # %entry
254 ; CHECK-LE-NEXT: sldi r3, r5, 3
255 ; CHECK-LE-NEXT: stxvrdx v2, r6, r3
258 ; CHECK-BE-LABEL: vec_xst_trunc_ull:
259 ; CHECK-BE: # %bb.0: # %entry
260 ; CHECK-BE-NEXT: sldi r3, r5, 3
261 ; CHECK-BE-NEXT: stxsdx v2, r6, r3
264 ; CHECK-O0-LABEL: vec_xst_trunc_ull:
265 ; CHECK-O0: # %bb.0: # %entry
266 ; CHECK-O0-NEXT: mfvsrld r3, v2
267 ; CHECK-O0-NEXT: sldi r4, r5, 3
268 ; CHECK-O0-NEXT: add r4, r6, r4
269 ; CHECK-O0-NEXT: std r3, 0(r4)
272 %0 = bitcast <1 x i128> %__vec to <2 x i64>
273 %conv = extractelement <2 x i64> %0, i32 0
274 %add.ptr = getelementptr inbounds i64, i64* %__ptr, i64 %__offset
275 store i64 %conv, i64* %add.ptr, align 8
279 define dso_local <1 x i128> @vec_xl_zext(i64 %__offset, i8* nocapture readonly %__pointer) {
280 ; CHECK-LABEL: vec_xl_zext:
281 ; CHECK: # %bb.0: # %entry
282 ; CHECK-NEXT: lxvrbx v2, r4, r3
285 %add.ptr = getelementptr inbounds i8, i8* %__pointer, i64 %__offset
286 %0 = load i8, i8* %add.ptr, align 1
287 %conv = zext i8 %0 to i128
288 %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
289 ret <1 x i128> %splat.splatinsert
292 define dso_local <1 x i128> @vec_xl_zext_short(i64 %__offset, i16* nocapture readonly %__pointer) {
293 ; CHECK-LABEL: vec_xl_zext_short:
294 ; CHECK: # %bb.0: # %entry
295 ; CHECK-NEXT: sldi r3, r3, 1
296 ; CHECK-NEXT: lxvrhx v2, r4, r3
299 %add.ptr = getelementptr inbounds i16, i16* %__pointer, i64 %__offset
300 %0 = load i16, i16* %add.ptr, align 2
301 %conv = zext i16 %0 to i128
302 %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
303 ret <1 x i128> %splat.splatinsert
306 define dso_local <1 x i128> @vec_xl_zext_word(i64 %__offset, i32* nocapture readonly %__pointer) {
307 ; CHECK-LABEL: vec_xl_zext_word:
308 ; CHECK: # %bb.0: # %entry
309 ; CHECK-NEXT: sldi r3, r3, 2
310 ; CHECK-NEXT: lxvrwx v2, r4, r3
313 %add.ptr = getelementptr inbounds i32, i32* %__pointer, i64 %__offset
314 %0 = load i32, i32* %add.ptr, align 4
315 %conv = zext i32 %0 to i128
316 %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
317 ret <1 x i128> %splat.splatinsert
320 define dso_local <1 x i128> @vec_xl_zext_dw(i64 %__offset, i64* nocapture readonly %__pointer) {
321 ; CHECK-LABEL: vec_xl_zext_dw:
322 ; CHECK: # %bb.0: # %entry
323 ; CHECK-NEXT: sldi r3, r3, 3
324 ; CHECK-NEXT: lxvrdx v2, r4, r3
327 %add.ptr = getelementptr inbounds i64, i64* %__pointer, i64 %__offset
328 %0 = load i64, i64* %add.ptr, align 8
329 %conv = zext i64 %0 to i128
330 %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
331 ret <1 x i128> %splat.splatinsert
334 define dso_local <1 x i128> @vec_xl_sext_b(i64 %offset, i8* %p) {
335 ; CHECK-LE-LABEL: vec_xl_sext_b:
336 ; CHECK-LE: # %bb.0: # %entry
337 ; CHECK-LE-NEXT: lbzx r3, r4, r3
338 ; CHECK-LE-NEXT: extsb r3, r3
339 ; CHECK-LE-NEXT: sradi r4, r3, 63
340 ; CHECK-LE-NEXT: mtvsrdd v2, r4, r3
343 ; CHECK-BE-LABEL: vec_xl_sext_b:
344 ; CHECK-BE: # %bb.0: # %entry
345 ; CHECK-BE-NEXT: lbzx r3, r4, r3
346 ; CHECK-BE-NEXT: extsb r3, r3
347 ; CHECK-BE-NEXT: sradi r4, r3, 63
348 ; CHECK-BE-NEXT: mtvsrdd v2, r4, r3
351 ; CHECK-O0-LABEL: vec_xl_sext_b:
352 ; CHECK-O0: # %bb.0: # %entry
353 ; CHECK-O0-NEXT: lbzx r3, r4, r3
354 ; CHECK-O0-NEXT: extsb r4, r3
355 ; CHECK-O0-NEXT: sradi r3, r4, 63
356 ; CHECK-O0-NEXT: mtvsrdd v2, r3, r4
359 %add.ptr = getelementptr inbounds i8, i8* %p, i64 %offset
360 %0 = load i8, i8* %add.ptr, align 1
361 %conv = sext i8 %0 to i128
362 %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
363 ret <1 x i128> %splat.splatinsert
366 define dso_local <1 x i128> @vec_xl_sext_h(i64 %offset, i16* %p) {
367 ; CHECK-LE-LABEL: vec_xl_sext_h:
368 ; CHECK-LE: # %bb.0: # %entry
369 ; CHECK-LE-NEXT: sldi r3, r3, 1
370 ; CHECK-LE-NEXT: lhax r3, r4, r3
371 ; CHECK-LE-NEXT: sradi r4, r3, 63
372 ; CHECK-LE-NEXT: mtvsrdd v2, r4, r3
375 ; CHECK-BE-LABEL: vec_xl_sext_h:
376 ; CHECK-BE: # %bb.0: # %entry
377 ; CHECK-BE-NEXT: sldi r3, r3, 1
378 ; CHECK-BE-NEXT: lhax r3, r4, r3
379 ; CHECK-BE-NEXT: sradi r4, r3, 63
380 ; CHECK-BE-NEXT: mtvsrdd v2, r4, r3
383 ; CHECK-O0-LABEL: vec_xl_sext_h:
384 ; CHECK-O0: # %bb.0: # %entry
385 ; CHECK-O0-NEXT: sldi r3, r3, 1
386 ; CHECK-O0-NEXT: lhax r4, r4, r3
387 ; CHECK-O0-NEXT: sradi r3, r4, 63
388 ; CHECK-O0-NEXT: mtvsrdd v2, r3, r4
391 %add.ptr = getelementptr inbounds i16, i16* %p, i64 %offset
392 %0 = load i16, i16* %add.ptr, align 2
393 %conv = sext i16 %0 to i128
394 %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
395 ret <1 x i128> %splat.splatinsert
398 define dso_local <1 x i128> @vec_xl_sext_w(i64 %offset, i32* %p) {
399 ; CHECK-LE-LABEL: vec_xl_sext_w:
400 ; CHECK-LE: # %bb.0: # %entry
401 ; CHECK-LE-NEXT: sldi r3, r3, 2
402 ; CHECK-LE-NEXT: lwax r3, r4, r3
403 ; CHECK-LE-NEXT: sradi r4, r3, 63
404 ; CHECK-LE-NEXT: mtvsrdd v2, r4, r3
407 ; CHECK-BE-LABEL: vec_xl_sext_w:
408 ; CHECK-BE: # %bb.0: # %entry
409 ; CHECK-BE-NEXT: sldi r3, r3, 2
410 ; CHECK-BE-NEXT: lwax r3, r4, r3
411 ; CHECK-BE-NEXT: sradi r4, r3, 63
412 ; CHECK-BE-NEXT: mtvsrdd v2, r4, r3
415 ; CHECK-O0-LABEL: vec_xl_sext_w:
416 ; CHECK-O0: # %bb.0: # %entry
417 ; CHECK-O0-NEXT: sldi r3, r3, 2
418 ; CHECK-O0-NEXT: lwax r4, r4, r3
419 ; CHECK-O0-NEXT: sradi r3, r4, 63
420 ; CHECK-O0-NEXT: mtvsrdd v2, r3, r4
423 %add.ptr = getelementptr inbounds i32, i32* %p, i64 %offset
424 %0 = load i32, i32* %add.ptr, align 4
425 %conv = sext i32 %0 to i128
426 %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
427 ret <1 x i128> %splat.splatinsert
430 define dso_local <1 x i128> @vec_xl_sext_d(i64 %offset, i64* %p) {
431 ; CHECK-LE-LABEL: vec_xl_sext_d:
432 ; CHECK-LE: # %bb.0: # %entry
433 ; CHECK-LE-NEXT: sldi r3, r3, 3
434 ; CHECK-LE-NEXT: ldx r3, r4, r3
435 ; CHECK-LE-NEXT: sradi r4, r3, 63
436 ; CHECK-LE-NEXT: mtvsrdd v2, r4, r3
439 ; CHECK-BE-LABEL: vec_xl_sext_d:
440 ; CHECK-BE: # %bb.0: # %entry
441 ; CHECK-BE-NEXT: sldi r3, r3, 3
442 ; CHECK-BE-NEXT: ldx r3, r4, r3
443 ; CHECK-BE-NEXT: sradi r4, r3, 63
444 ; CHECK-BE-NEXT: mtvsrdd v2, r4, r3
447 ; CHECK-O0-LABEL: vec_xl_sext_d:
448 ; CHECK-O0: # %bb.0: # %entry
449 ; CHECK-O0-NEXT: sldi r3, r3, 3
450 ; CHECK-O0-NEXT: ldx r4, r4, r3
451 ; CHECK-O0-NEXT: sradi r3, r4, 63
452 ; CHECK-O0-NEXT: mtvsrdd v2, r3, r4
455 %add.ptr = getelementptr inbounds i64, i64* %p, i64 %offset
456 %0 = load i64, i64* %add.ptr, align 8
457 %conv = sext i64 %0 to i128
458 %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
459 ret <1 x i128> %splat.splatinsert