summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-01-27 02:43:22 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-01-27 02:43:22 +0000
commit47de2140f7b2e094a03b3ab40c9ab3f4cc911677 (patch)
treec96a321674c801c7f0a99957fe4ceb56f1885eda /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent7cbc78e72b799a962eb5da3185dd1b6881cbf4ab (diff)
downloadbcm5719-llvm-47de2140f7b2e094a03b3ab40c9ab3f4cc911677.tar.gz
bcm5719-llvm-47de2140f7b2e094a03b3ab40c9ab3f4cc911677.zip
Revert "[SimplifyCFG] allow speculation of exactly one expensive instruction (PR24818)"
This reverts commit r255660. llvm-svn: 258903
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp23
1 files changed, 4 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 8cb1573fb9c..b6d87c22e43 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -85,11 +85,6 @@ static cl::opt<bool> MergeCondStoresAggressively(
cl::desc("When merging conditional stores, do so even if the resultant "
"basic blocks are unlikely to be if-converted as a result"));
-static cl::opt<bool> SpeculateOneExpensiveInst(
- "speculate-one-expensive-inst", cl::Hidden, cl::init(true),
- cl::desc("Allow exactly one expensive instruction to be speculatively "
- "executed"));
-
STATISTIC(NumBitMaps, "Number of switch instructions turned into bitmaps");
STATISTIC(NumLinearMaps, "Number of switch instructions turned into linear mapping");
STATISTIC(NumLookupTables, "Number of switch instructions turned into lookup tables");
@@ -267,8 +262,7 @@ static unsigned ComputeSpeculationCost(const User *I,
static bool DominatesMergePoint(Value *V, BasicBlock *BB,
SmallPtrSetImpl<Instruction*> *AggressiveInsts,
unsigned &CostRemaining,
- const TargetTransformInfo &TTI,
- unsigned Depth = 0) {
+ const TargetTransformInfo &TTI) {
Instruction *I = dyn_cast<Instruction>(V);
if (!I) {
// Non-instructions all dominate instructions, but not all constantexprs
@@ -306,24 +300,15 @@ static bool DominatesMergePoint(Value *V, BasicBlock *BB,
unsigned Cost = ComputeSpeculationCost(I, TTI);
- // Allow exactly one instruction to be speculated regardless of its cost
- // (as long as it is safe to do so).
- // This is intended to flatten the CFG even if the instruction is a division
- // or other expensive operation. The speculation of an expensive instruction
- // is expected to be undone in CodeGenPrepare if the speculation has not
- // enabled further IR optimizations.
- if (Cost > CostRemaining &&
- (!SpeculateOneExpensiveInst || !AggressiveInsts->empty() || Depth > 0))
+ if (Cost > CostRemaining)
return false;
- // Avoid unsigned wrap.
- CostRemaining = (Cost > CostRemaining) ? 0 : CostRemaining - Cost;
+ CostRemaining -= Cost;
// Okay, we can only really hoist these out if their operands do
// not take us over the cost threshold.
for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i)
- if (!DominatesMergePoint(*i, BB, AggressiveInsts, CostRemaining, TTI,
- Depth + 1))
+ if (!DominatesMergePoint(*i, BB, AggressiveInsts, CostRemaining, TTI))
return false;
// Okay, it's safe to do this! Remember this instruction.
AggressiveInsts->insert(I);
OpenPOWER on IntegriCloud