mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-23 05:29:23 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198949 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3dbf2472fd
commit
db81071b34
@ -563,13 +563,14 @@ namespace llvm {
|
|||||||
: public SCEVVisitor<SCEVParameterRewriter, const SCEV*> {
|
: public SCEVVisitor<SCEVParameterRewriter, const SCEV*> {
|
||||||
public:
|
public:
|
||||||
static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE,
|
static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE,
|
||||||
ValueToValueMap &Map) {
|
ValueToValueMap &Map,
|
||||||
SCEVParameterRewriter Rewriter(SE, Map);
|
bool InterpretConsts = false) {
|
||||||
|
SCEVParameterRewriter Rewriter(SE, Map, InterpretConsts);
|
||||||
return Rewriter.visit(Scev);
|
return Rewriter.visit(Scev);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCEVParameterRewriter(ScalarEvolution &S, ValueToValueMap &M)
|
SCEVParameterRewriter(ScalarEvolution &S, ValueToValueMap &M, bool C)
|
||||||
: SE(S), Map(M) {}
|
: SE(S), Map(M), InterpretConsts(C) {}
|
||||||
|
|
||||||
const SCEV *visitConstant(const SCEVConstant *Constant) {
|
const SCEV *visitConstant(const SCEVConstant *Constant) {
|
||||||
return Constant;
|
return Constant;
|
||||||
@ -632,8 +633,12 @@ namespace llvm {
|
|||||||
|
|
||||||
const SCEV *visitUnknown(const SCEVUnknown *Expr) {
|
const SCEV *visitUnknown(const SCEVUnknown *Expr) {
|
||||||
Value *V = Expr->getValue();
|
Value *V = Expr->getValue();
|
||||||
if (Map.count(V))
|
if (Map.count(V)) {
|
||||||
return SE.getUnknown(Map[V]);
|
Value *NV = Map[V];
|
||||||
|
if (InterpretConsts && isa<ConstantInt>(NV))
|
||||||
|
return SE.getConstant(cast<ConstantInt>(NV));
|
||||||
|
return SE.getUnknown(NV);
|
||||||
|
}
|
||||||
return Expr;
|
return Expr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,6 +649,7 @@ namespace llvm {
|
|||||||
private:
|
private:
|
||||||
ScalarEvolution &SE;
|
ScalarEvolution &SE;
|
||||||
ValueToValueMap ⤅
|
ValueToValueMap ⤅
|
||||||
|
bool InterpretConsts;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef DenseMap<const Loop*, const SCEV*> LoopToScevMapT;
|
typedef DenseMap<const Loop*, const SCEV*> LoopToScevMapT;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user