summaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2008-02-20 06:48:22 +0000
committerNick Lewycky <nicholas@mxc.ca>2008-02-20 06:48:22 +0000
commit3e6307698084e7adfc10b739442ae29742beefd0 (patch)
treeebc561431001a1c949d932f9f8224b4ed7391ee9 /include/llvm
parent19fc1d3742ccba2d8dde5d69c5593e1a0b83fefa (diff)
downloadexternal_llvm-3e6307698084e7adfc10b739442ae29742beefd0.zip
external_llvm-3e6307698084e7adfc10b739442ae29742beefd0.tar.gz
external_llvm-3e6307698084e7adfc10b739442ae29742beefd0.tar.bz2
Add 'umax' similar to 'smax' SCEV. Closes PR2003.
Parse reversed smax and umax as smin and umin and express them with negative or binary-not SCEVs (which are really just subtract under the hood). Parse 'xor %x, -1' as (-1 - %x). Remove dead code (ConstantInt::get always returns a ConstantInt). Don't use getIntegerSCEV(-1, Ty). The first value is an int, then it gets passed into a uint64_t. Instead, create the -1 directly from ConstantInt::getAllOnesValue(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47360 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Analysis/ScalarEvolution.h6
-rw-r--r--include/llvm/Analysis/ScalarEvolutionExpander.h2
-rw-r--r--include/llvm/Analysis/ScalarEvolutionExpressions.h30
3 files changed, 35 insertions, 3 deletions
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h
index ecf28ad..4d9d5e5 100644
--- a/include/llvm/Analysis/ScalarEvolution.h
+++ b/include/llvm/Analysis/ScalarEvolution.h
@@ -237,12 +237,18 @@ namespace llvm {
}
SCEVHandle getSMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
SCEVHandle getSMaxExpr(std::vector<SCEVHandle> Operands);
+ SCEVHandle getUMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
+ SCEVHandle getUMaxExpr(std::vector<SCEVHandle> Operands);
SCEVHandle getUnknown(Value *V);
/// getNegativeSCEV - Return the SCEV object corresponding to -V.
///
SCEVHandle getNegativeSCEV(const SCEVHandle &V);
+ /// getNotSCEV - Return the SCEV object corresponding to ~V.
+ ///
+ SCEVHandle getNotSCEV(const SCEVHandle &V);
+
/// getMinusSCEV - Return LHS-RHS.
///
SCEVHandle getMinusSCEV(const SCEVHandle &LHS,
diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h
index 530ce37..584e488 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpander.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpander.h
@@ -136,6 +136,8 @@ namespace llvm {
Value *visitSMaxExpr(SCEVSMaxExpr *S);
+ Value *visitUMaxExpr(SCEVUMaxExpr *S);
+
Value *visitUnknown(SCEVUnknown *S) {
return S->getValue();
}
diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h
index 409ad9e..905493a 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -25,7 +25,8 @@ namespace llvm {
// These should be ordered in terms of increasing complexity to make the
// folders simpler.
scConstant, scTruncate, scZeroExtend, scSignExtend, scAddExpr, scMulExpr,
- scUDivExpr, scAddRecExpr, scSMaxExpr, scUnknown, scCouldNotCompute
+ scUDivExpr, scAddRecExpr, scUMaxExpr, scSMaxExpr, scUnknown,
+ scCouldNotCompute
};
//===--------------------------------------------------------------------===//
@@ -275,7 +276,8 @@ namespace llvm {
static inline bool classof(const SCEV *S) {
return S->getSCEVType() == scAddExpr ||
S->getSCEVType() == scMulExpr ||
- S->getSCEVType() == scSMaxExpr;
+ S->getSCEVType() == scSMaxExpr ||
+ S->getSCEVType() == scUMaxExpr;
}
};
@@ -483,6 +485,27 @@ namespace llvm {
//===--------------------------------------------------------------------===//
+ /// SCEVUMaxExpr - This class represents an unsigned maximum selection.
+ ///
+ class SCEVUMaxExpr : public SCEVCommutativeExpr {
+ friend class ScalarEvolution;
+
+ explicit SCEVUMaxExpr(const std::vector<SCEVHandle> &ops)
+ : SCEVCommutativeExpr(scUMaxExpr, ops) {
+ }
+
+ public:
+ virtual const char *getOperationStr() const { return " umax "; }
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const SCEVUMaxExpr *S) { return true; }
+ static inline bool classof(const SCEV *S) {
+ return S->getSCEVType() == scUMaxExpr;
+ }
+ };
+
+
+ //===--------------------------------------------------------------------===//
/// SCEVUnknown - This means that we are dealing with an entirely unknown SCEV
/// value, and only represent it as it's LLVM Value. This is the "bottom"
/// value for the analysis.
@@ -546,6 +569,8 @@ namespace llvm {
return ((SC*)this)->visitAddRecExpr((SCEVAddRecExpr*)S);
case scSMaxExpr:
return ((SC*)this)->visitSMaxExpr((SCEVSMaxExpr*)S);
+ case scUMaxExpr:
+ return ((SC*)this)->visitUMaxExpr((SCEVUMaxExpr*)S);
case scUnknown:
return ((SC*)this)->visitUnknown((SCEVUnknown*)S);
case scCouldNotCompute:
@@ -565,4 +590,3 @@ namespace llvm {
}
#endif
-