fix PR10605 / rdar://9930964 by adding a pretty scary missed check.
[oota-llvm.git] / lib / CodeGen / SelectionDAG / SelectionDAGISel.cpp
index 87bb296b8c790f78e1385442b2e2a3f44e3de3b4..ec8f014f651c9bd00e774fe7df1073dcb9a5c49b 100644 (file)
@@ -754,6 +754,11 @@ bool SelectionDAGISel::TryToFoldFastISelLoad(const LoadInst *LI,
     TheUser = TheUser->use_back();
   }
   
+  // If we didn't find the fold instruction, then we failed to collapse the
+  // sequence.
+  if (TheUser != FoldInst)
+    return false;
+  
   // Don't try to fold volatile loads.  Target has to deal with alignment
   // constraints.
   if (LI->isVolatile()) return false;