[PATCH] D22630: Loop rotation

Michael Zolotukhin via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 16:29:33 PDT 2016

mzolotukhin added a comment.

> We need to rotate loops because of two reasons:
> - To make the loop in a canonical form.
> - To expose redundancies by cloning the basic blocks which are exiting out of the loop.

These are two completely separate goal and we should make a clear distinction between them. I think loop-rotate should be primarily used to achieve to canonicalize loops, and my impression of this patch was that it'll just help us to handle more loops, which is great.

If you also intend to use loop-rotate as an actual optimization (to achieve the second goal), I'd suggest adding a separate mode, maybe even separate pass, for it, which will reuse the same infrastructure, but will be driven by completely different factors. It'll probably be also scheduled in some other place in the pipeline.

Also, speaking about the tests:

> LLVM :: Transforms/GVNHoist/pr29031.ll
>  LLVM :: Transforms/LoopRotate/loop-rotate-before-latch.ll
>  LLVM :: Transforms/LoopRotate/multiple-exits.ll
>  LLVM :: Transforms/LoopRotate/pr7447.ll

Why do these fail? From the first glance it looks like they don't require rotating loops with exiting latch. Also, in the original code we explicitly had

  if (L->isLoopExiting(OrigLatch))
    return false;

How could we possible rotate the loops before? Could you please investigate it in more details?



More information about the llvm-commits mailing list