diff options
author | Sjoerd Meijer <sjoerd.meijer@arm.com> | 2021-02-16 14:43:44 +0000 |
---|---|---|
committer | Sjoerd Meijer <sjoerd.meijer@arm.com> | 2021-02-17 08:50:53 +0000 |
commit | 7f3170ec1943a25a09beb0a989ebc83c9c238f97 (patch) | |
tree | 599b5a4bc22b223c72b29e3ec34411cb107e73ee /llvm/lib/CodeGen/MachineSink.cpp | |
parent | ac6c13bfc49f2d67a77144c839ecf49e48cb994c (diff) | |
download | llvm-7f3170ec1943a25a09beb0a989ebc83c9c238f97.zip llvm-7f3170ec1943a25a09beb0a989ebc83c9c238f97.tar.gz llvm-7f3170ec1943a25a09beb0a989ebc83c9c238f97.tar.bz2 |
[MachineSink] Add a loop sink limit
To make sure compile-times don't regress, add an option to restrict the number
of instructions considered for sinking as alias analysis can be expensive and
for the same reason also skip large blocks.
Differential Revision: https://reviews.llvm.org/D96485
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineSink.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp index 832147e..0ac176e 100644 --- a/llvm/lib/CodeGen/MachineSink.cpp +++ b/llvm/lib/CodeGen/MachineSink.cpp @@ -97,6 +97,11 @@ SinkInstsIntoLoop("sink-insts-to-avoid-spills", "register spills"), cl::init(false), cl::Hidden); +static cl::opt<unsigned> SinkIntoLoopLimit( + "machine-sink-loop-limit", + cl::desc("The maximum number of instructions considered for loop sinking."), + cl::init(50), cl::Hidden); + STATISTIC(NumSunk, "Number of machine instructions sunk"); STATISTIC(NumLoopSunk, "Number of machine instructions sunk into a loop"); STATISTIC(NumSplit, "Number of critical edges split"); @@ -468,7 +473,15 @@ bool MachineSinking::runOnMachineFunction(MachineFunction &MF) { // Walk the candidates in reverse order so that we start with the use // of a def-use chain, if there is any. + // TODO: Sort the candidates using a cost-model. + unsigned i = 0; for (auto It = Candidates.rbegin(); It != Candidates.rend(); ++It) { + if (i++ == SinkIntoLoopLimit) { + LLVM_DEBUG(dbgs() << "LoopSink: Limit reached of instructions to " + "be analysed."); + break; + } + MachineInstr *I = *It; if (!SinkIntoLoop(L, *I)) break; @@ -1243,6 +1256,10 @@ bool MachineSinking::SinkIntoLoop(MachineLoop *L, MachineInstr &I) { LLVM_DEBUG(dbgs() << "LoopSink: Not sinking, sink block is the preheader\n"); return false; } + if (SinkBlock->size() > SinkLoadInstsPerBlockThreshold) { + LLVM_DEBUG(dbgs() << "LoopSink: Not Sinking, block too large to analyse.\n"); + return false; + } LLVM_DEBUG(dbgs() << "LoopSink: Sinking instruction!\n"); SinkBlock->splice(SinkBlock->getFirstNonPHI(), Preheader, I); |