@@ -56508,120 +56508,6 @@ static SDValue rebuildGatherScatter(MaskedGatherScatterSDNode *GorS,
5650856508 Scatter->isTruncatingStore());
5650956509}
5651056510
56511- // Target override this function to decide whether it want to update the base
56512- // and index value of a non-uniform gep
56513- static bool updateBaseAndIndex(SDValue &Base, SDValue &Index, SDValue &Scale,
56514- const SDLoc &DL, const SDValue &Gep,
56515- SelectionDAG &DAG) {
56516- SDValue Nbase;
56517- SDValue Nindex;
56518- SDValue NScale;
56519- bool Changed = false;
56520- // This function check the opcode of Index and update the index
56521- auto checkAndUpdateIndex = [&](SDValue &Idx) {
56522- if (Idx.getOpcode() == ISD::SHL) { // shl zext, BV
56523- SDValue Op10 = Idx.getOperand(0); // Zext or Sext value
56524- SDValue Op11 = Idx.getOperand(1); // Build vector of constant
56525- std::optional<uint64_t> ShAmt = DAG.getValidMinimumShiftAmount(Idx);
56526-
56527- unsigned IndexWidth = Op10.getScalarValueSizeInBits();
56528- if ((Op10.getOpcode() == ISD::SIGN_EXTEND ||
56529- Op10.getOpcode() == ISD::ZERO_EXTEND) &&
56530- IndexWidth > 32 &&
56531- Op10.getOperand(0).getScalarValueSizeInBits() <= 32 &&
56532- DAG.ComputeNumSignBits(Op10) > (IndexWidth - 32) && ShAmt) {
56533-
56534- KnownBits ExtKnown = DAG.computeKnownBits(Op10);
56535- bool ExtIsNonNegative = ExtKnown.isNonNegative();
56536- KnownBits ExtOpKnown = DAG.computeKnownBits(Op10.getOperand(0));
56537- bool ExtOpIsNonNegative = ExtOpKnown.isNonNegative();
56538- if (!ExtIsNonNegative || !ExtOpIsNonNegative)
56539- return false;
56540-
56541- SDValue NewOp10 =
56542- Op10.getOperand(0); // Get the Operand zero from the ext
56543- EVT VT = NewOp10.getValueType(); // Use the operand's type to determine
56544- // the type of index
56545-
56546- // auto *ConstEltNo = dyn_cast<ConstantSDNode>(Op11.getOperand(0));
56547- // if (!ConstEltNo)
56548- // return false;
56549- uint64_t ScaleAmt = cast<ConstantSDNode>(Scale)->getZExtValue();
56550- uint64_t NewScaleAmt = ScaleAmt * (1ULL << *ShAmt);
56551- LLVM_DEBUG(dbgs() << NewScaleAmt << " NewScaleAmt"
56552- << "\n");
56553- if (isPowerOf2_64(NewScaleAmt) && NewScaleAmt <= 8) {
56554- // Nindex = NewOp10.getOperand(0);
56555- Nindex = Op10;
56556- NScale = DAG.getTargetConstant(NewScaleAmt, DL, Scale.getValueType());
56557- return true;
56558- }
56559- // SmallVector<SDValue, 8> Ops(VT.getVectorNumElements(),
56560- // DAG.getConstant(ConstEltNo->getZExtValue(),
56561- // DL, VT.getScalarType()));
56562- // Nindex = DAG.getNode(ISD::SHL, DL, VT, NewOp10,
56563- // DAG.getBuildVector(VT, DL, Ops));
56564- }
56565- }
56566- return false;
56567- };
56568-
56569- // For the gep instruction, we are trying to properly assign the base and
56570- // index value We are go through the lower code and iterate backward.
56571- if (isNullConstant(Base) && Gep.getOpcode() == ISD::ADD) {
56572- SDValue Op0 = Gep.getOperand(0); // base or add
56573- SDValue Op1 = Gep.getOperand(1); // build vector or SHL
56574- Nbase = Op0;
56575- SDValue Idx = Op1;
56576- auto Flags = Gep->getFlags();
56577-
56578- if (Op0->getOpcode() == ISD::ADD) { // add t15(base), t18(Idx)
56579- SDValue Op00 = Op0.getOperand(0); // Base
56580- Nbase = Op00;
56581- Idx = Op0.getOperand(1);
56582- } else if (!(Op0->getOpcode() == ISD::BUILD_VECTOR &&
56583- Op0.getOperand(0).getOpcode() == ISD::CopyFromReg)) {
56584- return false;
56585- }
56586- if (!checkAndUpdateIndex(Idx)) {
56587- return false;
56588- }
56589- Base = Nbase.getOperand(0);
56590-
56591- if (Op0 != Nbase) {
56592- auto *ConstEltNo = dyn_cast<ConstantSDNode>(Op1.getOperand(0));
56593- if (!ConstEltNo)
56594- return false;
56595-
56596- // SmallVector<SDValue, 8> Ops(
56597- // Nindex.getValueType().getVectorNumElements(),
56598- // DAG.getConstant(ConstEltNo->getZExtValue(), DL,
56599- // Nindex.getValueType().getScalarType()));
56600- Base = DAG.getNode(ISD::ADD, DL, Nbase.getOperand(0).getValueType(),
56601- Nbase.getOperand(0), Op1.getOperand(0), Flags);
56602- }
56603- Index = Nindex;
56604- Scale = NScale;
56605- Changed = true;
56606- } else if (Base.getOpcode() == ISD::CopyFromReg ||
56607- (Base.getOpcode() == ISD::ADD &&
56608- Base.getOperand(0).getOpcode() == ISD::CopyFromReg &&
56609- isConstOrConstSplat(Base.getOperand(1)))) {
56610- if (checkAndUpdateIndex(Index)) {
56611- Index = Nindex;
56612- Changed = true;
56613- }
56614- }
56615- if (Changed) {
56616- LLVM_DEBUG(dbgs() << "Successful in updating the non uniform gep "
56617- "information\n";
56618- dbgs() << "updated base "; Base.dump();
56619- dbgs() << "updated Index "; Index.dump(););
56620- return true;
56621- }
56622- return false;
56623- }
56624-
5662556511static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5662656512 TargetLowering::DAGCombinerInfo &DCI) {
5662756513 SDLoc DL(N);
@@ -56634,10 +56520,6 @@ static SDValue combineGatherScatter(SDNode *N, SelectionDAG &DAG,
5663456520 const TargetLowering &TLI = DAG.getTargetLoweringInfo();
5663556521
5663656522 if (DCI.isBeforeLegalize()) {
56637- // if (updateBaseAndIndex(Base, Index, Scale, DL, Index, DAG))
56638- // return rebuildGatherScatter(GorS, Index, Base, Scale, DAG);
56639- //
56640-
5664156523 // Attempt to move shifted index into the address scale, allows further
5664256524 // index truncation below.
5664356525 // TODO
0 commit comments