This is an archive of the discontinued LLVM Phabricator instance.

[Loopinfo] Remove one latch case in getLoopID. NFC.
ClosedPublic

Authored by Meinersbur on Sep 14 2018, 12:54 PM.

Details

Summary

getLoopID has different control flow for two cases: If there is a
single loop latch and for any other number of loop latches (0 and more
than one). The latter case should return the same result if there is
only a single latch. We can save the preceding redundant search for a
latch by handling both cases with the same code.

Diff Detail

Repository
rL LLVM

Event Timeline

Meinersbur created this revision.Sep 14 2018, 12:54 PM
jdoerfert accepted this revision.Sep 15 2018, 3:49 AM

save an iteration over the loop's basic blocks (which is what getLoopLatch does)

I'm not sure this is true. getLoopLatch() in LoopInfoImpl.h
only traverses the children of the header in the inverse graph.
That should, I think, be similar to predecessors(Header) in case
of the IR CFG.

That being said, the patch makes sense to me and it is a simple,
straightforward improvement. I don't see any downsides and
it simplifies the code.

LGTM

This revision is now accepted and ready to land.Sep 15 2018, 3:49 AM
Meinersbur edited the summary of this revision. (Show Details)Sep 17 2018, 11:40 AM

save an iteration over the loop's basic blocks (which is what getLoopLatch does)

I'm not sure this is true. getLoopLatch() in LoopInfoImpl.h
only traverses the children of the header in the inverse graph.
That should, I think, be similar to predecessors(Header) in case
of the IR CFG.

You're right. I changed the summary/commit message accordingly.

This revision was automatically updated to reflect the committed changes.