Page MenuHomePhabricator

[LoopInterchange] Properly move condition, induction increment and ops to latch.
ClosedPublic

Authored by fhahn on Mon, Sep 9, 1:13 PM.

Details

Summary

Currently we only rely on the induction increment to come before the
condition to ensure the required instructions get moved to the new
latch.

This patch duplicates and moves the required instructions to the
newly created latch. We move the condition to the end of the new block,
then process its operands. We stop at operands that are defined
outside the loop, or are the induction PHI.

We duplicate the instructions and update the uses in the moved
instructions, to ensure other users remain intact. See the added
test2 for such an example.

Diff Detail

Repository
rL LLVM

Event Timeline

fhahn created this revision.Mon, Sep 9, 1:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptMon, Sep 9, 1:13 PM
Herald added a subscriber: hiraditya. · View Herald Transcript

This makes more sense than D67076, I think.

Do the safety checks ensure we never clone an instruction with side-effects? Can we assert that?

fhahn updated this revision to Diff 219529.Tue, Sep 10, 5:54 AM

Add assertion that moved instructions do not have side-effects, update test checks.

fhahn added a comment.Tue, Sep 10, 5:55 AM

This makes more sense than D67076, I think.

Do the safety checks ensure we never clone an instruction with side-effects? Can we assert that?

Yes they should. I've added an assert to be sure.

This revision is now accepted and ready to land.Tue, Sep 10, 11:28 AM
This revision was automatically updated to reflect the committed changes.