@@ -58823,6 +58823,8 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5882358823
5882458824 uint64_t IdxVal = N->getConstantOperandVal(2);
5882558825 MVT SubVecVT = SubVec.getSimpleValueType();
58826+ int VecNumElts = OpVT.getVectorNumElements();
58827+ int SubVecNumElts = SubVecVT.getVectorNumElements();
5882658828
5882758829 if (Vec.isUndef() && SubVec.isUndef())
5882858830 return DAG.getUNDEF(OpVT);
@@ -58882,19 +58884,17 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5888258884 SubVec.getOperand(0).getSimpleValueType() == OpVT &&
5888358885 (IdxVal != 0 ||
5888458886 !(Vec.isUndef() || ISD::isBuildVectorAllZeros(Vec.getNode())))) {
58887+ SDValue ExtSrc = SubVec.getOperand(0);
5888558888 int ExtIdxVal = SubVec.getConstantOperandVal(1);
5888658889 if (ExtIdxVal != 0) {
58887- int VecNumElts = OpVT.getVectorNumElements();
58888- int SubVecNumElts = SubVecVT.getVectorNumElements();
5888958890 SmallVector<int, 64> Mask(VecNumElts);
5889058891 // First create an identity shuffle mask.
5889158892 for (int i = 0; i != VecNumElts; ++i)
5889258893 Mask[i] = i;
5889358894 // Now insert the extracted portion.
5889458895 for (int i = 0; i != SubVecNumElts; ++i)
5889558896 Mask[i + IdxVal] = i + ExtIdxVal + VecNumElts;
58896-
58897- return DAG.getVectorShuffle(OpVT, dl, Vec, SubVec.getOperand(0), Mask);
58897+ return DAG.getVectorShuffle(OpVT, dl, Vec, ExtSrc, Mask);
5889858898 }
5889958899 }
5890058900
@@ -58942,7 +58942,7 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
5894258942 // If we're splatting the lower half subvector of a full vector load into the
5894358943 // upper half, attempt to create a subvector broadcast.
5894458944 // TODO: Drop hasOneUse checks.
58945- if (IdxVal == (OpVT.getVectorNumElements() / 2) &&
58945+ if ((int) IdxVal == (VecNumElts / 2) &&
5894658946 Vec.getValueSizeInBits() == (2 * SubVec.getValueSizeInBits()) &&
5894758947 (Vec.hasOneUse() || SubVec.hasOneUse())) {
5894858948 auto *VecLd = dyn_cast<LoadSDNode>(Vec);
0 commit comments