This is an archive of the discontinued LLVM Phabricator instance.

New Loop Distribution pass
ClosedPublic

Authored by anemet on Apr 4 2015, 1:36 AM.

Details

Summary

This implements the initial version as was proposed earlier this year
(http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-January/080462.html).
Since then the Loop Access Analysis was split out from the Loop
Vectorizer and was made into a separate analysis pass. Loop
Distribution becomes the second user of this analysis.

The pass is off by default and can be enabled
with -enable-loop-distribution. There is currently no notion of
profitability; if there is a loop with dependence cycles, the pass will
try to split them off from other memory operations into a separate loop.

I decided to remove the control-dependence calculation from this first
version. This and the issues with the PDT are actively discussed so it
probably makes sense to treat it separately. Right now I just mark all
terminator instruction required which keeps identical CFGs for each
distributed loop. This seems to be working pretty well for 456.hmmer
where even though there is an empty if-then block in the distributed
loop initially, it gets completely removed.

The pass keeps DominatorTree and LoopInfo updated. I've tested this
with -loop-distribute-verify with the testsuite where we distribute ~90
loops. SimplifyLoop is violated in some cases and I have a FIXME
covering this.

Diff Detail

Repository
rL LLVM

Event Timeline

anemet updated this revision to Diff 23249.Apr 4 2015, 1:36 AM
anemet retitled this revision from to New Loop Distribution pass.
anemet updated this object.
anemet edited the test plan for this revision. (Show Details)
anemet added reviewers: hfinkel, aschwaighofer, nadav.
anemet added a subscriber: Unknown Object (MLST).
anemet added inline comments.Apr 9 2015, 3:48 PM
lib/Transforms/Scalar/LoopDistribute.cpp
45 ↗(On Diff #23249)

Gerolf and I came up with a better name for this: -verify-after-loop-distribute.

ping

aschwaighofer edited edge metadata.May 13 2015, 3:26 PM

This LGTM. Nice work!

lib/Transforms/Scalar/LoopDistribute.cpp
147 ↗(On Diff #23249)

Comment: It is the other way round. The code moves 'this' to the 'Other' partition.

575 ↗(On Diff #23249)

Can we rewrite this nested loop to something like:

InstPartion *PrevMatch = nullptr;
for (auto It = PC.begin(); It != PC.end(); ) {
  auto DoesMatch = Predicate(*It);
  if (PreMatch == nullptr && DoesMatch) {
     PrevMatch = *It
     ++It;
  } else if (PreMatch != nullptr && DoesMatch) {
    *It->move_to(PrevMatch);
     It = PC.erase(It);
  } else {
    PrevMatch = nullptr;
    ++It;
  }
}
anemet accepted this revision.May 14 2015, 4:49 AM
anemet added a reviewer: anemet.

Thanks, Arnold!

lib/Transforms/Scalar/LoopDistribute.cpp
147 ↗(On Diff #23249)

Yeah, totally, the comment is backwards.

575 ↗(On Diff #23249)

Sure, if you prefer.

This revision is now accepted and ready to land.May 14 2015, 4:49 AM
This revision was automatically updated to reflect the committed changes.