HomePhabricator

[SimplifyCFG] Fix inconsistency in block size assessment for threading

Authored by mkazantsev on Mon, Jun 29, 10:38 PM.

Description

[SimplifyCFG] Fix inconsistency in block size assessment for threading

Sometimes SimplifyCFG may decide to perform jump threading. In order
to do it, it follows the following algorithm:

  1. Checks if the block is small enough for threading;
  2. If yes, inserts a PR Phi relying that the next iteration will remove it by performing jump threading;
  3. The next iteration checks the block again and performs the threading.

This logic has a corner case: inserting the PR Phi increases block's size
by 1. If the block size at first check was max possible, one more Phi will
exceed this size, and we will neither perform threading nor remove the
created Phi node. As result, we will end up with worse IR than before.

This patch fixes this situation by excluding Phis from block size computation.
Excluding Phis from size computation for threading also makes sense by
itself because in case of threadign all those Phis will be removed.

Differential Revision: https://reviews.llvm.org/D81835
Reviewed By: asbirlea, nikic

Details

Committed
mkazantsevMon, Jun 29, 10:40 PM
Reviewer
asbirlea
Differential Revision
D81835: [SimplifyCFG] Fix inconsistency in block size assessment for threading
Parents
rG11cd97701746: Add missing #include
Branches
Unknown
Tags
Unknown