forked from OSchip/llvm-project
[X86] Remove some code from combineShuffle that seems largely unnecessary with widening legalization.
The test case that changed is probably better served through allowing combineTruncatedArithmetic to create narrow vectors. It also appears InstCombine would have simplified this test case to remove the zext and trunc anyway. llvm-svn: 368522
This commit is contained in:
parent
96474d17c6
commit
0f74b82ef1
|
@ -33451,66 +33451,6 @@ static SDValue combineShuffle(SDNode *N, SelectionDAG &DAG,
|
|||
return HAddSub;
|
||||
}
|
||||
|
||||
// During Type Legalization, when promoting illegal vector types,
|
||||
// the backend might introduce new shuffle dag nodes and bitcasts.
|
||||
//
|
||||
// This code performs the following transformation:
|
||||
// fold: (shuffle (bitcast (BINOP A, B)), Undef, <Mask>) ->
|
||||
// (shuffle (BINOP (bitcast A), (bitcast B)), Undef, <Mask>)
|
||||
//
|
||||
// We do this only if both the bitcast and the BINOP dag nodes have
|
||||
// one use. Also, perform this transformation only if the new binary
|
||||
// operation is legal. This is to avoid introducing dag nodes that
|
||||
// potentially need to be further expanded (or custom lowered) into a
|
||||
// less optimal sequence of dag nodes.
|
||||
if (!DCI.isBeforeLegalize() && DCI.isBeforeLegalizeOps() &&
|
||||
N->getOpcode() == ISD::VECTOR_SHUFFLE &&
|
||||
N->getOperand(0).getOpcode() == ISD::BITCAST &&
|
||||
N->getOperand(1).isUndef() && N->getOperand(0).hasOneUse()) {
|
||||
SDValue N0 = N->getOperand(0);
|
||||
SDValue N1 = N->getOperand(1);
|
||||
|
||||
SDValue BC0 = N0.getOperand(0);
|
||||
EVT SVT = BC0.getValueType();
|
||||
unsigned Opcode = BC0.getOpcode();
|
||||
unsigned NumElts = VT.getVectorNumElements();
|
||||
|
||||
if (BC0.hasOneUse() && SVT.isVector() &&
|
||||
SVT.getVectorNumElements() * 2 == NumElts &&
|
||||
TLI.isOperationLegal(Opcode, VT)) {
|
||||
bool CanFold = false;
|
||||
switch (Opcode) {
|
||||
default : break;
|
||||
case ISD::ADD:
|
||||
case ISD::SUB:
|
||||
case ISD::MUL:
|
||||
// isOperationLegal lies for integer ops on floating point types.
|
||||
CanFold = VT.isInteger();
|
||||
break;
|
||||
case ISD::FADD:
|
||||
case ISD::FSUB:
|
||||
case ISD::FMUL:
|
||||
// isOperationLegal lies for floating point ops on integer types.
|
||||
CanFold = VT.isFloatingPoint();
|
||||
break;
|
||||
}
|
||||
|
||||
unsigned SVTNumElts = SVT.getVectorNumElements();
|
||||
ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N);
|
||||
for (unsigned i = 0, e = SVTNumElts; i != e && CanFold; ++i)
|
||||
CanFold = SVOp->getMaskElt(i) == (int)(i * 2);
|
||||
for (unsigned i = SVTNumElts, e = NumElts; i != e && CanFold; ++i)
|
||||
CanFold = SVOp->getMaskElt(i) < 0;
|
||||
|
||||
if (CanFold) {
|
||||
SDValue BC00 = DAG.getBitcast(VT, BC0.getOperand(0));
|
||||
SDValue BC01 = DAG.getBitcast(VT, BC0.getOperand(1));
|
||||
SDValue NewBinOp = DAG.getNode(BC0.getOpcode(), dl, VT, BC00, BC01);
|
||||
return DAG.getVectorShuffle(VT, dl, NewBinOp, N1, SVOp->getMask());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to combine into a vector load/broadcast.
|
||||
if (SDValue LD = combineToConsecutiveLoads(VT, N, dl, DAG, Subtarget, true))
|
||||
return LD;
|
||||
|
|
|
@ -63,8 +63,8 @@ define void @any_extend_load_v8i16(<8 x i8> * %ptr) {
|
|||
; KNL-LABEL: any_extend_load_v8i16:
|
||||
; KNL: # %bb.0:
|
||||
; KNL-NEXT: vpmovzxbw {{.*#+}} xmm0 = mem[0],zero,mem[1],zero,mem[2],zero,mem[3],zero,mem[4],zero,mem[5],zero,mem[6],zero,mem[7],zero
|
||||
; KNL-NEXT: vpaddb {{.*}}(%rip), %xmm0, %xmm0
|
||||
; KNL-NEXT: vpackuswb %xmm0, %xmm0, %xmm0
|
||||
; KNL-NEXT: vpaddw {{.*}}(%rip), %xmm0, %xmm0
|
||||
; KNL-NEXT: vpshufb {{.*#+}} xmm0 = xmm0[0,2,4,6,8,10,12,14,u,u,u,u,u,u,u,u]
|
||||
; KNL-NEXT: vmovq %xmm0, (%rdi)
|
||||
; KNL-NEXT: retq
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue