diff options
| author | Andrew Trick <atrick@apple.com> | 2012-01-07 00:27:31 +0000 |
|---|---|---|
| committer | Andrew Trick <atrick@apple.com> | 2012-01-07 00:27:31 +0000 |
| commit | 881a77687562546b31eae81d0a31f00b4c4d1722 (patch) | |
| tree | ea4a16ab316400a7157f0058069b9c0c5e1487c0 /llvm/lib/Analysis/ScalarEvolution.cpp | |
| parent | f64e1adcbb897446fc7a94a0d286c7bad4011704 (diff) | |
| download | bcm5719-llvm-881a77687562546b31eae81d0a31f00b4c4d1722.tar.gz bcm5719-llvm-881a77687562546b31eae81d0a31f00b4c4d1722.zip | |
Expose isNonConstantNegative to users of ScalarEvolution.
llvm-svn: 147700
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index daf7742b045..1fe72fd2b9a 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -284,6 +284,20 @@ bool SCEV::isAllOnesValue() const { return false; } +/// isNonConstantNegative - Return true if the specified scev is negated, but +/// not a constant. +bool SCEV::isNonConstantNegative() const { + const SCEVMulExpr *Mul = dyn_cast<SCEVMulExpr>(this); + if (!Mul) return false; + + // If there is a constant factor, it will be first. + const SCEVConstant *SC = dyn_cast<SCEVConstant>(Mul->getOperand(0)); + if (!SC) return false; + + // Return true if the value is negative, this matches things like (-42 * V). + return SC->getValue()->getValue().isNegative(); +} + SCEVCouldNotCompute::SCEVCouldNotCompute() : SCEV(FoldingSetNodeIDRef(), scCouldNotCompute) {} |

