This is an archive of the discontinued LLVM Phabricator instance.

[RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops
ClosedPublic

Authored by anna on May 3 2017, 6:36 AM.

Details

Summary

Cloning basic blocks in the loop for runtime loop unroller depends on loop being
in rotated form (i.e. loop latch target is the exit block).
Assert that this is true, so that callers of runtime loop unroller pass in
canonical loops.
The single caller of this function has that check recently added:
https://reviews.llvm.org/rL301239

Diff Detail

Repository
rL LLVM

Event Timeline

anna created this revision.May 3 2017, 6:36 AM
anna planned changes to this revision.May 3 2017, 6:41 AM

Some tests are failing, need to understand why.

anna updated this revision to Diff 97628.May 3 2017, 6:49 AM

Move the assert before the loop is being modified to support prolog/epilog remainders.
All tests passing.

davide accepted this revision.May 3 2017, 10:40 AM

LGTM.

lib/Transforms/Utils/LoopUnrollRuntime.cpp
515–521 ↗(On Diff #97628)

This seems like a natural extension of what I did.
I think the fact that the other successor is the header is given by the definition of a latch, so we should be fine with this.

This revision is now accepted and ready to land.May 3 2017, 10:40 AM
anna marked an inline comment as done.May 3 2017, 10:49 AM
anna added inline comments.
lib/Transforms/Utils/LoopUnrollRuntime.cpp
515–521 ↗(On Diff #97628)

Thanks, yes. I had spotted this implicit dependency (latch's successor is an exit) in the runtime unroller's clone function and was wondering if we can have such a situation where the dependency is not true. Sanjoy had pointed me to your fix (and test case) in the loop unroller.

davide added inline comments.May 3 2017, 10:52 AM
lib/Transforms/Utils/LoopUnrollRuntime.cpp
515–521 ↗(On Diff #97628)

Side note: ideally I'd like to teach the unroller to handle more complicated loops in the future rather than bailing out, but that would require more time than the one I can devote to the cause for the next 3 months at least.
Thanks for your patch. Feel free to land.

This revision was automatically updated to reflect the committed changes.