Avoid calling getUniqueExitBlocks from within LoopSimplify, as it depends
authorDan Gohman <gohman@apple.com>
Thu, 5 Nov 2009 21:48:32 +0000 (21:48 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 5 Nov 2009 21:48:32 +0000 (21:48 +0000)
on loops having dedicated exits, which LoopSimplify can no longer always
guarantee.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86181 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/LoopSimplify.cpp

index 63708b14b4d7e35c865b33422257b29986c225f0..2ab0972149588b0bc31f1235931129ab702ebd77 100644 (file)
@@ -241,7 +241,14 @@ ReprocessLoop:
   // loop-invariant instructions out of the way to open up more
   // opportunities, and the disadvantage of having the responsibility
   // to preserve dominator information.
-  if (ExitBlocks.size() > 1 && L->getUniqueExitBlock()) {
+  bool UniqueExit = true;
+  if (!ExitBlocks.empty())
+    for (unsigned i = 1, e = ExitBlocks.size(); i != e; ++i)
+      if (ExitBlocks[i] != ExitBlocks[0]) {
+        UniqueExit = false;
+        break;
+      }
+  if (UniqueExit) {
     SmallVector<BasicBlock*, 8> ExitingBlocks;
     L->getExitingBlocks(ExitingBlocks);
     for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i) {