[PATCH] D110613: [Taildup] Don't tail-duplicate loop header with multiple successors as its latches
JunMa via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 11 02:41:26 PDT 2021
junparser added a comment.
In D110613#3054163 <https://reviews.llvm.org/D110613#3054163>, @lkail wrote:
>> @lkail @MatzeB any suggestion with the parameter value 128?
>
> From the perf data pasted by @alexfh in https://reviews.llvm.org/D106056, the compile time regression occurs in `MachineBlockPlacement` when CFG becomes complex. I think we should fix the issue there, i.e., fix the O(n^2) iteration by(There are multiple such usages, listed one)
It's not only MachineBlockPlacement pass, we saw Eliminate PHI and Control flow pass also cost much more time. with the ir file i attached above, it shows
6.1973 ( 46.3%) 0.0000 ( 0.0%) 6.1973 ( 45.8%) 6.2801 ( 45.8%) Eliminate PHI nodes for register allocation
2.3774 ( 17.7%) 0.0000 ( 0.0%) 2.3774 ( 17.6%) 2.4110 ( 17.6%) Control Flow Optimizer
0.9603 ( 7.2%) 0.0000 ( 0.0%) 0.9603 ( 7.1%) 0.9740 ( 7.1%) Branch Probability Basic Block Placement
0.4236 ( 3.2%) 0.0680 ( 50.6%) 0.4916 ( 3.6%) 0.4978 ( 3.6%) Early Tail Duplication
0.4374 ( 3.3%) 0.0000 ( 0.0%) 0.4374 ( 3.2%) 0.4455 ( 3.2%) Machine code sinking
> diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
> index 8a1b4031642d..56c3d3106a19 100644
> --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
> +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
> @@ -1905,8 +1905,11 @@ MachineBlockPlacement::TopFallThroughFreq(
> // Check if Top is the best successor of Pred.
> auto TopProb = MBPI->getEdgeProbability(Pred, Top);
> bool TopOK = true;
> - for (MachineBasicBlock *Succ : Pred->successors()) {
> - auto SuccProb = MBPI->getEdgeProbability(Pred, Succ);
> + for (MachineBasicBlock::succ_iterator SI = Pred->succ_begin(),
> + SE = Pred->succ_end();
> + SI != SE; ++SI) {
> + MachineBasicBlock *Succ = *SI;
> + auto SuccProb = MBPI->getEdgeProbability(Pred, SI);
> BlockChain *SuccChain = BlockToChain[Succ];
> // Check if Succ can be placed after Pred.
> // Succ should not be in any chain, or it is the head of some chain.
>
> This might give acceptable compile time.
Also I have test with this change, It does not work. The time is not consumed by find in getEdgeProbability
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110613/new/
https://reviews.llvm.org/D110613
More information about the llvm-commits
mailing list