[llvm] r322137 - [LoopRotate] Detect loops with indirect branches better (we're giving up on them).
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 9 15:54:36 PST 2018
Author: mzolotukhin
Date: Tue Jan 9 15:54:35 2018
New Revision: 322137
URL: http://llvm.org/viewvc/llvm-project?rev=322137&view=rev
Log:
[LoopRotate] Detect loops with indirect branches better (we're giving up on them).
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
llvm/trunk/test/Transforms/LoopRotate/indirectbr.ll
Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=322137&r1=322136&r2=322137&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Tue Jan 9 15:54:35 2018
@@ -268,7 +268,7 @@ bool LoopRotate::rotateLoop(Loop *L, boo
// 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
Modified: llvm/trunk/test/Transforms/LoopRotate/indirectbr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopRotate/indirectbr.ll?rev=322137&r1=322136&r2=322137&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopRotate/indirectbr.ll (original)
+++ llvm/trunk/test/Transforms/LoopRotate/indirectbr.ll Tue Jan 9 15:54:35 2018
@@ -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:
%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
+}
More information about the llvm-commits
mailing list