diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopRotation.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/Transforms/LoopRotate/indirectbr.ll | 35 |
2 files changed, 34 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp index a91f53ba663..0f35fccbe66 100644 --- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRotation.cpp @@ -268,7 +268,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // If the loop could not be converted to canonical form, it must have an // indirectbr in it, just give up. - if (!OrigPreheader) + if (!OrigPreheader || !L->hasDedicatedExits()) return false; // Anything ScalarEvolution may know about this loop or the PHI nodes diff --git a/llvm/test/Transforms/LoopRotate/indirectbr.ll b/llvm/test/Transforms/LoopRotate/indirectbr.ll index 2ccc54697ae..8f059d50505 100644 --- a/llvm/test/Transforms/LoopRotate/indirectbr.ll +++ b/llvm/test/Transforms/LoopRotate/indirectbr.ll @@ -1,6 +1,6 @@ -; RUN: opt < %s -S -loop-rotate -disable-output -verify-loop-info -verify-dom-info -; PR5502 +; RUN: opt < %s -S -loop-rotate -o - -verify-loop-info -verify-dom-info | FileCheck %s +; PR5502 define void @z80_do_opcodes() nounwind { entry: br label %while.cond @@ -41,3 +41,34 @@ indirectgoto: ; preds = %run_opcode, %while. %opcode.0 = phi i8 [ undef, %while.body ], [ %tmp276, %run_opcode ] ; <i8> [#uses=2] indirectbr i8* undef, [label %run_opcode, label %if.else295, label %end_opcode] } + +; CHECK-LABEL: @foo +define void @foo(i1 %a, i1 %b, i8* %c) { +; CHECK: entry +; CHECK-NEXT: br i1 %a, label %return, label %preheader +entry: + br i1 %a, label %return, label %preheader + +; CHECK: preheader: +; CHECK-NEXT: br label %header +preheader: + br label %header + +; CHECK: header: +; CHECK-NEXT: br i1 %b, label %return, label %body +header: + br i1 %b, label %return, label %body + +; CHECK: body: +; CHECK-NEXT: indirectbr i8* %c, [label %return, label %latch] +body: + indirectbr i8* %c, [label %return, label %latch] + +; CHECK: latch: +; CHECK-NEXT: br label %header +latch: + br label %header + +return: + ret void +} |

