This is an archive of the discontinued LLVM Phabricator instance.

[LoopUnroll] Use changeToUnreachable()
ClosedPublic

Authored by nikic on May 28 2021, 1:54 PM.

Details

Summary

When fulling unrolling with a non-latch exit, the latch block is folded to unreachable. Replace this folding with the existing changeToUnreachable() helper, rather than performing it manually.

This is not NFC because we now also drop all the instructions from the unreachable latch block. Previously we would only convert the terminator, and (later) DCE anything that is trivially dead.

Diff Detail

Event Timeline

nikic created this revision.May 28 2021, 1:54 PM
nikic requested review of this revision.May 28 2021, 1:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 28 2021, 1:54 PM
reames accepted this revision.May 28 2021, 2:16 PM

I have two concerns with this patch.

  1. This is moving the code from before the dom tree rewrite to after. Is the dom tree rewrite correct with the changed CFG? From what I can tell, it is, but critical thought here is warranted.
  2. Previously a throwing instruction in the last latch block was left in place. If we ever had a case where we computed a trap count from a known throwing instruction, the new behavior is different than the old behavior. I don't know of anything which does this, but I think I'd prefer to be conservative here.

LGTM w/the unreachable moved to the end of the latch block.

This revision is now accepted and ready to land.May 28 2021, 2:16 PM
nikic added a comment.May 28 2021, 3:02 PM

I have two concerns with this patch.

  1. This is moving the code from before the dom tree rewrite to after. Is the dom tree rewrite correct with the changed CFG? From what I can tell, it is, but critical thought here is warranted.

Right, this is part of the motivation here: moving code out of the scope of the tricky manual dom tree update code. I believe that this is correct, because the particular CFG change that is performed here is one that does not affect the DT at all: The removal of an unconditional backedge.

  1. Previously a throwing instruction in the last latch block was left in place. If we ever had a case where we computed a trap count from a known throwing instruction, the new behavior is different than the old behavior. I don't know of anything which does this, but I think I'd prefer to be conservative here.

LGTM w/the unreachable moved to the end of the latch block.

Okay, I'll do that, which should make this an NFC change.

This revision was landed with ongoing or failed builds.May 28 2021, 3:11 PM
This revision was automatically updated to reflect the committed changes.