Page MenuHomePhabricator

[Loop] Add isRotated method to Loop class.

Authored by kbarton on Aug 8 2019, 9:53 AM.



This patch adds a method to determine if a loop is in rotated form (the latch is
an exiting block). It also modifies the getLoopGuardBranch method to use this
new method. This method can also be used in Loopfusion. Once this patch lands I
will make the corresponding changes there.

Diff Detail

Event Timeline

kbarton created this revision.Aug 8 2019, 9:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2019, 9:53 AM
Meinersbur added inline comments.Aug 8 2019, 4:49 PM

I think it would be simpler if the function would return false if there are multiple latches with the meaning that the loop is not in loop-rotated normal form.

Note that there might still be multiple exiting edges, e.g. if the latch's terminator is a switch.

I can also think a definition for rotated with multiple latches: All latches' outgoing edges that are not backedges are existing (so the property is orthogonal to simplified form), but this would probably not be useful for anything.


[suggestion] EXPECT_FALSE(L->isRotated()) to have a negative test as well.

kbarton marked 4 inline comments as done.Dec 3 2019, 11:21 AM
kbarton added inline comments.

I agree - I think this makes sense.


Added LoopNotRotated test.

kbarton updated this revision to Diff 231953.Dec 3 2019, 11:21 AM
kbarton marked 2 inline comments as done.
  • Return false if no latch block exists, instead of assert (based on suggestion from Meinersbur)
  • Add negative test case for loop that is not rotated.
This revision is now accepted and ready to land.Dec 5 2019, 1:09 PM
This revision was automatically updated to reflect the committed changes.