diff options
| author | Dan Gohman <gohman@apple.com> | 2009-05-18 15:22:39 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2009-05-18 15:22:39 +0000 |
| commit | ba7f6d8276a83042cd0147d4ae0b60d1c83fad5f (patch) | |
| tree | d1bb1612f012e09d48bbe6f289ac19506f136758 /llvm/lib/Analysis | |
| parent | b81dd48fd214c1757ad681c27cb20570f07e0d71 (diff) | |
| download | bcm5719-llvm-ba7f6d8276a83042cd0147d4ae0b60d1c83fad5f.tar.gz bcm5719-llvm-ba7f6d8276a83042cd0147d4ae0b60d1c83fad5f.zip | |
Add an isOne() utility function to ScalarEvolution, similar to isZero()
and similar to ConstantInt's isOne().
llvm-svn: 72003
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 77a80706314..4b99a869ff5 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -127,6 +127,11 @@ bool SCEV::isZero() const { return false; } +bool SCEV::isOne() const { + if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(this)) + return SC->getValue()->isOne(); + return false; +} SCEVCouldNotCompute::SCEVCouldNotCompute() : SCEV(scCouldNotCompute) {} SCEVCouldNotCompute::~SCEVCouldNotCompute() {} @@ -3392,7 +3397,7 @@ HowManyLessThans(const SCEV *LHS, const SCEV *RHS, const SCEVConstant *CStep = dyn_cast<SCEVConstant>(Step); if (!CStep || CStep->isZero()) return UnknownValue; - if (CStep->getValue()->getValue() == 1) { + if (CStep->isOne()) { // With unit stride, the iteration never steps past the limit value. } else if (CStep->getValue()->getValue().isStrictlyPositive()) { if (const SCEVConstant *CLimit = dyn_cast<SCEVConstant>(RHS)) { |

