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 | f8fd841a4bb7a59f81cf4642169e8251e039acfe (patch) | |
tree | eee8c31311fd12826e6c40bbfb12f3c233fbaf71 /lib/Analysis/ScalarEvolution.cpp | |
parent | 4bf76e0e28c2cc358e1106b64cad2fa59714df53 (diff) |
Expose isNonConstantNegative to users of ScalarEvolution.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147700 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index daf7742b04..1fe72fd2b9 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/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) {} |