[DAG] Fixed predicate for determining when two frame indices
authorNirav Dave <niravd@google.com>
Tue, 4 Jul 2017 02:20:17 +0000 (02:20 +0000)
committerNirav Dave <niravd@google.com>
Tue, 4 Jul 2017 02:20:17 +0000 (02:20 +0000)
addresses are comparable. NFCI.

llvm-svn: 307055

llvm/lib/CodeGen/SelectionDAG/SelectionDAGAddressAnalysis.cpp

index 4e899ae6668e76201da00890fa4e0d39edb736e2..14b804eef22ba1415568a1d99cc86c0a7f7d53e6 100644 (file)
@@ -37,13 +37,13 @@ bool BaseIndexOffset::equalBaseIndex(BaseIndexOffset &Other,
 
     const MachineFrameInfo &MFI = DAG.getMachineFunction().getFrameInfo();
 
-    // Match non-equal FrameIndexes - a FrameIndex stemming from an
-    // alloca will not have it's ObjectOffset set until post-DAG and
-    // as such we must assume the two framesIndices are incomparable.
+    // Match non-equal FrameIndexes - If both frame indices are fixed
+    // we know their relative offsets and can compare them. Otherwise
+    // we must be conservative.
     if (auto *A = dyn_cast<FrameIndexSDNode>(Base))
       if (auto *B = dyn_cast<FrameIndexSDNode>(Other.Base))
-        if (!MFI.getObjectAllocation(A->getIndex()) &&
-            !MFI.getObjectAllocation(B->getIndex())) {
+        if (MFI.isFixedObjectIndex(A->getIndex()) &&
+            MFI.isFixedObjectIndex(B->getIndex())) {
           Off += MFI.getObjectOffset(B->getIndex()) -
                  MFI.getObjectOffset(A->getIndex());
           return true;