@@ -56379,6 +56379,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5637956379 SDValue Index = GorS->getIndex();
5638056380 SDValue Base = GorS->getBasePtr();
5638156381 SDValue Scale = GorS->getScale();
56382+ EVT IndexVT = Index.getValueType();
5638256383 const TargetLowering &TLI = DAG.getTargetLoweringInfo();
5638356384
5638456385 if (DCI.isBeforeLegalize()) {
@@ -56394,7 +56395,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5639456395 if (auto *BV = dyn_cast<BuildVectorSDNode>(Index)) {
5639556396 if (BV->isConstant() && IndexWidth > 32 &&
5639656397 DAG.ComputeNumSignBits(Index) > (IndexWidth - 32)) {
56397- EVT NewVT = Index.getValueType() .changeVectorElementType(MVT::i32);
56398+ EVT NewVT = IndexVT .changeVectorElementType(MVT::i32);
5639856399 Index = DAG.getNode(ISD::TRUNCATE, DL, NewVT, Index);
5639956400 return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
5640056401 }
@@ -56408,7 +56409,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5640856409 IndexWidth > 32 &&
5640956410 Index.getOperand(0).getScalarValueSizeInBits() <= 32 &&
5641056411 DAG.ComputeNumSignBits(Index) > (IndexWidth - 32)) {
56411- EVT NewVT = Index.getValueType() .changeVectorElementType(MVT::i32);
56412+ EVT NewVT = IndexVT .changeVectorElementType(MVT::i32);
5641256413 Index = DAG.getNode(ISD::TRUNCATE, DL, NewVT, Index);
5641356414 return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
5641456415 }
@@ -56420,8 +56421,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5642056421 // this when index element type is the same as the pointer type.
5642156422 // Otherwise we need to be sure the math doesn't wrap before the scale.
5642256423 if (Index.getOpcode() == ISD::ADD &&
56423- Index.getValueType().getVectorElementType() == PtrVT &&
56424- isa<ConstantSDNode>(Scale)) {
56424+ IndexVT.getVectorElementType() == PtrVT && isa<ConstantSDNode>(Scale)) {
5642556425 uint64_t ScaleAmt = Scale->getAsZExtVal();
5642656426 if (auto *BV = dyn_cast<BuildVectorSDNode>(Index.getOperand(1))) {
5642756427 BitVector UndefElts;
@@ -56442,13 +56442,11 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5644256442 // replace it with 0 and move the displacement into the index.
5644356443 if (BV->isConstant() && isa<ConstantSDNode>(Base) &&
5644456444 isOneConstant(Scale)) {
56445- SDValue Splat = DAG.getSplatBuildVector(Index.getValueType() , DL, Base);
56445+ SDValue Splat = DAG.getSplatBuildVector(IndexVT , DL, Base);
5644656446 // Combine the constant build_vector and the constant base.
56447- Splat = DAG.getNode(ISD::ADD, DL, Index.getValueType(),
56448- Index.getOperand(1), Splat);
56447+ Splat = DAG.getNode(ISD::ADD, DL, IndexVT, Index.getOperand(1), Splat);
5644956448 // Add to the LHS of the original Index add.
56450- Index = DAG.getNode(ISD::ADD, DL, Index.getValueType(),
56451- Index.getOperand(0), Splat);
56449+ Index = DAG.getNode(ISD::ADD, DL, IndexVT, Index.getOperand(0), Splat);
5645256450 Base = DAG.getConstant(0, DL, Base.getValueType());
5645356451 return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
5645456452 }
@@ -56461,7 +56459,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5646156459 // Make sure the index is either i32 or i64
5646256460 if (IndexWidth != 32 && IndexWidth != 64) {
5646356461 MVT EltVT = IndexWidth > 32 ? MVT::i64 : MVT::i32;
56464- EVT IndexVT = Index.getValueType() .changeVectorElementType(EltVT);
56462+ IndexVT = IndexVT .changeVectorElementType(EltVT);
5646556463 Index = DAG.getSExtOrTrunc(Index, DL, IndexVT);
5646656464 return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
5646756465 }
0 commit comments