Skip to content

Commit 8a25154

Browse files
committed
[X86] SimplifyDemandedVectorElts - add X86ISD::VPERMV mask support
llvm-svn: 358174
1 parent b237b54 commit 8a25154

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33225,6 +33225,14 @@ bool X86TargetLowering::SimplifyDemandedVectorEltsForTargetNode(
3322533225
}
3322633226
break;
3322733227
}
33228+
case X86ISD::VPERMV: {
33229+
SDValue Mask = Op.getOperand(0);
33230+
APInt MaskUndef, MaskZero;
33231+
if (SimplifyDemandedVectorElts(Mask, DemandedElts, MaskUndef, MaskZero, TLO,
33232+
Depth + 1))
33233+
return true;
33234+
break;
33235+
}
3322833236
case X86ISD::PSHUFB:
3322933237
case X86ISD::VPERMILPV: {
3323033238
// TODO - simplify other variable shuffle masks.

llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -343,21 +343,10 @@ define <8 x float> @combine_permps_as_permpd(<8 x float> %a) {
343343
}
344344

345345
define <8 x float> @combine_permps_as_vpermilps(<8 x float> %a, i32 %a1) {
346-
; X86-LABEL: combine_permps_as_vpermilps:
347-
; X86: # %bb.0:
348-
; X86-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero
349-
; X86-NEXT: vblendps {{.*#+}} ymm1 = ymm1[0],mem[1,2,3,4,5,6,7]
350-
; X86-NEXT: vpermps %ymm0, %ymm1, %ymm0
351-
; X86-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[1,1,2,3,4,5,6,7]
352-
; X86-NEXT: retl
353-
;
354-
; X64-LABEL: combine_permps_as_vpermilps:
355-
; X64: # %bb.0:
356-
; X64-NEXT: vmovd %edi, %xmm1
357-
; X64-NEXT: vpblendd {{.*#+}} ymm1 = ymm1[0],mem[1,2,3,4,5,6,7]
358-
; X64-NEXT: vpermd %ymm0, %ymm1, %ymm0
359-
; X64-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[1,1,2,3,4,5,6,7]
360-
; X64-NEXT: retq
346+
; CHECK-LABEL: combine_permps_as_vpermilps:
347+
; CHECK: # %bb.0:
348+
; CHECK-NEXT: vpermilps {{.*#+}} ymm0 = ymm0[2,2,1,0,7,6,5,4]
349+
; CHECK-NEXT: ret{{[l|q]}}
361350
%1 = insertelement <8 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4>, i32 %a1, i32 0
362351
%2 = call <8 x float> @llvm.x86.avx2.permps(<8 x float> %a, <8 x i32> %1)
363352
%3 = shufflevector <8 x float> %2, <8 x float> undef, <8 x i32> <i32 1, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>

0 commit comments

Comments
 (0)