@@ -15370,41 +15370,6 @@ SDValue SITargetLowering::performPtrAddCombine(SDNode *N,
1537015370 return Folded;
1537115371 }
1537215372
15373- // Transform (ptradd a, b) -> (or disjoint a, b) if it is equivalent and if
15374- // that transformation can't block an offset folding at any use of the ptradd.
15375- // This should be done late, after legalization, so that it doesn't block
15376- // other ptradd combines that could enable more offset folding.
15377- bool HasIntermediateAssertAlign =
15378- N0->getOpcode() == ISD::AssertAlign && N0->getOperand(0)->isAnyAdd();
15379- // This is a hack to work around an ordering problem for DAGs like this:
15380- // (ptradd (AssertAlign (ptradd p, c1), k), c2)
15381- // If the outer ptradd is handled first by the DAGCombiner, it can be
15382- // transformed into a disjoint or. Then, when the generic AssertAlign combine
15383- // pushes the AssertAlign through the inner ptradd, it's too late for the
15384- // ptradd reassociation to trigger.
15385- if (!DCI.isBeforeLegalizeOps() && !HasIntermediateAssertAlign &&
15386- DAG.haveNoCommonBitsSet(N0, N1)) {
15387- bool TransformCanBreakAddrMode = any_of(N->users(), [&](SDNode *User) {
15388- if (auto *LoadStore = dyn_cast<MemSDNode>(User);
15389- LoadStore && LoadStore->getBasePtr().getNode() == N) {
15390- unsigned AS = LoadStore->getAddressSpace();
15391- // Currently, we only really need ptradds to fold offsets into flat
15392- // memory instructions.
15393- if (AS != AMDGPUAS::FLAT_ADDRESS)
15394- return false;
15395- TargetLoweringBase::AddrMode AM;
15396- AM.HasBaseReg = true;
15397- EVT VT = LoadStore->getMemoryVT();
15398- Type *AccessTy = VT.getTypeForEVT(*DAG.getContext());
15399- return isLegalAddressingMode(DAG.getDataLayout(), AM, AccessTy, AS);
15400- }
15401- return false;
15402- });
15403-
15404- if (!TransformCanBreakAddrMode)
15405- return DAG.getNode(ISD::OR, DL, VT, N0, N1, SDNodeFlags::Disjoint);
15406- }
15407-
1540815373 if (N1.getOpcode() != ISD::ADD || !N1.hasOneUse())
1540915374 return SDValue();
1541015375
0 commit comments