[BasicBlockUtils] Add a new way for CreateControlFlowHub()
authorBrendon Cahoon <brendon.cahoon@amd.com>
Sun, 9 Oct 2022 22:34:57 +0000 (17:34 -0500)
committerBrendon Cahoon <brendon.cahoon@amd.com>
Mon, 31 Oct 2022 13:58:54 +0000 (08:58 -0500)
commitf59205aef957da9017285d4c0bb6f9c6f244621f
tree22f3cfeb43e20311b5386979eb3bcdf0c7448276
parent64959325eb470489ca5757b9bd6eef97b402a0da
[BasicBlockUtils] Add a new way for CreateControlFlowHub()

The existing way of creating the predicate in the guard blocks uses
a boolean value per outgoing block. This increases the number of live
booleans as the number of outgoing blocks increases. The new way added
in this change is to store one integer to represent the outgoing block
we want to branch to, then at each guard block, an integer equality
check is performed to decide which a specific outgoing block is taken.

Using an integer reduces the number of live values and decreases
register pressure especially in cases where there are a large number
of outgoing blocks. The integer based approach is used when the
number of outgoing blocks crosses a threshold, which is currently set
to 32.

Patch by Ruiling Song.

Differential review: https://reviews.llvm.org/D127831
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
llvm/lib/Transforms/Utils/UnifyLoopExits.cpp
llvm/test/CodeGen/AMDGPU/si-annotate-cf.ll
llvm/test/Transforms/FixIrreducible/basic.ll
llvm/test/Transforms/StructurizeCFG/workarounds/needs-fr-ule.ll
llvm/test/Transforms/StructurizeCFG/workarounds/needs-unified-loop-exits.ll
llvm/test/Transforms/UnifyLoopExits/integer_guards.ll [new file with mode: 0644]
llvm/test/Transforms/UnifyLoopExits/nested.ll
llvm/test/Transforms/UnifyLoopExits/restore-ssa.ll