This is an archive of the discontinued LLVM Phabricator instance.

[LoopInterchange] Move preheader creation to transform stage and simplify.
ClosedPublic

Authored by fhahn on Sep 5 2018, 12:12 PM.

Details

Summary

There is no need to create preheaders in the analysis stage, we only
need them when adjusting the branches. Also, the only cases we need to
create our own preheaders is when they have more than 1 predecessors or
PHI nodes (even with only 1 predecessor, we could have an LCSSA phi
node). I have simplified the conditions and added some assertions to be
sure. Because we know the inner and outer loop need to be tightly
nested, it is sufficient to check if the inner loop preheader is the
outer loop header to check if we need to create a new preheader.

Diff Detail

Repository
rL LLVM

Event Timeline

fhahn created this revision.Sep 5 2018, 12:12 PM
efriedma accepted this revision.Sep 5 2018, 12:41 PM

LGTM

lib/Transforms/Scalar/LoopInterchange.cpp
1350 ↗(On Diff #164098)

Please add a comment explaining that this is using InsertPreheaderForLoop to insert an "extra" preheader block for loops which already have a preheader.

This revision is now accepted and ready to land.Sep 5 2018, 12:41 PM
fhahn updated this revision to Diff 164173.Sep 6 2018, 2:35 AM

Add comment

This revision was automatically updated to reflect the committed changes.