Vector-Select: Address one of the problems in pr10902. Add handling for the

integer-promotion of CONCAT_VECTORS.

Test: test/CodeGen/X86/widen_shuffle-1.ll

This patch fixes the above tests (when running in with -promote-elements).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140372 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nadav Rotem 2011-09-23 09:33:24 +00:00
parent 4da632e6e0
commit c56d65f63c
2 changed files with 43 additions and 0 deletions

View File

@ -86,6 +86,8 @@ void DAGTypeLegalizer::PromoteIntegerResult(SDNode *N, unsigned ResNo) {
Res = PromoteIntRes_BUILD_VECTOR(N); break; Res = PromoteIntRes_BUILD_VECTOR(N); break;
case ISD::SCALAR_TO_VECTOR: case ISD::SCALAR_TO_VECTOR:
Res = PromoteIntRes_SCALAR_TO_VECTOR(N); break; Res = PromoteIntRes_SCALAR_TO_VECTOR(N); break;
case ISD::CONCAT_VECTORS:
Res = PromoteIntRes_CONCAT_VECTORS(N); break;
case ISD::SIGN_EXTEND: case ISD::SIGN_EXTEND:
case ISD::ZERO_EXTEND: case ISD::ZERO_EXTEND:
@ -2916,6 +2918,46 @@ SDValue DAGTypeLegalizer::PromoteIntRes_SCALAR_TO_VECTOR(SDNode *N) {
return DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, NOutVT, Op); return DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, NOutVT, Op);
} }
SDValue DAGTypeLegalizer::PromoteIntRes_CONCAT_VECTORS(SDNode *N) {
DebugLoc dl = N->getDebugLoc();
SDValue Op0 = N->getOperand(1);
SDValue Op1 = N->getOperand(1);
assert(Op0.getValueType() == Op1.getValueType() &&
"Invalid input vector types");
EVT OutVT = N->getValueType(0);
EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);
assert(NOutVT.isVector() && "This type must be promoted to a vector type");
EVT OutElemTy = NOutVT.getVectorElementType();
unsigned NumElem0 = Op0.getValueType().getVectorNumElements();
unsigned NumElem1 = Op1.getValueType().getVectorNumElements();
unsigned NumOutElem = NOutVT.getVectorNumElements();
assert(NumElem0 + NumElem1 == NumOutElem &&
"Invalid number of incoming elements");
// Take the elements from the first vector.
SmallVector<SDValue, 8> Ops(NumOutElem);
for (unsigned i = 0; i < NumElem0; ++i) {
SDValue Ext = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
Op0.getValueType().getScalarType(), Op0,
DAG.getIntPtrConstant(i));
Ops[i] = DAG.getNode(ISD::ANY_EXTEND, dl, OutElemTy, Ext);
}
// Take the elements from the second vector
for (unsigned i = 0; i < NumElem1; ++i) {
SDValue Ext = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl,
Op1.getValueType().getScalarType(), Op1,
DAG.getIntPtrConstant(i));
Ops[i + NumElem0] = DAG.getNode(ISD::ANY_EXTEND, dl, OutElemTy, Ext);
}
return DAG.getNode(ISD::BUILD_VECTOR, dl, NOutVT, &Ops[0], Ops.size());
}
SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(SDNode *N) { SDValue DAGTypeLegalizer::PromoteIntRes_INSERT_VECTOR_ELT(SDNode *N) {
EVT OutVT = N->getValueType(0); EVT OutVT = N->getValueType(0);
EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT); EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT);

View File

@ -224,6 +224,7 @@ private:
SDValue PromoteIntRes_BUILD_VECTOR(SDNode *N); SDValue PromoteIntRes_BUILD_VECTOR(SDNode *N);
SDValue PromoteIntRes_SCALAR_TO_VECTOR(SDNode *N); SDValue PromoteIntRes_SCALAR_TO_VECTOR(SDNode *N);
SDValue PromoteIntRes_INSERT_VECTOR_ELT(SDNode *N); SDValue PromoteIntRes_INSERT_VECTOR_ELT(SDNode *N);
SDValue PromoteIntRes_CONCAT_VECTORS(SDNode *N);
SDValue PromoteIntRes_BITCAST(SDNode *N); SDValue PromoteIntRes_BITCAST(SDNode *N);
SDValue PromoteIntRes_BSWAP(SDNode *N); SDValue PromoteIntRes_BSWAP(SDNode *N);
SDValue PromoteIntRes_BUILD_PAIR(SDNode *N); SDValue PromoteIntRes_BUILD_PAIR(SDNode *N);