Make getUniqueExitBlocks's precondition assert more precise, to
authorDan Gohman <gohman@apple.com>
Fri, 11 Dec 2009 20:05:23 +0000 (20:05 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 11 Dec 2009 20:05:23 +0000 (20:05 +0000)
avoid spurious failures. This fixes PR5758.

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

include/llvm/Analysis/LoopInfo.h
lib/Analysis/LoopInfo.cpp
test/Transforms/IndVarSimplify/indirectbr.ll [new file with mode: 0644]

index 9969d999e13ec0b80007f63fac3862b5b5d7a6d0..7419cdc4440d6ca0e9c8165744019ae0674051b8 100644 (file)
@@ -568,7 +568,7 @@ public:
 
   /// getUniqueExitBlocks - Return all unique successor blocks of this loop. 
   /// These are the blocks _outside of the current loop_ which are branched to.
-  /// This assumes that loop is in canonical form.
+  /// This assumes that loop exits are in canonical form.
   ///
   void getUniqueExitBlocks(SmallVectorImpl<BasicBlock *> &ExitBlocks) const;
 
index 4de756c41b0eb088b7fe3deeacb9894487746f46..34089ee59c4171ed87a523f3ca06e5b91e143547 100644 (file)
@@ -316,12 +316,12 @@ bool Loop::hasDedicatedExits() const {
 
 /// getUniqueExitBlocks - Return all unique successor blocks of this loop.
 /// These are the blocks _outside of the current loop_ which are branched to.
-/// This assumes that loop is in canonical form.
+/// This assumes that loop exits are in canonical form.
 ///
 void
 Loop::getUniqueExitBlocks(SmallVectorImpl<BasicBlock *> &ExitBlocks) const {
-  assert(isLoopSimplifyForm() &&
-         "getUniqueExitBlocks assumes the loop is in canonical form!");
+  assert(hasDedicatedExits() &&
+         "getUniqueExitBlocks assumes the loop has canonical form exits!");
 
   // Sort the blocks vector so that we can use binary search to do quick
   // lookups.
diff --git a/test/Transforms/IndVarSimplify/indirectbr.ll b/test/Transforms/IndVarSimplify/indirectbr.ll
new file mode 100644 (file)
index 0000000..b4ce153
--- /dev/null
@@ -0,0 +1,22 @@
+; RUN: opt < %s -indvars -S -disable-output
+; PR5758
+
+define zeroext i1 @foo() nounwind {
+entry:
+  indirectbr i8* undef, [label %"202", label %"133"]
+
+"132":                                            ; preds = %"133"
+  %0 = add i32 %1, 1                              ; <i32> [#uses=1]
+  br label %"133"
+
+"133":                                            ; preds = %"132", %entry
+  %1 = phi i32 [ %0, %"132" ], [ 0, %entry ]      ; <i32> [#uses=2]
+  %2 = icmp eq i32 %1, 4                          ; <i1> [#uses=1]
+  br i1 %2, label %"134", label %"132"
+
+"134":                                            ; preds = %"133"
+  ret i1 true
+
+"202":                                            ; preds = %entry
+  ret i1 false
+}