@@ -58823,6 +58823,8 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
58823
58823
58824
58824
uint64_t IdxVal = N->getConstantOperandVal(2);
58825
58825
MVT SubVecVT = SubVec.getSimpleValueType();
58826
+ int VecNumElts = OpVT.getVectorNumElements();
58827
+ int SubVecNumElts = SubVecVT.getVectorNumElements();
58826
58828
58827
58829
if (Vec.isUndef() && SubVec.isUndef())
58828
58830
return DAG.getUNDEF(OpVT);
@@ -58882,19 +58884,17 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
58882
58884
SubVec.getOperand(0).getSimpleValueType() == OpVT &&
58883
58885
(IdxVal != 0 ||
58884
58886
!(Vec.isUndef() || ISD::isBuildVectorAllZeros(Vec.getNode())))) {
58887
+ SDValue ExtSrc = SubVec.getOperand(0);
58885
58888
int ExtIdxVal = SubVec.getConstantOperandVal(1);
58886
58889
if (ExtIdxVal != 0) {
58887
- int VecNumElts = OpVT.getVectorNumElements();
58888
- int SubVecNumElts = SubVecVT.getVectorNumElements();
58889
58890
SmallVector<int, 64> Mask(VecNumElts);
58890
58891
// First create an identity shuffle mask.
58891
58892
for (int i = 0; i != VecNumElts; ++i)
58892
58893
Mask[i] = i;
58893
58894
// Now insert the extracted portion.
58894
58895
for (int i = 0; i != SubVecNumElts; ++i)
58895
58896
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);
58898
58898
}
58899
58899
}
58900
58900
@@ -58942,7 +58942,7 @@ static SDValue combineINSERT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
58942
58942
// If we're splatting the lower half subvector of a full vector load into the
58943
58943
// upper half, attempt to create a subvector broadcast.
58944
58944
// TODO: Drop hasOneUse checks.
58945
- if (IdxVal == (OpVT.getVectorNumElements() / 2) &&
58945
+ if ((int) IdxVal == (VecNumElts / 2) &&
58946
58946
Vec.getValueSizeInBits() == (2 * SubVec.getValueSizeInBits()) &&
58947
58947
(Vec.hasOneUse() || SubVec.hasOneUse())) {
58948
58948
auto *VecLd = dyn_cast<LoadSDNode>(Vec);
0 commit comments