[llvm-commits] [llvm] r72003 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp
Dan Gohman
gohman at apple.com
Mon May 18 08:22:40 PDT 2009
Author: djg
Date: Mon May 18 10:22:39 2009
New Revision: 72003
URL: http://llvm.org/viewvc/llvm-project?rev=72003&view=rev
Log:
Add an isOne() utility function to ScalarEvolution, similar to isZero()
and similar to ConstantInt's isOne().
Modified:
llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=72003&r1=72002&r2=72003&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Mon May 18 10:22:39 2009
@@ -77,6 +77,10 @@
///
bool isZero() const;
+ /// isOne - Return true if the expression is a constant one.
+ ///
+ bool isOne() const;
+
/// replaceSymbolicValuesWithConcrete - If this SCEV internally references
/// the symbolic value "Sym", construct and return a new SCEV that produces
/// the same value, but which uses the concrete value Conc instead of the
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=72003&r1=72002&r2=72003&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon May 18 10:22:39 2009
@@ -127,6 +127,11 @@
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 @@
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)) {
More information about the llvm-commits
mailing list