[all-commits] [llvm/llvm-project] e13248: [UnifyLoopExits] Reduce number of guard blocks

bcahoon via All-commits all-commits at lists.llvm.org
Wed Jun 22 13:49:06 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e13248ab0e79b59d5e5ac73e2fe57d82ce485ce1
      https://github.com/llvm/llvm-project/commit/e13248ab0e79b59d5e5ac73e2fe57d82ce485ce1
  Author: Brendon Cahoon <brendon.cahoon at amd.com>
  Date:   2022-06-22 (Wed, 22 Jun 2022)

  Changed paths:
    M llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
    A llvm/test/Transforms/UnifyLoopExits/reduce_guards.ll

  Log Message:
  -----------
  [UnifyLoopExits] Reduce number of guard blocks

UnifyLoopExits creates a single exit, a control flow hub, for
loops with multiple exits. There is an input to the block for
each loop exiting block and an output from the block for each
loop exit block. Multiple checks, or guard blocks, are needed
to branch to the correct exit block.

For large loops with lots of exit blocks, all the extra guard
blocks cause problems for StructurizeCFG and subsequent passes.
This patch reduces the number of guard blocks needed when the
exit blocks branch to a common block (e.g., an unreachable
block). The guard blocks are reduced by changing the inputs
and outputs of the control flow hub. The inputs are the exit
blocks and the outputs are the common block.

Reducing the guard blocks enables StructurizeCFG to reorder the
basic blocks in the CFG to reduce the values that exit a loop
with multiple exits. This reduces the compile-time of
StructurizeCFG and also reduces register pressure.

Differential Revision: https://reviews.llvm.org/D123230




More information about the All-commits mailing list