Page MenuHomePhabricator

[Loop] Add isRotated method to Loop class.
Needs ReviewPublic

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

Details

Summary

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.

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
llvm/include/llvm/Analysis/LoopInfo.h
763

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.

llvm/unittests/Analysis/LoopInfoTest.cpp
1214

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