This is an archive of the discontinued LLVM Phabricator instance.

[SimpleLoopUnswitch] After unswitch delete dead blocks in parent loops
ClosedPublic

Authored by fedor.sergeev on Aug 29 2018, 4:55 AM.

Details

Summary

Assert from PR38737 happens on the dead block inside the parent loop
after unswitching nontrivial switch in the inner loop.

deleteDeadBlocksFromLoop now takes extra care to detect/remove dead
blocks in all the parent loops in addition to the blocks from original
loop being unswitched.

Diff Detail

Event Timeline

fedor.sergeev created this revision.Aug 29 2018, 4:55 AM

Original unreduced testcase I was using when filing PR38737 also passes with this change.

asbirlea accepted this revision.Aug 29 2018, 11:00 AM

This LGTM.
FWIW, I think we're having an underlying problem and this and the previous PRs may be related.
In unswitchTrivialSwitch, at the very beginning we're removing switch cases and querying LoopInfo to get the outer loop for each switch successor without updating it. LoopInfo is updated only at the very end in hoistLoopToNewParent. Adding an artificial assert to check if LI should be updated after removing switch cases, triggers on 2/3 tests from D51375 and existing trivial-unswitch tests. Looking into it further.

This revision is now accepted and ready to land.Aug 29 2018, 11:00 AM
This revision was automatically updated to reflect the committed changes.