mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +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:
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user