[PATCH] D72519: [LoopInfo] Support multi edge in getLoopLatch()

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 11 13:11:06 PST 2020


nikic added a comment.

> I'm open to being convinced that the change in canonical form to allow multiple identical backedges is reasonable, but I'd expect to see an argument to that form, not simple a code change.

The context here is D72420 <https://reviews.llvm.org/D72420>, which adds support for rotating loops that use a switch instruction rather than branch instruction for the loop exit condition. The loop rotation pass naturally asserts that the end result is going to be a loop that has an exiting latch. Of course it is possible to instead produce a separate latch block (as loop simplify currently does) and remove the requirement that the latch be exiting. However, that leaves us with a loop that we generally would not say to be in rotated form -- and indeed, successive applications of the loop rotate pass will continue to rotate it, effectively peeling off iterations one by one. It would be necessary to special case this structure in order to prevent additional rotations from occurring.

The use of multi edges for switches is a peculiarity of LLVMs representation, not an intrinsic property of the control flow graph. Structurally, I would expect that any optimizations that require a unique latch, or a unique latch that is also exiting, will remain applicable if the edges are repeated. Allowing this avoids having to either special case this kind of code, or give up optimization potential. (Practically this tends to not be very relevant right now, because loop passes generally bail on switches.)

I do understand the concern about breaking assumptions though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72519





More information about the llvm-commits mailing list