[PATCH] D22630: Loop rotation
Sebastian Pop via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 26 15:21:40 PDT 2016
sebpop added inline comments.
================
Comment at: llvm/lib/Transforms/Scalar/LoopRotation.cpp:431
@@ +430,3 @@
+ DEBUG(dbgs() << "\nSplitting the edge of Loop:"; L->dumpVerbose(););
+ LoopLatch = SplitEdge(LoopLatch, L->getHeader(), DT, LI);
+ }
----------------
eli.friedman wrote:
> sebpop wrote:
> > hiraditya wrote:
> > > eli.friedman wrote:
> > > > The loop latch could be an indirectbr.
> > > I'll fix this, thanks.
> > I have the impression that the loop analysis will not find a natural loop if the edge from the latch to the header is an indirect branch.
> > Are you sure this is possible? Do you have a test-case where we recognize a loop with an indirect branch for the latch edge?
> indirectbr loop in C:
>
> int g(), h(), z();
> int f() {
> static void* x[] = {&&F, &&G, &&H};
> F:
> goto *x[z()];
>
> G: return g();
> H: return h();
> }
>
> `clang -x c - -o - -S -O2 -emit-llvm | opt -analyze -loops` gives:
>
> Printing analysis 'Natural Loop Information' for function 'f':
> Loop at depth 1 containing: %F<header><latch><exiting>
Thanks Eli for the testcase: we will add it to the testsuite and we will add a check "if (isa<IndirectBrInst>(LoopLatch->getTerminator()))" before entering the loop rotation for that loop.
https://reviews.llvm.org/D22630
More information about the llvm-commits
mailing list