summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2016-12-15 03:02:15 +0000
committerHal Finkel <hfinkel@anl.gov>2016-12-15 03:02:15 +0000
commit3ca4a6bcf11d6b4ac34fed640f3ab23995ec1877 (patch)
tree4594d31d24d9535dd4f5198505a25dd88c0f8fb5 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parentcb9f78e1c3951337de4ba24902eced2c72184319 (diff)
downloadbcm5719-llvm-3ca4a6bcf11d6b4ac34fed640f3ab23995ec1877.tar.gz
bcm5719-llvm-3ca4a6bcf11d6b4ac34fed640f3ab23995ec1877.zip
Remove the AssumptionCache
After r289755, the AssumptionCache is no longer needed. Variables affected by assumptions are now found by using the new operand-bundle-based scheme. This new scheme is more computationally efficient, and also we need much less code... llvm-svn: 289756
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp75
1 files changed, 36 insertions, 39 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 2f4e3e99b3f..5889f940670 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -166,7 +166,6 @@ class SimplifyCFGOpt {
const TargetTransformInfo &TTI;
const DataLayout &DL;
unsigned BonusInstThreshold;
- AssumptionCache *AC;
SmallPtrSetImpl<BasicBlock *> *LoopHeaders;
Value *isValueEqualityComparison(TerminatorInst *TI);
BasicBlock *GetValueEqualityComparisonCases(
@@ -190,9 +189,9 @@ class SimplifyCFGOpt {
public:
SimplifyCFGOpt(const TargetTransformInfo &TTI, const DataLayout &DL,
- unsigned BonusInstThreshold, AssumptionCache *AC,
+ unsigned BonusInstThreshold,
SmallPtrSetImpl<BasicBlock *> *LoopHeaders)
- : TTI(TTI), DL(DL), BonusInstThreshold(BonusInstThreshold), AC(AC),
+ : TTI(TTI), DL(DL), BonusInstThreshold(BonusInstThreshold),
LoopHeaders(LoopHeaders) {}
bool run(BasicBlock *BB);
@@ -3474,8 +3473,7 @@ static bool SimplifyIndirectBrOnSelect(IndirectBrInst *IBI, SelectInst *SI) {
/// the PHI, merging the third icmp into the switch.
static bool TryToSimplifyUncondBranchWithICmpInIt(
ICmpInst *ICI, IRBuilder<> &Builder, const DataLayout &DL,
- const TargetTransformInfo &TTI, unsigned BonusInstThreshold,
- AssumptionCache *AC) {
+ const TargetTransformInfo &TTI, unsigned BonusInstThreshold) {
BasicBlock *BB = ICI->getParent();
// If the block has any PHIs in it or the icmp has multiple uses, it is too
@@ -3510,7 +3508,7 @@ static bool TryToSimplifyUncondBranchWithICmpInIt(
ICI->eraseFromParent();
}
// BB is now empty, so it is likely to simplify away.
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
}
// Ok, the block is reachable from the default dest. If the constant we're
@@ -3526,7 +3524,7 @@ static bool TryToSimplifyUncondBranchWithICmpInIt(
ICI->replaceAllUsesWith(V);
ICI->eraseFromParent();
// BB is now empty, so it is likely to simplify away.
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
}
// The use of the icmp has to be in the 'end' block, by the only PHI node in
@@ -4323,17 +4321,16 @@ static bool TurnSwitchRangeIntoICmp(SwitchInst *SI, IRBuilder<> &Builder) {
/// Compute masked bits for the condition of a switch
/// and use it to remove dead cases.
-static bool EliminateDeadSwitchCases(SwitchInst *SI, AssumptionCache *AC,
- const DataLayout &DL) {
+static bool EliminateDeadSwitchCases(SwitchInst *SI, const DataLayout &DL) {
Value *Cond = SI->getCondition();
unsigned Bits = Cond->getType()->getIntegerBitWidth();
APInt KnownZero(Bits, 0), KnownOne(Bits, 0);
- computeKnownBits(Cond, KnownZero, KnownOne, DL, 0, AC, SI);
+ computeKnownBits(Cond, KnownZero, KnownOne, DL, 0, SI);
// We can also eliminate cases by determining that their values are outside of
// the limited range of the condition based on how many significant (non-sign)
// bits are in the condition value.
- unsigned ExtraSignBits = ComputeNumSignBits(Cond, DL, 0, AC, SI) - 1;
+ unsigned ExtraSignBits = ComputeNumSignBits(Cond, DL, 0, SI) - 1;
unsigned MaxSignificantBitsInCond = Bits - ExtraSignBits;
// Gather dead cases.
@@ -4753,7 +4750,7 @@ static void RemoveSwitchAfterSelectConversion(SwitchInst *SI, PHINode *PHI,
/// phi nodes in a common successor block with only two different
/// constant values, replace the switch with select.
static bool SwitchToSelect(SwitchInst *SI, IRBuilder<> &Builder,
- AssumptionCache *AC, const DataLayout &DL,
+ const DataLayout &DL,
const TargetTransformInfo &TTI) {
Value *const Cond = SI->getCondition();
PHINode *PHI = nullptr;
@@ -5500,12 +5497,12 @@ bool SimplifyCFGOpt::SimplifySwitch(SwitchInst *SI, IRBuilder<> &Builder) {
// see if that predecessor totally determines the outcome of this switch.
if (BasicBlock *OnlyPred = BB->getSinglePredecessor())
if (SimplifyEqualityComparisonWithOnlyPredecessor(SI, OnlyPred, Builder))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
Value *Cond = SI->getCondition();
if (SelectInst *Select = dyn_cast<SelectInst>(Cond))
if (SimplifySwitchOnSelect(SI, Select))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
// If the block only contains the switch, see if we can fold the block
// away into any preds.
@@ -5515,28 +5512,28 @@ bool SimplifyCFGOpt::SimplifySwitch(SwitchInst *SI, IRBuilder<> &Builder) {
++BBI;
if (SI == &*BBI)
if (FoldValueComparisonIntoPredecessors(SI, Builder))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
}
// Try to transform the switch into an icmp and a branch.
if (TurnSwitchRangeIntoICmp(SI, Builder))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
// Remove unreachable cases.
- if (EliminateDeadSwitchCases(SI, AC, DL))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ if (EliminateDeadSwitchCases(SI, DL))
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
- if (SwitchToSelect(SI, Builder, AC, DL, TTI))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ if (SwitchToSelect(SI, Builder, DL, TTI))
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
if (ForwardSwitchConditionToPHI(SI))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
if (SwitchToLookupTable(SI, Builder, DL, TTI))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
if (ReduceSwitchRange(SI, Builder, DL, TTI))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
return false;
}
@@ -5574,7 +5571,7 @@ bool SimplifyCFGOpt::SimplifyIndirectBr(IndirectBrInst *IBI) {
if (SelectInst *SI = dyn_cast<SelectInst>(IBI->getAddress())) {
if (SimplifyIndirectBrOnSelect(IBI, SI))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
}
return Changed;
}
@@ -5683,7 +5680,7 @@ bool SimplifyCFGOpt::SimplifyUncondBranch(BranchInst *BI,
;
if (I->isTerminator() &&
TryToSimplifyUncondBranchWithICmpInIt(ICI, Builder, DL, TTI,
- BonusInstThreshold, AC))
+ BonusInstThreshold))
return true;
}
@@ -5701,7 +5698,7 @@ bool SimplifyCFGOpt::SimplifyUncondBranch(BranchInst *BI,
// predecessor and use logical operations to update the incoming value
// for PHI nodes in common successor.
if (FoldBranchToCommonDest(BI, BonusInstThreshold))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
return false;
}
@@ -5726,7 +5723,7 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
// switch.
if (BasicBlock *OnlyPred = BB->getSinglePredecessor())
if (SimplifyEqualityComparisonWithOnlyPredecessor(BI, OnlyPred, Builder))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
// This block must be empty, except for the setcond inst, if it exists.
// Ignore dbg intrinsics.
@@ -5736,14 +5733,14 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
++I;
if (&*I == BI) {
if (FoldValueComparisonIntoPredecessors(BI, Builder))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
} else if (&*I == cast<Instruction>(BI->getCondition())) {
++I;
// Ignore dbg intrinsics.
while (isa<DbgInfoIntrinsic>(I))
++I;
if (&*I == BI && FoldValueComparisonIntoPredecessors(BI, Builder))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
}
}
@@ -5770,7 +5767,7 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
: ConstantInt::getFalse(BB->getContext());
BI->setCondition(CI);
RecursivelyDeleteTriviallyDeadInstructions(OldCond);
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
}
}
}
@@ -5779,7 +5776,7 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
// branches to us and one of our successors, fold the comparison into the
// predecessor and use logical operations to pick the right destination.
if (FoldBranchToCommonDest(BI, BonusInstThreshold))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
// We have a conditional branch to two blocks that are only reachable
// from BI. We know that the condbr dominates the two blocks, so see if
@@ -5788,7 +5785,7 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
if (BI->getSuccessor(0)->getSinglePredecessor()) {
if (BI->getSuccessor(1)->getSinglePredecessor()) {
if (HoistThenElseCodeToIf(BI, TTI))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
} else {
// If Successor #1 has multiple preds, we may be able to conditionally
// execute Successor #0 if it branches to Successor #1.
@@ -5796,7 +5793,7 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
if (Succ0TI->getNumSuccessors() == 1 &&
Succ0TI->getSuccessor(0) == BI->getSuccessor(1))
if (SpeculativelyExecuteBB(BI, BI->getSuccessor(0), TTI))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
}
} else if (BI->getSuccessor(1)->getSinglePredecessor()) {
// If Successor #0 has multiple preds, we may be able to conditionally
@@ -5805,7 +5802,7 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
if (Succ1TI->getNumSuccessors() == 1 &&
Succ1TI->getSuccessor(0) == BI->getSuccessor(0))
if (SpeculativelyExecuteBB(BI, BI->getSuccessor(1), TTI))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
}
// If this is a branch on a phi node in the current block, thread control
@@ -5813,14 +5810,14 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
if (PHINode *PN = dyn_cast<PHINode>(BI->getCondition()))
if (PN->getParent() == BI->getParent())
if (FoldCondBranchOnPHI(BI, DL))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
// Scan predecessor blocks for conditional branches.
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI)
if (BranchInst *PBI = dyn_cast<BranchInst>((*PI)->getTerminator()))
if (PBI != BI && PBI->isConditional())
if (SimplifyCondBranchToCondBranch(PBI, BI, DL))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
// Look for diamond patterns.
if (MergeCondStores)
@@ -5828,7 +5825,7 @@ bool SimplifyCFGOpt::SimplifyCondBranch(BranchInst *BI, IRBuilder<> &Builder) {
if (BranchInst *PBI = dyn_cast<BranchInst>(PrevBB->getTerminator()))
if (PBI != BI && PBI->isConditional())
if (mergeConditionalStores(PBI, BI))
- return SimplifyCFG(BB, TTI, BonusInstThreshold, AC) | true;
+ return SimplifyCFG(BB, TTI, BonusInstThreshold) | true;
return false;
}
@@ -5990,9 +5987,9 @@ bool SimplifyCFGOpt::run(BasicBlock *BB) {
/// of the CFG. It returns true if a modification was made.
///
bool llvm::SimplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
- unsigned BonusInstThreshold, AssumptionCache *AC,
+ unsigned BonusInstThreshold,
SmallPtrSetImpl<BasicBlock *> *LoopHeaders) {
return SimplifyCFGOpt(TTI, BB->getModule()->getDataLayout(),
- BonusInstThreshold, AC, LoopHeaders)
+ BonusInstThreshold, LoopHeaders)
.run(BB);
}
OpenPOWER on IntegriCloud