diff options
author | Dan Gohman <gohman@apple.com> | 2008-06-18 16:23:07 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-06-18 16:23:07 +0000 |
commit | 7b560c4218a3eac6af49b43d14003e30c9024b94 (patch) | |
tree | cce837286c2b0aac98e2442e475309248f7a24c4 /lib/Analysis | |
parent | 7dabe38781d34c681ca6dff9a5df1de7e44308d5 (diff) | |
download | external_llvm-7b560c4218a3eac6af49b43d14003e30c9024b94.zip external_llvm-7b560c4218a3eac6af49b43d14003e30c9024b94.tar.gz external_llvm-7b560c4218a3eac6af49b43d14003e30c9024b94.tar.bz2 |
Move LSR's private isZero function to a public SCEV member
function, and make use of it in several places.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52463 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 20 | ||||
-rw-r--r-- | lib/Analysis/ScalarEvolutionExpander.cpp | 3 |
2 files changed, 13 insertions, 10 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index ae3d100..36da85b 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -132,6 +132,12 @@ uint32_t SCEV::getBitWidth() const { return 0; } +bool SCEV::isZero() const { + if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(this)) + return SC->getValue()->isZero(); + return false; +} + SCEVCouldNotCompute::SCEVCouldNotCompute() : SCEV(scCouldNotCompute) {} @@ -1136,11 +1142,10 @@ SCEVHandle ScalarEvolution::getAddRecExpr(std::vector<SCEVHandle> &Operands, const Loop *L) { if (Operands.size() == 1) return Operands[0]; - if (SCEVConstant *StepC = dyn_cast<SCEVConstant>(Operands.back())) - if (StepC->getValue()->isZero()) { - Operands.pop_back(); - return getAddRecExpr(Operands, L); // { X,+,0 } --> X - } + if (Operands.back()->isZero()) { + Operands.pop_back(); + return getAddRecExpr(Operands, L); // { X,+,0 } --> X + } SCEVAddRecExpr *&Result = (*SCEVAddRecExprs)[std::make_pair(L, std::vector<SCEV*>(Operands.begin(), @@ -2583,9 +2588,8 @@ SCEVHandle ScalarEvolutionsImpl::HowFarToZero(SCEV *V, const Loop *L) { // value at this index. When solving for "X*X != 5", for example, we // should not accept a root of 2. SCEVHandle Val = AddRec->evaluateAtIteration(R1, SE); - if (SCEVConstant *EvalVal = dyn_cast<SCEVConstant>(Val)) - if (EvalVal->getValue()->isZero()) - return R1; // We found a quadratic root! + if (Val->isZero()) + return R1; // We found a quadratic root! } } } diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 9872ced..e7bc3f2 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -126,8 +126,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) { assert(Ty->isInteger() && "Cannot expand fp recurrences yet!"); // {X,+,F} --> X + {0,+,F} - if (!isa<SCEVConstant>(S->getStart()) || - !cast<SCEVConstant>(S->getStart())->getValue()->isZero()) { + if (!S->getStart()->isZero()) { Value *Start = expand(S->getStart()); std::vector<SCEVHandle> NewOps(S->op_begin(), S->op_end()); NewOps[0] = SE.getIntegerSCEV(0, Ty); |