Skip to content

Commit 1b07bd9

Browse files
committed
[X86] Add tests for vector widening with freeze(undef)
As noted on D103874, the 'no-op' vector widening intrinsics currently depend on undef shuffle mask indices, moving to poison we need to adjust this to reference a 'undefined' second vector operand, which will be a freeze(undef).
1 parent 9add949 commit 1b07bd9

File tree

4 files changed

+204
-0
lines changed

4 files changed

+204
-0
lines changed

llvm/test/CodeGen/X86/avx-intrinsics-fast-isel.ll

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ define <4 x double> @test_mm256_castpd128_pd256(<2 x double> %a0) nounwind {
254254
ret <4 x double> %res
255255
}
256256

257+
define <4 x double> @test_mm256_castpd128_pd256_freeze(<2 x double> %a0) nounwind {
258+
; CHECK-LABEL: test_mm256_castpd128_pd256_freeze:
259+
; CHECK: # %bb.0:
260+
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
261+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
262+
; CHECK-NEXT: ret{{[l|q]}}
263+
%a1 = freeze <2 x double> undef
264+
%res = shufflevector <2 x double> %a0, <2 x double> %a1, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
265+
ret <4 x double> %res
266+
}
267+
257268
define <2 x double> @test_mm256_castpd256_pd128(<4 x double> %a0) nounwind {
258269
; CHECK-LABEL: test_mm256_castpd256_pd128:
259270
; CHECK: # %bb.0:
@@ -289,6 +300,17 @@ define <8 x float> @test_mm256_castps128_ps256(<4 x float> %a0) nounwind {
289300
ret <8 x float> %res
290301
}
291302

303+
define <8 x float> @test_mm256_castps128_ps256_freeze(<4 x float> %a0) nounwind {
304+
; CHECK-LABEL: test_mm256_castps128_ps256_freeze:
305+
; CHECK: # %bb.0:
306+
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
307+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
308+
; CHECK-NEXT: ret{{[l|q]}}
309+
%a1 = freeze <4 x float> undef
310+
%res = shufflevector <4 x float> %a0, <4 x float> %a1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
311+
ret <8 x float> %res
312+
}
313+
292314
define <4 x float> @test_mm256_castps256_ps128(<8 x float> %a0) nounwind {
293315
; CHECK-LABEL: test_mm256_castps256_ps128:
294316
; CHECK: # %bb.0:
@@ -308,6 +330,17 @@ define <4 x i64> @test_mm256_castsi128_si256(<2 x i64> %a0) nounwind {
308330
ret <4 x i64> %res
309331
}
310332

333+
define <4 x i64> @test_mm256_castsi128_si256_freeze(<2 x i64> %a0) nounwind {
334+
; CHECK-LABEL: test_mm256_castsi128_si256_freeze:
335+
; CHECK: # %bb.0:
336+
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
337+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
338+
; CHECK-NEXT: ret{{[l|q]}}
339+
%a1 = freeze <2 x i64> undef
340+
%res = shufflevector <2 x i64> %a0, <2 x i64> %a1, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
341+
ret <4 x i64> %res
342+
}
343+
311344
define <4 x double> @test_mm256_castsi256_pd(<4 x i64> %a0) nounwind {
312345
; CHECK-LABEL: test_mm256_castsi256_pd:
313346
; CHECK: # %bb.0:

llvm/test/CodeGen/X86/avx-intrinsics-x86.ll

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,3 +1030,57 @@ define <2 x i64> @test_x86_pclmulqdq(<2 x i64> %a0, <2 x i64> %a1) {
10301030
ret <2 x i64> %res
10311031
}
10321032
declare <2 x i64> @llvm.x86.pclmulqdq(<2 x i64>, <2 x i64>, i8) nounwind readnone
1033+
1034+
1035+
define <4 x double> @test_mm256_castpd128_pd256_freeze(<2 x double> %a0) nounwind {
1036+
; AVX-LABEL: test_mm256_castpd128_pd256_freeze:
1037+
; AVX: # %bb.0:
1038+
; AVX-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
1039+
; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0 # encoding: [0xc4,0xe3,0x7d,0x18,0xc0,0x01]
1040+
; AVX-NEXT: ret{{[l|q]}} # encoding: [0xc3]
1041+
;
1042+
; AVX512VL-LABEL: test_mm256_castpd128_pd256_freeze:
1043+
; AVX512VL: # %bb.0:
1044+
; AVX512VL-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
1045+
; AVX512VL-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0 # EVEX TO VEX Compression encoding: [0xc4,0xe3,0x7d,0x18,0xc0,0x01]
1046+
; AVX512VL-NEXT: ret{{[l|q]}} # encoding: [0xc3]
1047+
%a1 = freeze <2 x double> undef
1048+
%res = shufflevector <2 x double> %a0, <2 x double> %a1, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
1049+
ret <4 x double> %res
1050+
}
1051+
1052+
1053+
define <8 x float> @test_mm256_castps128_ps256_freeze(<4 x float> %a0) nounwind {
1054+
; AVX-LABEL: test_mm256_castps128_ps256_freeze:
1055+
; AVX: # %bb.0:
1056+
; AVX-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
1057+
; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0 # encoding: [0xc4,0xe3,0x7d,0x18,0xc0,0x01]
1058+
; AVX-NEXT: ret{{[l|q]}} # encoding: [0xc3]
1059+
;
1060+
; AVX512VL-LABEL: test_mm256_castps128_ps256_freeze:
1061+
; AVX512VL: # %bb.0:
1062+
; AVX512VL-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
1063+
; AVX512VL-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0 # EVEX TO VEX Compression encoding: [0xc4,0xe3,0x7d,0x18,0xc0,0x01]
1064+
; AVX512VL-NEXT: ret{{[l|q]}} # encoding: [0xc3]
1065+
%a1 = freeze <4 x float> undef
1066+
%res = shufflevector <4 x float> %a0, <4 x float> %a1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
1067+
ret <8 x float> %res
1068+
}
1069+
1070+
1071+
define <4 x i64> @test_mm256_castsi128_si256_freeze(<2 x i64> %a0) nounwind {
1072+
; AVX-LABEL: test_mm256_castsi128_si256_freeze:
1073+
; AVX: # %bb.0:
1074+
; AVX-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
1075+
; AVX-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0 # encoding: [0xc4,0xe3,0x7d,0x18,0xc0,0x01]
1076+
; AVX-NEXT: ret{{[l|q]}} # encoding: [0xc3]
1077+
;
1078+
; AVX512VL-LABEL: test_mm256_castsi128_si256_freeze:
1079+
; AVX512VL: # %bb.0:
1080+
; AVX512VL-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
1081+
; AVX512VL-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0 # EVEX TO VEX Compression encoding: [0xc4,0xe3,0x7d,0x18,0xc0,0x01]
1082+
; AVX512VL-NEXT: ret{{[l|q]}} # encoding: [0xc3]
1083+
%a1 = freeze <2 x i64> undef
1084+
%res = shufflevector <2 x i64> %a0, <2 x i64> %a1, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
1085+
ret <4 x i64> %res
1086+
}

llvm/test/CodeGen/X86/avx512-intrinsics.ll

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7492,6 +7492,85 @@ define <8 x i64> @test_x86_avx512_maskz_psrlv_q_512(<8 x i64> %a0, <8 x i64> %a1
74927492

74937493
declare <8 x i64> @llvm.x86.avx512.psrlv.q.512(<8 x i64>, <8 x i64>) nounwind readnone
74947494

7495+
7496+
define <8 x double> @test_mm256_castpd128_pd256_freeze(<2 x double> %a0) nounwind {
7497+
; CHECK-LABEL: test_mm256_castpd128_pd256_freeze:
7498+
; CHECK: # %bb.0:
7499+
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
7500+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm1
7501+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
7502+
; CHECK-NEXT: vinsertf64x4 $1, %ymm1, %zmm0, %zmm0
7503+
; CHECK-NEXT: ret{{[l|q]}}
7504+
%a1 = freeze <2 x double> undef
7505+
%res = shufflevector <2 x double> %a0, <2 x double> %a1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 2, i32 3, i32 2, i32 3>
7506+
ret <8 x double> %res
7507+
}
7508+
7509+
7510+
define <8 x double> @test_mm256_castpd256_pd256_freeze(<4 x double> %a0) nounwind {
7511+
; CHECK-LABEL: test_mm256_castpd256_pd256_freeze:
7512+
; CHECK: # %bb.0:
7513+
; CHECK-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
7514+
; CHECK-NEXT: vinsertf64x4 $1, %ymm0, %zmm0, %zmm0
7515+
; CHECK-NEXT: ret{{[l|q]}}
7516+
%a1 = freeze <4 x double> undef
7517+
%res = shufflevector <4 x double> %a0, <4 x double> %a1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
7518+
ret <8 x double> %res
7519+
}
7520+
7521+
7522+
define <16 x float> @test_mm256_castps128_ps512_freeze(<4 x float> %a0) nounwind {
7523+
; CHECK-LABEL: test_mm256_castps128_ps512_freeze:
7524+
; CHECK: # %bb.0:
7525+
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
7526+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm1
7527+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
7528+
; CHECK-NEXT: vinsertf64x4 $1, %ymm1, %zmm0, %zmm0
7529+
; CHECK-NEXT: ret{{[l|q]}}
7530+
%a1 = freeze <4 x float> undef
7531+
%res = shufflevector <4 x float> %a0, <4 x float> %a1, <16x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 4, i32 5, i32 6, i32 7, i32 4, i32 5, i32 6, i32 7>
7532+
ret <16 x float> %res
7533+
}
7534+
7535+
7536+
define <16 x float> @test_mm256_castps256_ps512_freeze(<8 x float> %a0) nounwind {
7537+
; CHECK-LABEL: test_mm256_castps256_ps512_freeze:
7538+
; CHECK: # %bb.0:
7539+
; CHECK-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
7540+
; CHECK-NEXT: vinsertf64x4 $1, %ymm0, %zmm0, %zmm0
7541+
; CHECK-NEXT: ret{{[l|q]}}
7542+
%a1 = freeze <8 x float> undef
7543+
%res = shufflevector <8 x float> %a0, <8 x float> %a1, <16x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
7544+
ret <16 x float> %res
7545+
}
7546+
7547+
7548+
define <8 x i64> @test_mm512_castsi128_si512_freeze(<2 x i64> %a0) nounwind {
7549+
; CHECK-LABEL: test_mm512_castsi128_si512_freeze:
7550+
; CHECK: # %bb.0:
7551+
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
7552+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm1
7553+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
7554+
; CHECK-NEXT: vinsertf64x4 $1, %ymm1, %zmm0, %zmm0
7555+
; CHECK-NEXT: ret{{[l|q]}}
7556+
%a1 = freeze <2 x i64> undef
7557+
%res = shufflevector <2 x i64> %a0, <2 x i64> %a1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 2, i32 3, i32 2, i32 3>
7558+
ret <8 x i64> %res
7559+
}
7560+
7561+
7562+
define <8 x i64> @test_mm512_castsi256_si512_pd256_freeze(<4 x i64> %a0) nounwind {
7563+
; CHECK-LABEL: test_mm512_castsi256_si512_pd256_freeze:
7564+
; CHECK: # %bb.0:
7565+
; CHECK-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
7566+
; CHECK-NEXT: vinsertf64x4 $1, %ymm0, %zmm0, %zmm0
7567+
; CHECK-NEXT: ret{{[l|q]}}
7568+
%a1 = freeze <4 x i64> undef
7569+
%res = shufflevector <4 x i64> %a0, <4 x i64> %a1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
7570+
ret <8 x i64> %res
7571+
}
7572+
7573+
74957574
define <16 x float> @bad_mask_transition(<8 x double> %a, <8 x double> %b, <8 x double> %c, <8 x double> %d, <16 x float> %e, <16 x float> %f) {
74967575
; X64-LABEL: bad_mask_transition:
74977576
; X64: # %bb.0: # %entry

llvm/test/CodeGen/X86/avx512fp16-intrinsics.ll

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,3 +1215,41 @@ define <8 x half> @test_x86_avx512fp16_vcvtusi642sh(<8 x half> %arg0, i64 %arg1)
12151215
%res = fadd <8 x half> %res1, %res2
12161216
ret <8 x half> %res
12171217
}
1218+
1219+
1220+
define <16 x half> @test_mm256_castph128_ph256_freeze(<8 x half> %a0) nounwind {
1221+
; CHECK-LABEL: test_mm256_castph128_ph256_freeze:
1222+
; CHECK: # %bb.0:
1223+
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
1224+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
1225+
; CHECK-NEXT: retq
1226+
%a1 = freeze <8 x half> undef
1227+
%res = shufflevector <8 x half> %a0, <8 x half> %a1, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
1228+
ret <16 x half> %res
1229+
}
1230+
1231+
1232+
define <32 x half> @test_mm512_castph128_ph512_freeze(<8 x half> %a0) nounwind {
1233+
; CHECK-LABEL: test_mm512_castph128_ph512_freeze:
1234+
; CHECK: # %bb.0:
1235+
; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
1236+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm1
1237+
; CHECK-NEXT: vinsertf128 $1, %xmm0, %ymm0, %ymm0
1238+
; CHECK-NEXT: vinsertf64x4 $1, %ymm1, %zmm0, %zmm0
1239+
; CHECK-NEXT: retq
1240+
%a1 = freeze <8 x half> undef
1241+
%res = shufflevector <8 x half> %a0, <8 x half> %a1, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
1242+
ret <32 x half> %res
1243+
}
1244+
1245+
1246+
define <32 x half> @test_mm512_castph256_ph512_freeze(<16 x half> %a0) nounwind {
1247+
; CHECK-LABEL: test_mm512_castph256_ph512_freeze:
1248+
; CHECK: # %bb.0:
1249+
; CHECK-NEXT: # kill: def $ymm0 killed $ymm0 def $zmm0
1250+
; CHECK-NEXT: vinsertf64x4 $1, %ymm0, %zmm0, %zmm0
1251+
; CHECK-NEXT: retq
1252+
%a1 = freeze <16 x half> undef
1253+
%res = shufflevector <16 x half> %a0, <16 x half> %a1, <32 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
1254+
ret <32 x half> %res
1255+
}

0 commit comments

Comments
 (0)