CodeGen: BlockPlacement: Don't always tail-duplicate with no other successor.
The math works out where it can actually be counter-productive. The probability
calculations correctly handle the case where the alternative is 0 probability,
rely on those calculations.
Includes a test case that demonstrates the problem.
llvm-svn: 299892
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index c03ffdd..ffd88b7 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -1489,11 +1489,7 @@
if (DupProb < BestProb)
break;
if (canTailDuplicateUnplacedPreds(BB, Succ, Chain, BlockFilter)
- // If tail duplication gives us fallthrough when we otherwise wouldn't
- // have it, that is a strict gain.
- && (BestSucc.BB == nullptr
- || isProfitableToTailDup(BB, Succ, BestProb, Chain,
- BlockFilter))) {
+ && (isProfitableToTailDup(BB, Succ, BestProb, Chain, BlockFilter))) {
DEBUG(
dbgs() << " Candidate: " << getBlockName(Succ) << ", probability: "
<< DupProb