aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff options
context:
space:
mode:
authorGeoff Berry <gberry@codeaurora.org>2016-03-16 19:21:47 +0000
committerGeoff Berry <gberry@codeaurora.org>2016-03-16 19:21:47 +0000
commit56fabf9b55aba34691f6002f27aed28f1d72c3a5 (patch)
tree1cb24537f4e32ff6154627b4d3512333ad3c8c9f /llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
parenta03acfa3597b5df9e9358953868650c15b211c61 (diff)
downloadllvm-56fabf9b55aba34691f6002f27aed28f1d72c3a5.zip
llvm-56fabf9b55aba34691f6002f27aed28f1d72c3a5.tar.gz
llvm-56fabf9b55aba34691f6002f27aed28f1d72c3a5.tar.bz2
Revert "[LSR] Create fewer redundant instructions."
This reverts commit r263644. Investigating bootstrap failures. llvm-svn: 263655
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 3b0fccc..acfdec4 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -4331,28 +4331,7 @@ BasicBlock::iterator
LSRInstance::HoistInsertPosition(BasicBlock::iterator IP,
const SmallVectorImpl<Instruction *> &Inputs)
const {
- Instruction *Tentative = &*IP;
for (;;) {
- bool AllDominate = true;
- Instruction *BetterPos = nullptr;
- for (Instruction *Inst : Inputs) {
- if (Inst == Tentative || !DT.dominates(Inst, Tentative)) {
- AllDominate = false;
- break;
- }
- // Attempt to find an insert position in the middle of the block,
- // instead of at the end, so that it can be used for other expansions.
- if (Tentative->getParent() == Inst->getParent() &&
- (!BetterPos || !DT.dominates(Inst, BetterPos)))
- BetterPos = &*std::next(BasicBlock::iterator(Inst));
- }
- if (!AllDominate)
- break;
- if (BetterPos)
- IP = BetterPos->getIterator();
- else
- IP = Tentative->getIterator();
-
const Loop *IPLoop = LI.getLoopFor(IP->getParent());
unsigned IPLoopDepth = IPLoop ? IPLoop->getLoopDepth() : 0;
@@ -4371,7 +4350,26 @@ LSRInstance::HoistInsertPosition(BasicBlock::iterator IP,
break;
}
- Tentative = IDom->getTerminator();
+ bool AllDominate = true;
+ Instruction *BetterPos = nullptr;
+ Instruction *Tentative = IDom->getTerminator();
+ for (Instruction *Inst : Inputs) {
+ if (Inst == Tentative || !DT.dominates(Inst, Tentative)) {
+ AllDominate = false;
+ break;
+ }
+ // Attempt to find an insert position in the middle of the block,
+ // instead of at the end, so that it can be used for other expansions.
+ if (IDom == Inst->getParent() &&
+ (!BetterPos || !DT.dominates(Inst, BetterPos)))
+ BetterPos = &*std::next(BasicBlock::iterator(Inst));
+ }
+ if (!AllDominate)
+ break;
+ if (BetterPos)
+ IP = BetterPos->getIterator();
+ else
+ IP = Tentative->getIterator();
}
return IP;