This is an archive of the discontinued LLVM Phabricator instance.

[LoopSimplify] Factor the logic to form dedicated exits into a utility.
ClosedPublic

Authored by chandlerc on Jun 9 2017, 3:38 AM.

Details

Summary

I want to use the same logic as LoopSimplify to form dedicated exits in
another pass (SimpleLoopUnswitch) so I wanted to factor it out here.

I also noticed that there is a pretty significantly more efficient way
to implement this than the way the code in LoopSimplify worked. We don't
need to actually retain the set of unique exit blocks, we can just
rewrite them as we find them and use only a set to deduplicate.

This did require changing one part of LoopSimplify to not re-use the
unique set of exits, but it only used it to check that there was
a single unique exit. That part of the code is about to walk the exiting
blocks anyways, so it seemed better to rewrite it to use those exiting
blocks to compute this property on-demand.

I also had to ditch a statistic, but it doesn't seem terribly valuable.

Diff Detail

Repository
rL LLVM

Event Timeline

chandlerc created this revision.Jun 9 2017, 3:38 AM

Rebase and ping.

davide accepted this revision.Jun 18 2017, 9:48 PM
davide added a subscriber: davide.

LGTM, I don't think that statistic was that valuable anyway.

include/llvm/Transforms/Utils/LoopUtils.h
365 ↗(On Diff #102496)

typo, are dedicated

This revision is now accepted and ready to land.Jun 18 2017, 9:48 PM
This revision was automatically updated to reflect the committed changes.

Landed with the typo fix, thansk for the review!