mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:40:38 +00:00
[X86][SSE] getFauxShuffleMask - peek through TRUNCATE/AEXT/ZEXT for INSERT_VECTOR_ELT(EXTRACT_VECTOR_ELT())
As long we extract from a source vector with smaller elements and we zero-extend the element in the final shuffle mask then we can safely peek through truncations and any/zero-extensions to find the source extraction.
This commit is contained in:
parent
e127891baf
commit
2950a4b04b
@ -7417,15 +7417,20 @@ static bool getFauxShuffleMask(SDValue N, const APInt &DemandedElts,
|
||||
}
|
||||
}
|
||||
|
||||
// Peek through trunc/aext/zext.
|
||||
// TODO: aext shouldn't require SM_SentinelZero padding.
|
||||
// TODO: handle shift of scalars.
|
||||
while (Scl.getOpcode() == ISD::TRUNCATE ||
|
||||
Scl.getOpcode() == ISD::ANY_EXTEND ||
|
||||
Scl.getOpcode() == ISD::ZERO_EXTEND)
|
||||
Scl = Scl.getOperand(0);
|
||||
|
||||
// Attempt to find the source vector the scalar was extracted from.
|
||||
// TODO: Handle truncate/zext/shift of scalars.
|
||||
SDValue SrcExtract;
|
||||
if ((Scl.getOpcode() == ISD::EXTRACT_VECTOR_ELT &&
|
||||
Scl.getOperand(0).getValueType() == VT) ||
|
||||
(Scl.getOpcode() == X86ISD::PEXTRW &&
|
||||
Scl.getOperand(0).getValueType() == MVT::v8i16) ||
|
||||
(Scl.getOpcode() == X86ISD::PEXTRB &&
|
||||
Scl.getOperand(0).getValueType() == MVT::v16i8)) {
|
||||
if ((Scl.getOpcode() == ISD::EXTRACT_VECTOR_ELT ||
|
||||
Scl.getOpcode() == X86ISD::PEXTRW ||
|
||||
Scl.getOpcode() == X86ISD::PEXTRB) &&
|
||||
Scl.getOperand(0).getValueSizeInBits() == NumSizeInBits) {
|
||||
SrcExtract = Scl;
|
||||
}
|
||||
if (!SrcExtract || !isa<ConstantSDNode>(SrcExtract.getOperand(1)))
|
||||
@ -7437,8 +7442,7 @@ static bool getFauxShuffleMask(SDValue N, const APInt &DemandedElts,
|
||||
unsigned NumZeros =
|
||||
std::max<int>((NumBitsPerElt / SrcVT.getScalarSizeInBits()) - 1, 0);
|
||||
|
||||
if (SrcVT.getSizeInBits() != VT.getSizeInBits() ||
|
||||
(NumSrcElts % NumElts) != 0)
|
||||
if ((NumSrcElts % NumElts) != 0)
|
||||
return false;
|
||||
|
||||
unsigned SrcIdx = SrcExtract.getConstantOperandVal(1);
|
||||
|
@ -293,24 +293,19 @@ define <2 x i64> @extract2_i32_zext_insert1_i64_undef(<4 x i32> %x) {
|
||||
define <2 x i64> @extract2_i32_zext_insert1_i64_zero(<4 x i32> %x) {
|
||||
; SSE2-LABEL: extract2_i32_zext_insert1_i64_zero:
|
||||
; SSE2: # %bb.0:
|
||||
; SSE2-NEXT: pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
|
||||
; SSE2-NEXT: movd %xmm0, %eax
|
||||
; SSE2-NEXT: movq %rax, %xmm0
|
||||
; SSE2-NEXT: pslldq {{.*#+}} xmm0 = zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3,4,5,6,7]
|
||||
; SSE2-NEXT: andps {{.*}}(%rip), %xmm0
|
||||
; SSE2-NEXT: retq
|
||||
;
|
||||
; SSE41-LABEL: extract2_i32_zext_insert1_i64_zero:
|
||||
; SSE41: # %bb.0:
|
||||
; SSE41-NEXT: extractps $2, %xmm0, %eax
|
||||
; SSE41-NEXT: movq %rax, %xmm0
|
||||
; SSE41-NEXT: pslldq {{.*#+}} xmm0 = zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3,4,5,6,7]
|
||||
; SSE41-NEXT: xorps %xmm1, %xmm1
|
||||
; SSE41-NEXT: blendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2],xmm1[3]
|
||||
; SSE41-NEXT: retq
|
||||
;
|
||||
; AVX-LABEL: extract2_i32_zext_insert1_i64_zero:
|
||||
; AVX: # %bb.0:
|
||||
; AVX-NEXT: vextractps $2, %xmm0, %eax
|
||||
; AVX-NEXT: vmovq %rax, %xmm0
|
||||
; AVX-NEXT: vpslldq {{.*#+}} xmm0 = zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3,4,5,6,7]
|
||||
; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
|
||||
; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm1[0,1],xmm0[2],xmm1[3]
|
||||
; AVX-NEXT: retq
|
||||
%e = extractelement <4 x i32> %x, i32 2
|
||||
%z = zext i32 %e to i64
|
||||
@ -386,16 +381,22 @@ define <2 x i64> @extract0_i16_zext_insert0_i64_undef(<8 x i16> %x) {
|
||||
}
|
||||
|
||||
define <2 x i64> @extract0_i16_zext_insert0_i64_zero(<8 x i16> %x) {
|
||||
; SSE-LABEL: extract0_i16_zext_insert0_i64_zero:
|
||||
; SSE: # %bb.0:
|
||||
; SSE-NEXT: pextrw $0, %xmm0, %eax
|
||||
; SSE-NEXT: movd %eax, %xmm0
|
||||
; SSE-NEXT: retq
|
||||
; SSE2-LABEL: extract0_i16_zext_insert0_i64_zero:
|
||||
; SSE2: # %bb.0:
|
||||
; SSE2-NEXT: pextrw $0, %xmm0, %eax
|
||||
; SSE2-NEXT: movd %eax, %xmm0
|
||||
; SSE2-NEXT: retq
|
||||
;
|
||||
; SSE41-LABEL: extract0_i16_zext_insert0_i64_zero:
|
||||
; SSE41: # %bb.0:
|
||||
; SSE41-NEXT: pxor %xmm1, %xmm1
|
||||
; SSE41-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3,4,5,6,7]
|
||||
; SSE41-NEXT: retq
|
||||
;
|
||||
; AVX-LABEL: extract0_i16_zext_insert0_i64_zero:
|
||||
; AVX: # %bb.0:
|
||||
; AVX-NEXT: vpextrw $0, %xmm0, %eax
|
||||
; AVX-NEXT: vmovd %eax, %xmm0
|
||||
; AVX-NEXT: vpxor %xmm1, %xmm1, %xmm1
|
||||
; AVX-NEXT: vpblendw {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3,4,5,6,7]
|
||||
; AVX-NEXT: retq
|
||||
%e = extractelement <8 x i16> %x, i32 0
|
||||
%z = zext i16 %e to i64
|
||||
|
@ -21,10 +21,7 @@ define void @foo(<3 x float> %in, <4 x i8>* nocapture %out) nounwind {
|
||||
; SSE41-LABEL: foo:
|
||||
; SSE41: # %bb.0:
|
||||
; SSE41-NEXT: cvttps2dq %xmm0, %xmm0
|
||||
; SSE41-NEXT: pextrb $8, %xmm0, %eax
|
||||
; SSE41-NEXT: pextrb $4, %xmm0, %ecx
|
||||
; SSE41-NEXT: pinsrb $1, %ecx, %xmm0
|
||||
; SSE41-NEXT: pinsrb $2, %eax, %xmm0
|
||||
; SSE41-NEXT: pshufb {{.*#+}} xmm0 = xmm0[0,4,8,3,u,u,u,u,u,u,u,u,u,u,u,u]
|
||||
; SSE41-NEXT: movl $255, %eax
|
||||
; SSE41-NEXT: pinsrb $3, %eax, %xmm0
|
||||
; SSE41-NEXT: movd %xmm0, (%rdi)
|
||||
|
@ -8,10 +8,7 @@ define void @foo(<4 x float> %in, <4 x i8>* %out) {
|
||||
; SSE42-LABEL: foo:
|
||||
; SSE42: # %bb.0:
|
||||
; SSE42-NEXT: cvttps2dq %xmm0, %xmm0
|
||||
; SSE42-NEXT: pextrb $8, %xmm0, %eax
|
||||
; SSE42-NEXT: pextrb $4, %xmm0, %ecx
|
||||
; SSE42-NEXT: pinsrb $1, %ecx, %xmm0
|
||||
; SSE42-NEXT: pinsrb $2, %eax, %xmm0
|
||||
; SSE42-NEXT: pshufb {{.*#+}} xmm0 = xmm0[0,4,8,3,u,u,u,u,u,u,u,u,u,u,u,u]
|
||||
; SSE42-NEXT: movl $255, %eax
|
||||
; SSE42-NEXT: pinsrb $3, %eax, %xmm0
|
||||
; SSE42-NEXT: movd %xmm0, (%rdi)
|
||||
@ -20,10 +17,7 @@ define void @foo(<4 x float> %in, <4 x i8>* %out) {
|
||||
; AVX-LABEL: foo:
|
||||
; AVX: # %bb.0:
|
||||
; AVX-NEXT: vcvttps2dq %xmm0, %xmm0
|
||||
; AVX-NEXT: vpextrb $8, %xmm0, %eax
|
||||
; AVX-NEXT: vpextrb $4, %xmm0, %ecx
|
||||
; AVX-NEXT: vpinsrb $1, %ecx, %xmm0, %xmm0
|
||||
; AVX-NEXT: vpinsrb $2, %eax, %xmm0, %xmm0
|
||||
; AVX-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,4,8,3,u,u,u,u,u,u,u,u,u,u,u,u]
|
||||
; AVX-NEXT: movl $255, %eax
|
||||
; AVX-NEXT: vpinsrb $3, %eax, %xmm0, %xmm0
|
||||
; AVX-NEXT: vmovd %xmm0, (%rdi)
|
||||
|
Loading…
Reference in New Issue
Block a user