[llvm] [CodeGen] Perform early program return instead of using indirect branch (PR #102127)
Vikash Gupta via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 03:02:25 PDT 2024
vg0204 wrote:
@arsenm, the following constraints on tail duplication in machineBlockPlacement has to be strictly followed if it has to realize the early return optimization.
> [ BB -control-flow-> return block(RB) ]
1. The RB (BB'ssuccessor) should be post dominating i.e. the control should reach RB from all possible path from BB till the graph end.
> This constraints might eliminate chances of early in presence of multiple return blocks.
2. The BB to RB edge probability should be greater than 50%.
> This constraints makes sense to avoid tail duplication.
3. The RB should be eligible for tail-duplication & also all its predessor (including BB) should be capable of tail-duplicating RB into them respectively. [as per Tail duplicator utility].
> It considers lot of stuff not really effecting if early return is attempted
And so, both the test cases added yet does not get optimized (as for branch-early-return-unconditional gets optimized way before in branchFolder pass) as one or the more above constraint is not satisfied eventhough scope for early return is there.
https://github.com/llvm/llvm-project/pull/102127
More information about the llvm-commits
mailing list