summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-01-07 00:27:31 +0000
committerAndrew Trick <atrick@apple.com>2012-01-07 00:27:31 +0000
commit881a77687562546b31eae81d0a31f00b4c4d1722 (patch)
treeea4a16ab316400a7157f0058069b9c0c5e1487c0 /llvm/lib/Analysis/ScalarEvolution.cpp
parentf64e1adcbb897446fc7a94a0d286c7bad4011704 (diff)
downloadbcm5719-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.cpp14
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) {}
OpenPOWER on IntegriCloud