summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@apple.com>2014-04-03 01:38:47 +0000
committerJuergen Ributzka <juergen@apple.com>2014-04-03 01:38:47 +0000
commitc81000b8e908b722480bc23c04004ebab7720717 (patch)
treeecc73df53b98271fae8f0cbfb1e0db6cf0a3a359
parent6c9ed91ccae7f08784c234c26f1e2b4cbd8ed4d0 (diff)
downloadbcm5719-llvm-c81000b8e908b722480bc23c04004ebab7720717.tar.gz
bcm5719-llvm-c81000b8e908b722480bc23c04004ebab7720717.zip
Revert "[Constant Hoisting] Lazily compute the idom and cache the result."
This code is no longer usefull, because we only compute and use the IDom once. There is no benefit in caching it anymore. llvm-svn: 205498
-rw-r--r--llvm/lib/Transforms/Scalar/ConstantHoisting.cpp47
1 files changed, 4 insertions, 43 deletions
diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
index b8c282a4e56..57a15214e65 100644
--- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
@@ -87,10 +87,9 @@ struct ConstantCandidate {
struct RebasedConstantInfo {
ConstantUseListType Uses;
Constant *Offset;
- mutable BasicBlock *IDom;
RebasedConstantInfo(ConstantUseListType &&Uses, Constant *Offset)
- : Uses(Uses), Offset(Offset), IDom(nullptr) { }
+ : Uses(Uses), Offset(Offset) { }
};
/// \brief A base constant and all its rebased constants.
@@ -151,17 +150,6 @@ private:
Entry = nullptr;
}
- /// \brief Find the common dominator of all uses and cache the result for
- /// future lookup.
- BasicBlock *getIDom(const RebasedConstantInfo &RCI) const {
- if (RCI.IDom)
- return RCI.IDom;
- RCI.IDom = findIDomOfAllUses(RCI.Uses);
- assert(RCI.IDom && "Invalid IDom.");
- return RCI.IDom;
- }
-
- BasicBlock *findIDomOfAllUses(const ConstantUseListType &Uses) const;
Instruction *findMatInsertPt(Instruction *Inst, unsigned Idx = ~0U) const;
Instruction *findConstantInsertionPoint(const ConstantInfo &ConstInfo) const;
void collectConstantCandidates(ConstCandMapType &ConstCandMap,
@@ -214,32 +202,6 @@ bool ConstantHoisting::runOnFunction(Function &Fn) {
return MadeChange;
}
-/// \brief Find nearest common dominator of all uses.
-/// FIXME: Replace this with NearestCommonDominator once it is in common code.
-BasicBlock *
-ConstantHoisting::findIDomOfAllUses(const ConstantUseListType &Uses) const {
- // Collect all basic blocks.
- SmallPtrSet<BasicBlock *, 8> BBs;
- for (auto const &U : Uses)
- BBs.insert(findMatInsertPt(U.Inst, U.OpndIdx)->getParent());
-
- if (BBs.count(Entry))
- return Entry;
-
- while (BBs.size() >= 2) {
- BasicBlock *BB, *BB1, *BB2;
- BB1 = *BBs.begin();
- BB2 = *std::next(BBs.begin());
- BB = DT->findNearestCommonDominator(BB1, BB2);
- if (BB == Entry)
- return Entry;
- BBs.erase(BB1);
- BBs.erase(BB2);
- BBs.insert(BB);
- }
- assert((BBs.size() == 1) && "Expected only one element.");
- return *BBs.begin();
-}
/// \brief Find the constant materialization insertion point.
Instruction *ConstantHoisting::findMatInsertPt(Instruction *Inst,
@@ -262,12 +224,11 @@ Instruction *ConstantHoisting::findMatInsertPt(Instruction *Inst,
Instruction *ConstantHoisting::
findConstantInsertionPoint(const ConstantInfo &ConstInfo) const {
assert(!ConstInfo.RebasedConstants.empty() && "Invalid constant info entry.");
- // Collect all IDoms.
+ // Collect all basic blocks.
SmallPtrSet<BasicBlock *, 8> BBs;
for (auto const &RCI : ConstInfo.RebasedConstants)
- BBs.insert(getIDom(RCI));
-
- assert(!BBs.empty() && "No dominators!?");
+ for (auto const &U : RCI.Uses)
+ BBs.insert(U.Inst->getParent());
if (BBs.count(Entry))
return &Entry->front();
OpenPOWER on IntegriCloud