Match more post-indexed ops.
[oota-llvm.git] / lib / CodeGen / SelectionDAG / DAGCombiner.cpp
index bdb2d5e2f17163a5ad3236ad965f618e4073a7fc..430cf5c6f56a7f807593c01ba74a2f7cd3d826ec 100644 (file)
@@ -301,8 +301,12 @@ namespace {
           SDOperand BasePtr;
           SDOperand Offset;
           ISD::MemOpAddrMode AM = ISD::UNINDEXED;
-          if (TLI.getPostIndexedAddressParts(Op, VT, BasePtr, Offset, AM,DAG) &&
-              BasePtr == Ptr) {
+          if (TLI.getPostIndexedAddressParts(Op, VT, BasePtr, Offset, AM,DAG)) {
+            if (Ptr == Offset)
+              std::swap(BasePtr, Offset);
+            if (Ptr != BasePtr)
+              continue;
+
             // Try turning it into a post-indexed load / store except when
             // 1) Op must be independent of N, i.e. Op is neither a predecessor
             //    nor a successor of N. Otherwise, if Op is folded that would