This is an archive of the discontinued LLVM Phabricator instance.

[LoopSimplifyCFG] Delete dead exiting edges
ClosedPublic

Authored by mkazantsev on Nov 1 2018, 11:59 PM.

Details

Summary

This patch teaches LoopSimplifyCFG to remove dead exiting edges
from loops.

Diff Detail

Repository
rL LLVM

Event Timeline

mkazantsev created this revision.
dmgreen added a subscriber: dmgreen.Nov 4 2018, 1:03 PM
mkazantsev planned changes to this revision.Nov 6 2018, 9:30 PM

Needs rebase.

Rebased, lifted limitation related to breaking connectivity between nested and parent loops.

mkazantsev planned changes to this revision.Nov 20 2018, 10:50 PM

This might be buggy, I will add more tests and rebase it later.

False alarm, seems OK. Rebased on new tests.

fedor.sergeev added inline comments.Nov 22 2018, 12:56 AM
lib/Transforms/Scalar/LoopSimplifyCFG.cpp
256 ↗(On Diff #174875)

need to have the label name matching the switch (new_preheader vs preheader-split)

262 ↗(On Diff #174875)

%dead_exit_N ?

272 ↗(On Diff #174875)

Stray comment?

mkazantsev planned changes to this revision.Nov 22 2018, 4:24 AM
mkazantsev added inline comments.
lib/Transforms/Scalar/LoopSimplifyCFG.cpp
109 ↗(On Diff #174875)

We generate switches basing on this, and SmallPtrSet has a non-deterministic order. Need underlying NFC to make it a vector.

mkazantsev marked an inline comment as done.Nov 22 2018, 4:37 AM
mkazantsev added inline comments.
lib/Transforms/Scalar/LoopSimplifyCFG.cpp
109 ↗(On Diff #174875)
mkazantsev marked an inline comment as done.Nov 22 2018, 4:38 AM
mkazantsev marked 3 inline comments as done.

Fixed messy comments, rebased on top of deterministic collection of exit blocks, tests updated accordingly.

mkazantsev planned changes to this revision.Nov 29 2018, 1:10 AM
mkazantsev requested review of this revision.Dec 6 2018, 2:10 AM

Underlying patch merged, opening for review.

This revision is now accepted and ready to land.Dec 7 2018, 6:25 AM
fedor.sergeev added inline comments.Dec 7 2018, 6:29 AM
lib/Transforms/Scalar/LoopSimplifyCFG.cpp
262 ↗(On Diff #175039)

Minor nit - your current code splits preheader at terminator, so <preheader code> is left at preheader,
and preheader-split becomes just a block with a single branch and nothing else.
Please, correct the pseudo-code in comments here.

mkazantsev marked an inline comment as done.Dec 23 2018, 11:16 PM
This revision was automatically updated to reflect the committed changes.