[all-commits] [llvm/llvm-project] e4688b: [SimplifyCFG] Avoid increasing too many phi entrie...

Chengjun via All-commits all-commits at lists.llvm.org
Wed Sep 25 03:41:36 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e4688b98cd2b86035a2b563a8db0819710d6275a
      https://github.com/llvm/llvm-project/commit/e4688b98cd2b86035a2b563a8db0819710d6275a
  Author: Chengjun <chengjunp at Nvidia.com>
  Date:   2024-09-25 (Wed, 25 Sep 2024)

  Changed paths:
    M llvm/lib/Transforms/Utils/Local.cpp
    A llvm/test/Transforms/SimplifyCFG/avoid-complex-phi.ll

  Log Message:
  -----------
  [SimplifyCFG] Avoid increasing too many phi entries when removing empty blocks (#104887)

Now in the simplifycfg and jumpthreading passes, we will remove the
empty blocks (blocks only have phis and an unconditional branch).
However, in some cases, this will increase size of the IR and slow down
the compile of other passes dramatically. For example, we have the
following CFG:

1. BB1 has 100 predecessors, and unconditionally branches to BB2 (does
not have any other instructions).
2. BB2 has 100 phis.

Then in this case, if we remove BB1, for every phi in BB2, we need to
increase 99 entries (replace the incoming edge from BB1 with 100 edges
from its predecessors). Then in total, we will increase 9900 phi
entries, which can slow down the compile time for many other passes.

Therefore, in this change, we add a check to see whether removing the
empty blocks will increase lots of phi entries. Now, the threshold is
1000 (can be controlled by the command line option
`max-phi-entries-increase-after-removing-empty-block`), which means that
we will not remove an empty block if it will increase the total number
of phi entries by 1000. This threshold is conservative and for most of
the cases, we will not have such a large phi. So, this will only be
triggered in some unusual IRs.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list