If loop header is also loop exiting block then it may not be safe to hoist instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141576 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/MachineLICM.cpp b/lib/CodeGen/MachineLICM.cpp
index f8cbe41..bd25b2c 100644
--- a/lib/CodeGen/MachineLICM.cpp
+++ b/lib/CodeGen/MachineLICM.cpp
@@ -1145,13 +1145,12 @@
     return true;
 
   // Get the exit blocks for the current loop.
-  SmallVector<MachineBasicBlock*, 8> ExitBlocks;
-  CurLoop->getExitingBlocks(ExitBlocks);
+  SmallVector<MachineBasicBlock*, 8> ExitingBlocks;
+  CurLoop->getExitingBlocks(ExitingBlocks);
 
   // Verify that the block dominates each of the exit blocks of the loop.
-  for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
-    if (ExitBlocks[i] != CurLoop->getHeader() &&
-	!DT->dominates(MI->getParent(), ExitBlocks[i]))
+  for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i)
+    if (!DT->dominates(MI->getParent(), ExitingBlocks[i]))
       return false;
 
   return true;