diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -117,11 +117,12 @@ case ISD::INSERT_VECTOR_ELT: Res = PromoteIntRes_INSERT_VECTOR_ELT(N); break; case ISD::BUILD_VECTOR: - Res = PromoteIntRes_BUILD_VECTOR(N); break; - case ISD::SCALAR_TO_VECTOR: - Res = PromoteIntRes_SCALAR_TO_VECTOR(N); break; + Res = PromoteIntRes_BUILD_VECTOR(N); + break; case ISD::SPLAT_VECTOR: - Res = PromoteIntRes_SPLAT_VECTOR(N); break; + case ISD::SCALAR_TO_VECTOR: + Res = PromoteIntRes_ScalarOp(N); + break; case ISD::STEP_VECTOR: Res = PromoteIntRes_STEP_VECTOR(N); break; case ISD::CONCAT_VECTORS: Res = PromoteIntRes_CONCAT_VECTORS(N); break; @@ -1634,11 +1635,12 @@ case ISD::CONCAT_VECTORS: Res = PromoteIntOp_CONCAT_VECTORS(N); break; case ISD::EXTRACT_VECTOR_ELT: Res = PromoteIntOp_EXTRACT_VECTOR_ELT(N); break; case ISD::INSERT_VECTOR_ELT: - Res = PromoteIntOp_INSERT_VECTOR_ELT(N, OpNo);break; - case ISD::SCALAR_TO_VECTOR: - Res = PromoteIntOp_SCALAR_TO_VECTOR(N); break; + Res = PromoteIntOp_INSERT_VECTOR_ELT(N, OpNo); + break; case ISD::SPLAT_VECTOR: - Res = PromoteIntOp_SPLAT_VECTOR(N); break; + case ISD::SCALAR_TO_VECTOR: + Res = PromoteIntOp_ScalarOp(N); + break; case ISD::VSELECT: case ISD::SELECT: Res = PromoteIntOp_SELECT(N, OpNo); break; case ISD::SELECT_CC: Res = PromoteIntOp_SELECT_CC(N, OpNo); break; @@ -1911,20 +1913,13 @@ N->getOperand(1), Idx), 0); } -SDValue DAGTypeLegalizer::PromoteIntOp_SCALAR_TO_VECTOR(SDNode *N) { - // Integer SCALAR_TO_VECTOR operands are implicitly truncated, so just promote - // the operand in place. +SDValue DAGTypeLegalizer::PromoteIntOp_ScalarOp(SDNode *N) { + // Integer SPLAT_VECTOR/SCALAR_TO_VECTOR operands are implicitly truncated, + // so just promote the operand in place. return SDValue(DAG.UpdateNodeOperands(N, GetPromotedInteger(N->getOperand(0))), 0); } -SDValue DAGTypeLegalizer::PromoteIntOp_SPLAT_VECTOR(SDNode *N) { - // Integer SPLAT_VECTOR operands are implicitly truncated, so just promote the - // operand in place. - return SDValue( - DAG.UpdateNodeOperands(N, GetPromotedInteger(N->getOperand(0))), 0); -} - SDValue DAGTypeLegalizer::PromoteIntOp_SELECT(SDNode *N, unsigned OpNo) { assert(OpNo == 0 && "Only know how to promote the condition!"); SDValue Cond = N->getOperand(0); @@ -5239,7 +5234,7 @@ return DAG.getBuildVector(NOutVT, dl, Ops); } -SDValue DAGTypeLegalizer::PromoteIntRes_SCALAR_TO_VECTOR(SDNode *N) { +SDValue DAGTypeLegalizer::PromoteIntRes_ScalarOp(SDNode *N) { SDLoc dl(N); @@ -5249,28 +5244,11 @@ 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 NOutVTElem = NOutVT.getVectorElementType(); - - SDValue Op = DAG.getNode(ISD::ANY_EXTEND, dl, NOutVTElem, N->getOperand(0)); - - return DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, NOutVT, Op); -} - -SDValue DAGTypeLegalizer::PromoteIntRes_SPLAT_VECTOR(SDNode *N) { - SDLoc dl(N); - - SDValue SplatVal = N->getOperand(0); - - assert(!SplatVal.getValueType().isVector() && "Input must be a scalar"); - - EVT OutVT = N->getValueType(0); - EVT NOutVT = TLI.getTypeToTransformTo(*DAG.getContext(), OutVT); - assert(NOutVT.isVector() && "Type must be promoted to a vector type"); EVT NOutElemVT = NOutVT.getVectorElementType(); - SDValue Op = DAG.getNode(ISD::ANY_EXTEND, dl, NOutElemVT, SplatVal); + SDValue Op = DAG.getNode(ISD::ANY_EXTEND, dl, NOutElemVT, N->getOperand(0)); - return DAG.getNode(ISD::SPLAT_VECTOR, dl, NOutVT, Op); + return DAG.getNode(N->getOpcode(), dl, NOutVT, Op); } SDValue DAGTypeLegalizer::PromoteIntRes_STEP_VECTOR(SDNode *N) { diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h @@ -308,8 +308,7 @@ SDValue PromoteIntRes_VECTOR_SHUFFLE(SDNode *N); SDValue PromoteIntRes_VECTOR_SPLICE(SDNode *N); SDValue PromoteIntRes_BUILD_VECTOR(SDNode *N); - SDValue PromoteIntRes_SCALAR_TO_VECTOR(SDNode *N); - SDValue PromoteIntRes_SPLAT_VECTOR(SDNode *N); + SDValue PromoteIntRes_ScalarOp(SDNode *N); SDValue PromoteIntRes_STEP_VECTOR(SDNode *N); SDValue PromoteIntRes_EXTEND_VECTOR_INREG(SDNode *N); SDValue PromoteIntRes_INSERT_VECTOR_ELT(SDNode *N); @@ -377,8 +376,7 @@ SDValue PromoteIntOp_EXTRACT_SUBVECTOR(SDNode *N); SDValue PromoteIntOp_INSERT_SUBVECTOR(SDNode *N); SDValue PromoteIntOp_CONCAT_VECTORS(SDNode *N); - SDValue PromoteIntOp_SCALAR_TO_VECTOR(SDNode *N); - SDValue PromoteIntOp_SPLAT_VECTOR(SDNode *N); + SDValue PromoteIntOp_ScalarOp(SDNode *N); SDValue PromoteIntOp_SELECT(SDNode *N, unsigned OpNo); SDValue PromoteIntOp_SELECT_CC(SDNode *N, unsigned OpNo); SDValue PromoteIntOp_SETCC(SDNode *N, unsigned OpNo);