@@ -56427,34 +56427,34 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5642756427 if (DCI.isBeforeLegalize()) {
5642856428 unsigned IndexWidth = Index.getScalarValueSizeInBits();
5642956429
56430- // Shrink constant indices if they are larger than 32-bits.
56430+ // Shrink indices if they are larger than 32-bits.
5643156431 // Only do this before legalize types since v2i64 could become v2i32.
5643256432 // FIXME: We could check that the type is legal if we're after legalize
5643356433 // types, but then we would need to construct test cases where that happens.
56434- // FIXME: We could support more than just constant vectors, but we need to
56435- // careful with costing. A truncate that can be optimized out would be fine.
56436- // Otherwise we might only want to create a truncate if it avoids a split.
56437- if (auto *BV = dyn_cast<BuildVectorSDNode>(Index)) {
56438- if (BV->isConstant() && IndexWidth > 32 &&
56439- DAG.ComputeNumSignBits(Index) > (IndexWidth - 32)) {
56440- EVT NewVT = IndexVT.changeVectorElementType(MVT::i32);
56434+ if (IndexWidth > 32 && DAG.ComputeNumSignBits(Index) > (IndexWidth - 32)) {
56435+ EVT NewVT = IndexVT.changeVectorElementType(MVT::i32);
56436+
56437+ // FIXME: We could support more than just constant vectors, but we need to
56438+ // careful with costing. A truncate that can be optimized out would be
56439+ // fine. Otherwise we might only want to create a truncate if it avoids a
56440+ // split.
56441+ if (auto *BV = dyn_cast<BuildVectorSDNode>(Index)) {
56442+ if (BV->isConstant()) {
56443+ Index = DAG.getNode(ISD::TRUNCATE, DL, NewVT, Index);
56444+ return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
56445+ }
56446+ }
56447+
56448+ // Shrink any sign/zero extends from 32 or smaller to larger than 32 if
56449+ // there are sufficient sign bits. Only do this before legalize types to
56450+ // avoid creating illegal types in truncate.
56451+ if ((Index.getOpcode() == ISD::SIGN_EXTEND ||
56452+ Index.getOpcode() == ISD::ZERO_EXTEND) &&
56453+ Index.getOperand(0).getScalarValueSizeInBits() <= 32) {
5644156454 Index = DAG.getNode(ISD::TRUNCATE, DL, NewVT, Index);
5644256455 return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
5644356456 }
5644456457 }
56445-
56446- // Shrink any sign/zero extends from 32 or smaller to larger than 32 if
56447- // there are sufficient sign bits. Only do this before legalize types to
56448- // avoid creating illegal types in truncate.
56449- if ((Index.getOpcode() == ISD::SIGN_EXTEND ||
56450- Index.getOpcode() == ISD::ZERO_EXTEND) &&
56451- IndexWidth > 32 &&
56452- Index.getOperand(0).getScalarValueSizeInBits() <= 32 &&
56453- DAG.ComputeNumSignBits(Index) > (IndexWidth - 32)) {
56454- EVT NewVT = IndexVT.changeVectorElementType(MVT::i32);
56455- Index = DAG.getNode(ISD::TRUNCATE, DL, NewVT, Index);
56456- return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
56457- }
5645856458 }
5645956459
5646056460 EVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
0 commit comments