Instructions to be redone only if from the same BB
[oota-llvm.git] / lib / Transforms / Scalar / Reassociate.cpp
index 401a740856e9cbcf5cca45241e82573c2f4678f5..bcadd4e2bee69aae900241c7f00717aab64ec3c9 100644 (file)
@@ -2155,7 +2155,8 @@ void Reassociate::OptimizeInst(Instruction *I) {
     // During the initial run we will get to the root of the tree.
     // But if we get here while we are redoing instructions, there is no
     // guarantee that the root will be visited. So Redo later
-    if (BO->user_back() != BO)
+    if (BO->user_back() != BO &&
+        BO->getParent() == BO->user_back()->getParent())
       RedoInsts.insert(BO->user_back());
     return;
   }