Skip to content

Commit a21320e

Browse files
committed
Replace custom code with canFoldInAddressingMode
1 parent 89d54cf commit a21320e

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,23 +2772,9 @@ SDValue DAGCombiner::visitPTRADD(SDNode *N) {
27722772
// This should be done late, after legalization, so that it doesn't block
27732773
// other ptradd combines that could enable more offset folding.
27742774
if (LegalOperations && DAG.haveNoCommonBitsSet(N0, N1)) {
2775-
bool TransformCanBreakAddrMode = false;
2776-
if (auto *C = dyn_cast<ConstantSDNode>(N1)) {
2777-
TargetLoweringBase::AddrMode AM;
2778-
AM.HasBaseReg = true;
2779-
AM.BaseOffs = C->getSExtValue();
2780-
TransformCanBreakAddrMode = any_of(N->users(), [&](SDNode *User) {
2781-
if (auto *LoadStore = dyn_cast<MemSDNode>(User);
2782-
LoadStore && LoadStore->getBasePtr().getNode() == N) {
2783-
unsigned AS = LoadStore->getAddressSpace();
2784-
EVT AccessVT = LoadStore->getMemoryVT();
2785-
Type *AccessTy = AccessVT.getTypeForEVT(*DAG.getContext());
2786-
return TLI.isLegalAddressingMode(DAG.getDataLayout(), AM, AccessTy,
2787-
AS);
2788-
}
2789-
return false;
2790-
});
2791-
}
2775+
bool TransformCanBreakAddrMode = any_of(N->users(), [&](SDNode *User) {
2776+
return canFoldInAddressingMode(N, User, DAG, TLI);
2777+
});
27922778

27932779
if (!TransformCanBreakAddrMode)
27942780
return DAG.getNode(ISD::OR, DL, PtrVT, N0, N1, SDNodeFlags::Disjoint);

0 commit comments

Comments
 (0)