forked from OSchip/llvm-project
Vector shuffle mask elements may be "undef". Handle
this everywhere in LegalizeTypes. llvm-svn: 57783
This commit is contained in:
parent
c6d12bd665
commit
8d11adca4c
|
@ -156,8 +156,10 @@ SDValue DAGTypeLegalizer::ScalarizeVecRes_SELECT(SDNode *N) {
|
|||
|
||||
SDValue DAGTypeLegalizer::ScalarizeVecRes_VECTOR_SHUFFLE(SDNode *N) {
|
||||
// Figure out if the scalar is the LHS or RHS and return it.
|
||||
SDValue EltNum = N->getOperand(2).getOperand(0);
|
||||
unsigned Op = cast<ConstantSDNode>(EltNum)->getZExtValue() != 0;
|
||||
SDValue Arg = N->getOperand(2).getOperand(0);
|
||||
if (Arg.getOpcode() == ISD::UNDEF)
|
||||
return DAG.getNode(ISD::UNDEF, N->getValueType(0).getVectorElementType());
|
||||
unsigned Op = !cast<ConstantSDNode>(Arg)->isNullValue();
|
||||
return GetScalarizedVector(N->getOperand(Op));
|
||||
}
|
||||
|
||||
|
@ -562,6 +564,10 @@ void DAGTypeLegalizer::SplitVecRes_VECTOR_SHUFFLE(SDNode *N, SDValue &Lo,
|
|||
// buildvector of extractelement here because the input vectors will have
|
||||
// to be legalized, so this makes the code simpler.
|
||||
for (unsigned i = 0; i != LoNumElts; ++i) {
|
||||
SDValue Arg = Mask.getOperand(i);
|
||||
if (Arg.getOpcode() == ISD::UNDEF) {
|
||||
Ops.push_back(DAG.getNode(ISD::UNDEF, EltVT));
|
||||
} else {
|
||||
unsigned Idx = cast<ConstantSDNode>(Mask.getOperand(i))->getZExtValue();
|
||||
SDValue InVec = N->getOperand(0);
|
||||
if (Idx >= NumElements) {
|
||||
|
@ -571,6 +577,7 @@ void DAGTypeLegalizer::SplitVecRes_VECTOR_SHUFFLE(SDNode *N, SDValue &Lo,
|
|||
Ops.push_back(DAG.getNode(ISD::EXTRACT_VECTOR_ELT, EltVT, InVec,
|
||||
DAG.getIntPtrConstant(Idx)));
|
||||
}
|
||||
}
|
||||
Lo = DAG.getNode(ISD::BUILD_VECTOR, LoVT, &Ops[0], Ops.size());
|
||||
Ops.clear();
|
||||
|
||||
|
@ -802,10 +809,14 @@ SDValue DAGTypeLegalizer::SplitVecOp_VECTOR_SHUFFLE(SDNode *N, unsigned OpNo){
|
|||
// Success! Rebuild the vector using the legal types.
|
||||
SmallVector<SDValue, 16> Ops(MaskLength);
|
||||
for (unsigned i = 0; i < MaskLength; ++i) {
|
||||
uint64_t Idx =
|
||||
cast<ConstantSDNode>(Mask.getOperand(i))->getZExtValue();
|
||||
SDValue Arg = Mask.getOperand(i);
|
||||
if (Arg.getOpcode() == ISD::UNDEF) {
|
||||
Ops[i] = DAG.getNode(ISD::UNDEF, OpVT);
|
||||
} else {
|
||||
uint64_t Idx = cast<ConstantSDNode>(Arg)->getZExtValue();
|
||||
Ops[i] = DAG.getConstant(Idx, OpVT);
|
||||
}
|
||||
}
|
||||
return DAG.UpdateNodeOperands(SDValue(N,0),
|
||||
N->getOperand(0), N->getOperand(1),
|
||||
DAG.getNode(ISD::BUILD_VECTOR,
|
||||
|
|
Loading…
Reference in New Issue