summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-05-07 23:36:59 +0000
committerDan Gohman <gohman@apple.com>2010-05-07 23:36:59 +0000
commitd0800241d27b281afa9d130fa9ccb6928bb2e42d (patch)
tree8ba16568b211674795fc49d88780c0c3e4366184 /llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
parent0625af2a888e9603bfded090da6f4cff17460d14 (diff)
downloadbcm5719-llvm-d0800241d27b281afa9d130fa9ccb6928bb2e42d.tar.gz
bcm5719-llvm-d0800241d27b281afa9d130fa9ccb6928bb2e42d.zip
When pruning candidate formulae out of an LSRUse, update the
LSRUse's Regs set after all pruning is done, rather than trying to do it on the fly, which can produce an incomplete result. This fixes a case where heuristic pruning was stripping all formulae from a use, which led the solver to enter an infinite loop. Also, add a few asserts to diagnose this kind of situation. llvm-svn: 103328
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index cf3d16f05db..61966f52f51 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -2592,9 +2592,6 @@ void LSRInstance::FilterOutUndesirableDedicatedRegisters() {
LSRUse &LU = Uses[LUIdx];
FormulaSorter Sorter(L, LU, SE, DT);
- // Clear out the set of used regs; it will be recomputed.
- LU.Regs.clear();
-
for (size_t FIdx = 0, NumForms = LU.Formulae.size();
FIdx != NumForms; ++FIdx) {
Formula &F = LU.Formulae[FIdx];
@@ -2632,9 +2629,18 @@ void LSRInstance::FilterOutUndesirableDedicatedRegisters() {
--NumForms;
continue;
}
+ }
+
+ // Now that we've filtered out some formulae, recompute the Regs set.
+ LU.Regs.clear();
+ for (size_t FIdx = 0, NumForms = LU.Formulae.size();
+ FIdx != NumForms; ++FIdx) {
+ Formula &F = LU.Formulae[FIdx];
if (F.ScaledReg) LU.Regs.insert(F.ScaledReg);
LU.Regs.insert(F.BaseRegs.begin(), F.BaseRegs.end());
}
+
+ // Reset this to prepare for the next use.
BestFormulae.clear();
}
@@ -2718,6 +2724,7 @@ void LSRInstance::NarrowSearchSpaceUsingHeuristics() {
LU.Formulae.pop_back();
--e;
--i;
+ assert(e != 0 && "Use has no formulae left! Is Regs inconsistent?");
continue;
}
@@ -2810,6 +2817,7 @@ retry:
// If none of the formulae had all of the required registers, relax the
// constraint so that we don't exclude all formulae.
if (!AnySatisfiedReqRegs) {
+ assert(!ReqRegs.empty() && "Solver failed even without required registers");
ReqRegs.clear();
goto retry;
}
OpenPOWER on IntegriCloud