@@ -56379,6 +56379,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
56379
56379
SDValue Index = GorS->getIndex();
56380
56380
SDValue Base = GorS->getBasePtr();
56381
56381
SDValue Scale = GorS->getScale();
56382
+ EVT IndexVT = Index.getValueType();
56382
56383
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
56383
56384
56384
56385
if (DCI.isBeforeLegalize()) {
@@ -56394,7 +56395,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
56394
56395
if (auto *BV = dyn_cast<BuildVectorSDNode>(Index)) {
56395
56396
if (BV->isConstant() && IndexWidth > 32 &&
56396
56397
DAG.ComputeNumSignBits(Index) > (IndexWidth - 32)) {
56397
- EVT NewVT = Index.getValueType() .changeVectorElementType(MVT::i32);
56398
+ EVT NewVT = IndexVT .changeVectorElementType(MVT::i32);
56398
56399
Index = DAG.getNode(ISD::TRUNCATE, DL, NewVT, Index);
56399
56400
return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
56400
56401
}
@@ -56408,7 +56409,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
56408
56409
IndexWidth > 32 &&
56409
56410
Index.getOperand(0).getScalarValueSizeInBits() <= 32 &&
56410
56411
DAG.ComputeNumSignBits(Index) > (IndexWidth - 32)) {
56411
- EVT NewVT = Index.getValueType() .changeVectorElementType(MVT::i32);
56412
+ EVT NewVT = IndexVT .changeVectorElementType(MVT::i32);
56412
56413
Index = DAG.getNode(ISD::TRUNCATE, DL, NewVT, Index);
56413
56414
return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
56414
56415
}
@@ -56420,8 +56421,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
56420
56421
// this when index element type is the same as the pointer type.
56421
56422
// Otherwise we need to be sure the math doesn't wrap before the scale.
56422
56423
if (Index.getOpcode() == ISD::ADD &&
56423
- Index.getValueType().getVectorElementType() == PtrVT &&
56424
- isa<ConstantSDNode>(Scale)) {
56424
+ IndexVT.getVectorElementType() == PtrVT && isa<ConstantSDNode>(Scale)) {
56425
56425
uint64_t ScaleAmt = Scale->getAsZExtVal();
56426
56426
if (auto *BV = dyn_cast<BuildVectorSDNode>(Index.getOperand(1))) {
56427
56427
BitVector UndefElts;
@@ -56442,13 +56442,11 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
56442
56442
// replace it with 0 and move the displacement into the index.
56443
56443
if (BV->isConstant() && isa<ConstantSDNode>(Base) &&
56444
56444
isOneConstant(Scale)) {
56445
- SDValue Splat = DAG.getSplatBuildVector(Index.getValueType() , DL, Base);
56445
+ SDValue Splat = DAG.getSplatBuildVector(IndexVT , DL, Base);
56446
56446
// 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);
56449
56448
// 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);
56452
56450
Base = DAG.getConstant(0, DL, Base.getValueType());
56453
56451
return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
56454
56452
}
@@ -56461,7 +56459,7 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
56461
56459
// Make sure the index is either i32 or i64
56462
56460
if (IndexWidth != 32 && IndexWidth != 64) {
56463
56461
MVT EltVT = IndexWidth > 32 ? MVT::i64 : MVT::i32;
56464
- EVT IndexVT = Index.getValueType() .changeVectorElementType(EltVT);
56462
+ IndexVT = IndexVT .changeVectorElementType(EltVT);
56465
56463
Index = DAG.getSExtOrTrunc(Index, DL, IndexVT);
56466
56464
return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
56467
56465
}
0 commit comments