Move SCEV::isLoopInvariant and hasComputableLoopEvolution to be member

functions of ScalarEvolution, in preparation for memoization and
other optimizations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119562 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2010-11-17 21:23:15 +00:00
parent f8dabac604
commit 17ead4ff4b
7 changed files with 163 additions and 154 deletions

View File

@@ -78,16 +78,6 @@ namespace llvm {
unsigned getSCEVType() const { return SCEVType; }
/// isLoopInvariant - Return true if the value of this SCEV is unchanging in
/// the specified loop.
virtual bool isLoopInvariant(const Loop *L) const = 0;
/// hasComputableLoopEvolution - Return true if this SCEV changes value in a
/// known way in the specified loop. This property being true implies that
/// the value is variant in the loop AND that we can emit an expression to
/// compute the value of the expression at any particular loop iteration.
virtual bool hasComputableLoopEvolution(const Loop *L) const = 0;
/// getType - Return the LLVM type of this SCEV expression.
///
virtual const Type *getType() const = 0;
@@ -156,9 +146,7 @@ namespace llvm {
SCEVCouldNotCompute();
// None of these methods are valid for this object.
virtual bool isLoopInvariant(const Loop *L) const;
virtual const Type *getType() const;
virtual bool hasComputableLoopEvolution(const Loop *L) const;
virtual void print(raw_ostream &OS) const;
virtual bool hasOperand(const SCEV *Op) const;
@@ -701,6 +689,16 @@ namespace llvm {
const SCEV *&LHS,
const SCEV *&RHS);
/// isLoopInvariant - Return true if the value of the given SCEV is
/// unchanging in the specified loop.
bool isLoopInvariant(const SCEV *S, const Loop *L);
/// hasComputableLoopEvolution - Return true if the given SCEV changes value
/// in a known way in the specified loop. This property being true implies
/// that the value is variant in the loop AND that we can emit an expression
/// to compute the value of the expression at any particular loop iteration.
bool hasComputableLoopEvolution(const SCEV *S, const Loop *L);
virtual bool runOnFunction(Function &F);
virtual void releaseMemory();
virtual void getAnalysisUsage(AnalysisUsage &AU) const;

View File

@@ -42,14 +42,6 @@ namespace llvm {
public:
ConstantInt *getValue() const { return V; }
virtual bool isLoopInvariant(const Loop *L) const {
return true;
}
virtual bool hasComputableLoopEvolution(const Loop *L) const {
return false; // Not loop variant
}
virtual const Type *getType() const;
virtual bool hasOperand(const SCEV *) const {
@@ -88,14 +80,6 @@ namespace llvm {
const SCEV *getOperand() const { return Op; }
virtual const Type *getType() const { return Ty; }
virtual bool isLoopInvariant(const Loop *L) const {
return Op->isLoopInvariant(L);
}
virtual bool hasComputableLoopEvolution(const Loop *L) const {
return Op->hasComputableLoopEvolution(L);
}
virtual bool hasOperand(const SCEV *O) const {
return Op == O || Op->hasOperand(O);
}
@@ -202,13 +186,6 @@ namespace llvm {
op_iterator op_begin() const { return Operands; }
op_iterator op_end() const { return Operands + NumOperands; }
virtual bool isLoopInvariant(const Loop *L) const;
// hasComputableLoopEvolution - N-ary expressions have computable loop
// evolutions iff they have at least one operand that varies with the loop,
// but that all varying operands are computable.
virtual bool hasComputableLoopEvolution(const Loop *L) const;
virtual bool hasOperand(const SCEV *O) const;
bool dominates(BasicBlock *BB, DominatorTree *DT) const;
@@ -328,15 +305,6 @@ namespace llvm {
const SCEV *getLHS() const { return LHS; }
const SCEV *getRHS() const { return RHS; }
virtual bool isLoopInvariant(const Loop *L) const {
return LHS->isLoopInvariant(L) && RHS->isLoopInvariant(L);
}
virtual bool hasComputableLoopEvolution(const Loop *L) const {
return LHS->hasComputableLoopEvolution(L) &&
RHS->hasComputableLoopEvolution(L);
}
virtual bool hasOperand(const SCEV *O) const {
return O == LHS || O == RHS || LHS->hasOperand(O) || RHS->hasOperand(O);
}
@@ -389,12 +357,6 @@ namespace llvm {
getLoop());
}
virtual bool hasComputableLoopEvolution(const Loop *QL) const {
return L == QL;
}
virtual bool isLoopInvariant(const Loop *QueryLoop) const;
bool dominates(BasicBlock *BB, DominatorTree *DT) const;
bool properlyDominates(BasicBlock *BB, DominatorTree *DT) const;
@@ -530,11 +492,6 @@ namespace llvm {
bool isAlignOf(const Type *&AllocTy) const;
bool isOffsetOf(const Type *&STy, Constant *&FieldNo) const;
virtual bool isLoopInvariant(const Loop *L) const;
virtual bool hasComputableLoopEvolution(const Loop *QL) const {
return false; // not computable
}
virtual bool hasOperand(const SCEV *) const {
return false;
}