[all-commits] [llvm/llvm-project] f01d9e: [SimplifyCFG] Fix inconsistency in block size asse...

max-azul via All-commits all-commits at lists.llvm.org
Mon Jun 29 22:40:41 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f01d9e6fc3e291a2faed8c9b7dcbabf760f32bd6
      https://github.com/llvm/llvm-project/commit/f01d9e6fc3e291a2faed8c9b7dcbabf760f32bd6
  Author: Max Kazantsev <mkazantsev at azul.com>
  Date:   2020-06-30 (Tue, 30 Jun 2020)

  Changed paths:
    M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    M llvm/test/Transforms/SimplifyCFG/unprofitable-pr.ll

  Log Message:
  -----------
  [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




More information about the All-commits mailing list