Page MenuHomePhabricator

[LoopInfo] Add helper methods to compute two useful orderings of the loops in a function.
ClosedPublic

Authored by chandlerc on Jan 19 2017, 6:14 PM.

Details

Summary

These are relatively confusing to talk about and compute correctly so it
seems really good to write down their implementation in one place. I've
replaced one place we needed this in the loop PM infrastructure and
I have another place in a pending patch that wants it.

We can't quite use this for the core loop PM walk because there we're
sometimes working on a sub-forest.

I'll add the expected unittests before committing this but wanted to
make sure folks were happy with these names / comments.

Credit goes to Richard Smith for the idea for naming the order where siblings
are in reverse program order but the tree traversal remains preorder.

Event Timeline

chandlerc created this revision.Jan 19 2017, 6:14 PM
davide edited edge metadata.Jan 19 2017, 6:24 PM

I like the idea (and the names), some obvious comments inline. Given these two functions are almost identical modulo the reverse(), maybe use a common helper? Not feeling strong tho, so, up to you.

include/llvm/Analysis/LoopInfoImpl.h
511–512 ↗(On Diff #85088)

Does this actually build (I'm probably missing something here)?

sanjoy accepted this revision.Jan 19 2017, 6:27 PM

lgtm, once you can get this to build :P

This revision is now accepted and ready to land.Jan 19 2017, 6:27 PM
davide accepted this revision.Jan 19 2017, 6:33 PM

As we quickly discussed on IRC, a common helper seems hard to get, so nvm. LGTM once you fix the obvious typo.

chandlerc updated this revision to Diff 85088.Jan 19 2017, 6:50 PM

Update with unittests and everything.

This revision was automatically updated to reflect the committed changes.