[llvm] 4c79864 - [NFC][SimplifyCFG] SinkCommonCodeFromPredecessors(): early return if nothing to sink
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 15 14:22:27 PDT 2020
Author: Roman Lebedev
Date: 2020-07-16T00:21:55+03:00
New Revision: 4c798644881abc4c43a7cdbc5df465fff04d03e3
URL: https://github.com/llvm/llvm-project/commit/4c798644881abc4c43a7cdbc5df465fff04d03e3
DIFF: https://github.com/llvm/llvm-project/commit/4c798644881abc4c43a7cdbc5df465fff04d03e3.diff
LOG: [NFC][SimplifyCFG] SinkCommonCodeFromPredecessors(): early return if nothing to sink
If we can't sink even one instruction, early return, to increase readability.
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 3a9326a1d120..74c7f0db01c2 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1800,7 +1800,6 @@ static bool SinkCommonCodeFromPredecessors(BasicBlock *BB) {
if (UnconditionalPreds.size() < 2)
return false;
- bool Changed = false;
// We take a two-step approach to tail sinking. First we scan from the end of
// each block upwards in lockstep. If the n'th instruction from the end of each
// block can be sunk, those instructions are added to ValuesToSink and we
@@ -1820,6 +1819,12 @@ static bool SinkCommonCodeFromPredecessors(BasicBlock *BB) {
--LRI;
}
+ // If no instructions can be sunk, early-return.
+ if (ScanIdx == 0)
+ return false;
+
+ bool Changed = false;
+
auto ProfitableToSinkInstruction = [&](LockstepReverseIterator &LRI) {
unsigned NumPHIdValues = 0;
for (auto *I : *LRI)
@@ -1834,7 +1839,7 @@ static bool SinkCommonCodeFromPredecessors(BasicBlock *BB) {
return NumPHIInsts <= 1;
};
- if (ScanIdx > 0 && Cond) {
+ if (Cond) {
// Check if we would actually sink anything first! This mutates the CFG and
// adds an extra block. The goal in doing this is to allow instructions that
// couldn't be sunk before to be sunk - obviously, speculatable instructions
More information about the llvm-commits
mailing list