aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2007-11-25 22:41:31 +0000
committerNick Lewycky <nicholas@mxc.ca>2007-11-25 22:41:31 +0000
commitc54c561c9f7270c055dd7ba75a3a003b771a42d9 (patch)
tree89d177bb9a1e54eae89f8c6a73192dcc9971159d /include
parentcfa597569d79a8b53cc4faa9725a66e246a19866 (diff)
downloadexternal_llvm-c54c561c9f7270c055dd7ba75a3a003b771a42d9.zip
external_llvm-c54c561c9f7270c055dd7ba75a3a003b771a42d9.tar.gz
external_llvm-c54c561c9f7270c055dd7ba75a3a003b771a42d9.tar.bz2
Add new SCEV, SCEVSMax. This allows LLVM to analyze do-while loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44319 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/ScalarEvolution.h2
-rw-r--r--include/llvm/Analysis/ScalarEvolutionExpander.h2
-rw-r--r--include/llvm/Analysis/ScalarEvolutionExpressions.h29
3 files changed, 31 insertions, 2 deletions
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h
index a52f273..d0886e8 100644
--- a/include/llvm/Analysis/ScalarEvolution.h
+++ b/include/llvm/Analysis/ScalarEvolution.h
@@ -235,6 +235,8 @@ namespace llvm {
std::vector<SCEVHandle> NewOp(Operands);
return getAddRecExpr(NewOp, L);
}
+ SCEVHandle getSMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
+ SCEVHandle getSMaxExpr(std::vector<SCEVHandle> Operands);
SCEVHandle getUnknown(Value *V);
/// getNegativeSCEV - Return the SCEV object corresponding to -V.
diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h
index 8582067..6529902 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpander.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpander.h
@@ -134,6 +134,8 @@ namespace llvm {
Value *visitAddRecExpr(SCEVAddRecExpr *S);
+ Value *visitSMaxExpr(SCEVSMaxExpr *S);
+
Value *visitUnknown(SCEVUnknown *S) {
return S->getValue();
}
diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h
index fb69a90..f639243 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpressions.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h
@@ -25,7 +25,7 @@ namespace llvm {
// These should be ordered in terms of increasing complexity to make the
// folders simpler.
scConstant, scTruncate, scZeroExtend, scSignExtend, scAddExpr, scMulExpr,
- scSDivExpr, scAddRecExpr, scUnknown, scCouldNotCompute
+ scSDivExpr, scAddRecExpr, scSMaxExpr, scUnknown, scCouldNotCompute
};
//===--------------------------------------------------------------------===//
@@ -274,7 +274,8 @@ namespace llvm {
static inline bool classof(const SCEVCommutativeExpr *S) { return true; }
static inline bool classof(const SCEV *S) {
return S->getSCEVType() == scAddExpr ||
- S->getSCEVType() == scMulExpr;
+ S->getSCEVType() == scMulExpr ||
+ S->getSCEVType() == scSMaxExpr;
}
};
@@ -459,6 +460,28 @@ namespace llvm {
}
};
+
+ //===--------------------------------------------------------------------===//
+ /// SCEVSMaxExpr - This class represents a signed maximum selection.
+ ///
+ class SCEVSMaxExpr : public SCEVCommutativeExpr {
+ friend class ScalarEvolution;
+
+ explicit SCEVSMaxExpr(const std::vector<SCEVHandle> &ops)
+ : SCEVCommutativeExpr(scSMaxExpr, ops) {
+ }
+
+ public:
+ virtual const char *getOperationStr() const { return " smax "; }
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const SCEVSMaxExpr *S) { return true; }
+ static inline bool classof(const SCEV *S) {
+ return S->getSCEVType() == scSMaxExpr;
+ }
+ };
+
+
//===--------------------------------------------------------------------===//
/// 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"
@@ -521,6 +544,8 @@ namespace llvm {
return ((SC*)this)->visitSDivExpr((SCEVSDivExpr*)S);
case scAddRecExpr:
return ((SC*)this)->visitAddRecExpr((SCEVAddRecExpr*)S);
+ case scSMaxExpr:
+ return ((SC*)this)->visitSMaxExpr((SCEVSMaxExpr*)S);
case scUnknown:
return ((SC*)this)->visitUnknown((SCEVUnknown*)S);
case scCouldNotCompute: