[PATCH] D60266: [LoopUnroll] Rotate loop, when optimizing for size and can fully unroll a loop.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 4 13:04:37 PDT 2019


fhahn added a comment.

In D60266#1455299 <https://reviews.llvm.org/D60266#1455299>, @efriedma wrote:

> Why do we need to rotate the loop before unrolling?  llvm::UnrollLoop currently refuses to unroll loops where the latch is an unconditional branch, but that isn't a fundamental limitation, as far as I can tell.  We already support unrolling loops where the latch is not the exit branch; allowing loops where the latch doesn't exit at all is a minor extension.  Granted, it might be more efficient to explicitly rotate the loop before unrolling, so we don't clone quite so much code.


IIUC the only reason requiring the conditional branch in the latch is to reduce the complexity of the unrolling code. In the non-optsize case, loop-rotate should take care of them. I can have a look and see how much work it would be to lift the restriction on UnrollLoop. The initial patch was just the easiest way to get things working, to give a good idea of the potential gains.

> On a related note, independent of what we do in unrolling, it would probably be worthwhile to teach loop rotation to rotate loops where the cloned header would fold to zero instructions.

Great idea, it seems there are a few potential improvements for optsize around here. I'll add it to my todo list :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60266/new/

https://reviews.llvm.org/D60266





More information about the llvm-commits mailing list