[llvm] r198949 - SCEVRewriter: Optionally interpret constants in value map as SCEVConstant
Arnold Schwaighofer
aschwaighofer at apple.com
Fri Jan 10 10:20:29 PST 2014
Author: arnolds
Date: Fri Jan 10 12:20:29 2014
New Revision: 198949
URL: http://llvm.org/viewvc/llvm-project?rev=198949&view=rev
Log:
SCEVRewriter: Optionally interpret constants in value map as SCEVConstant
An upcoming loop vectorizer commit will want to replace a SCEVUnknown(Value*)
by a SCEVConstant. This commit modifies the SCEVParameterRewriter to support
this. The SCEVParameterRewriter constructor can optionally specify to follow
this behavior.
Modified:
llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h
Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=198949&r1=198948&r2=198949&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Fri Jan 10 12:20:29 2014
@@ -563,13 +563,14 @@ namespace llvm {
: public SCEVVisitor<SCEVParameterRewriter, const SCEV*> {
public:
static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE,
- ValueToValueMap &Map) {
- SCEVParameterRewriter Rewriter(SE, Map);
+ ValueToValueMap &Map,
+ bool InterpretConsts = false) {
+ SCEVParameterRewriter Rewriter(SE, Map, InterpretConsts);
return Rewriter.visit(Scev);
}
- SCEVParameterRewriter(ScalarEvolution &S, ValueToValueMap &M)
- : SE(S), Map(M) {}
+ SCEVParameterRewriter(ScalarEvolution &S, ValueToValueMap &M, bool C)
+ : SE(S), Map(M), InterpretConsts(C) {}
const SCEV *visitConstant(const SCEVConstant *Constant) {
return Constant;
@@ -632,8 +633,12 @@ namespace llvm {
const SCEV *visitUnknown(const SCEVUnknown *Expr) {
Value *V = Expr->getValue();
- if (Map.count(V))
- return SE.getUnknown(Map[V]);
+ if (Map.count(V)) {
+ Value *NV = Map[V];
+ if (InterpretConsts && isa<ConstantInt>(NV))
+ return SE.getConstant(cast<ConstantInt>(NV));
+ return SE.getUnknown(NV);
+ }
return Expr;
}
@@ -644,6 +649,7 @@ namespace llvm {
private:
ScalarEvolution &SE;
ValueToValueMap ⤅
+ bool InterpretConsts;
};
typedef DenseMap<const Loop*, const SCEV*> LoopToScevMapT;
More information about the llvm-commits
mailing list