[LoopUnrollRuntime] Bailout when multiple exiting blocks to the unique latch exit block

Currently, we do not support multiple exiting blocks to the
latch exit block. However, this bailout wasn't triggered when we had a
unique exit block (which is the latch exit), with multiple exiting
blocks to that unique exit.

Moved the bailout so that it's triggered in both cases and added
testcase.

llvm-svn: 307291
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
index 9ad2b70..f96c0bd 100644
--- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
@@ -504,10 +504,6 @@
     // transformed.
     if (!PreserveLCSSA)
       return false;
-    // TODO: Support multiple exiting blocks jumping to the `LatchExit`. This
-    // will need updating the logic in connectEpilog.
-    if (!LatchExit->getSinglePredecessor())
-        return false;
     SmallVector<BasicBlock *, 4> Exits;
     L->getUniqueExitBlocks(Exits);
     for (auto *BB : Exits)
@@ -517,6 +513,11 @@
 
   assert(LatchExit && "Latch Exit should exist!");
 
+  // TODO: Support multiple exiting blocks jumping to the `LatchExit` when
+  // UnrollRuntimeMultiExit is true. This will need updating the logic in
+  // connectEpilog.
+  if (!LatchExit->getSinglePredecessor())
+    return false;
   // Use Scalar Evolution to compute the trip count. This allows more loops to
   // be unrolled than relying on induction var simplification.
   if (!SE)