This is an archive of the discontinued LLVM Phabricator instance.

[LoopDeletion] Handle switch in proving that loop exits on first iteration
ClosedPublic

Authored by dmakogon on Jul 9 2021, 2:50 AM.

Details

Summary

Added check for switch-terminated blocks in loops.
Now if a block is terminated with a switch, we try to find out which of the cases is taken on 1st iteration and mark corresponding edge from the block to the case successor as live.

Diff Detail

Event Timeline

dmakogon created this revision.Jul 9 2021, 2:50 AM
dmakogon requested review of this revision.Jul 9 2021, 2:50 AM
dmakogon updated this revision to Diff 357462.Jul 9 2021, 2:57 AM

Updated test checks

Fine by me, but please someone else take a look.

nikic accepted this revision.Jul 9 2021, 3:10 AM

LGTM as well.

llvm/lib/Transforms/Scalar/LoopDeletion.cpp
321

Just as a side-note: I think it would be nice to move the SimplifyICmpInst handling into getValueOnFirstIteration(), and then this could just directly work on the br argument.

This revision is now accepted and ready to land.Jul 9 2021, 3:10 AM

Good idea, we'll follow-up with this as NFC.

This revision was landed with ongoing or failed builds.Jul 9 2021, 4:05 AM
This revision was automatically updated to reflect the committed changes.