From: Clement Courbet Date: Tue, 5 Feb 2019 07:36:20 +0000 (+0000) Subject: [DAG] BaseIndexOffset: FrameIndexSDNodes with the same FrameIndex compare equal. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c605438958a7c35065de7edbb517cee86bef8757;p=llvm [DAG] BaseIndexOffset: FrameIndexSDNodes with the same FrameIndex compare equal. Reviewers: niravd Subscribers: arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D57692 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353143 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp index e57dabca5ee..5666c1293e9 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp @@ -59,17 +59,22 @@ bool BaseIndexOffset::equalBaseIndex(const BaseIndexOffset &Other, const MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo(); - // Match non-equal FrameIndexes - If both frame indices are fixed - // we know their relative offsets and can compare them. Otherwise - // we must be conservative. + // Match FrameIndexes. if (auto *A = dyn_cast(Base)) - if (auto *B = dyn_cast(Other.Base)) + if (auto *B = dyn_cast(Other.Base)) { + // Equal FrameIndexes - offsets are directly comparable. + if (A->getIndex() == B->getIndex()) + return true; + // Non-equal FrameIndexes - If both frame indices are fixed + // we know their relative offsets and can compare them. Otherwise + // we must be conservative. if (MFI.isFixedObjectIndex(A->getIndex()) && MFI.isFixedObjectIndex(B->getIndex())) { Off += MFI.getObjectOffset(B->getIndex()) - MFI.getObjectOffset(A->getIndex()); return true; } + } } return false; } @@ -195,4 +200,3 @@ void BaseIndexOffset::print(raw_ostream& OS) const { } #endif -