[PATCH] D110613: [Taildup] Don't tail-duplicate loop header with multiple successors as its latches
Kai Luo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 10 21:37:40 PDT 2021
lkail added a comment.
> @lkail @MatzeB any suggestion with the parameter value 128?
I don't think it's a good idea to add such constraint in taildup pass when `-Oz` or `-Os` is not specified. 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)
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.
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