[PATCH] D123230: [UnifyLoopExits] Reduce number of guard blocks

Brendon Cahoon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 6 09:05:27 PDT 2022


bcahoon created this revision.
bcahoon added a reviewer: sameerds.
Herald added a subscriber: hiraditya.
Herald added a project: All.
bcahoon requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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 and 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123230

Files:
  llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
  llvm/test/Transforms/UnifyLoopExits/reduce_guards.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123230.420906.patch
Type: text/x-patch
Size: 14427 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220406/976352e3/attachment.bin>


More information about the llvm-commits mailing list