Skip to content

Commit a1c816a

Browse files
committed
Replace custom code with canFoldInAddressingMode
1 parent abdc12f commit a1c816a

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
@@ -2779,23 +2779,9 @@ SDValue DAGCombiner::visitPTRADD(SDNode *N) {
27792779
// This should be done late, after legalization, so that it doesn't block
27802780
// other ptradd combines that could enable more offset folding.
27812781
if (LegalOperations && DAG.haveNoCommonBitsSet(N0, N1)) {
2782-
bool TransformCanBreakAddrMode = false;
2783-
if (auto *C = dyn_cast<ConstantSDNode>(N1)) {
2784-
TargetLoweringBase::AddrMode AM;
2785-
AM.HasBaseReg = true;
2786-
AM.BaseOffs = C->getSExtValue();
2787-
TransformCanBreakAddrMode = any_of(N->users(), [&](SDNode *User) {
2788-
if (auto *LoadStore = dyn_cast<MemSDNode>(User);
2789-
LoadStore && LoadStore->getBasePtr().getNode() == N) {
2790-
unsigned AS = LoadStore->getAddressSpace();
2791-
EVT AccessVT = LoadStore->getMemoryVT();
2792-
Type *AccessTy = AccessVT.getTypeForEVT(*DAG.getContext());
2793-
return TLI.isLegalAddressingMode(DAG.getDataLayout(), AM, AccessTy,
2794-
AS);
2795-
}
2796-
return false;
2797-
});
2798-
}
2782+
bool TransformCanBreakAddrMode = any_of(N->users(), [&](SDNode *User) {
2783+
return canFoldInAddressingMode(N, User, DAG, TLI);
2784+
});
27992785

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

0 commit comments

Comments
 (0)