BlockGenerator: inline lookupAvailableValue into getValue [NFC]

There was no good reason why this code was split accross two functions.

In subsequent changes we will change the order in which values are looked up.
Doing so would make the split into two functions even more arbitrary.

We also slightly improve the documentation.

llvm-svn: 221388
This commit is contained in:
Tobias Grosser 2014-11-05 19:46:04 +00:00
parent f2676a5afc
commit d213a8b810
2 changed files with 11 additions and 26 deletions

View File

@ -100,7 +100,13 @@ protected:
ScalarEvolution &SE, __isl_keep isl_ast_build *Build,
IslExprBuilder *ExprBuilder);
/// @brief Get the new version of a Value.
/// @brief Get the new version of a value.
///
/// Given an old value, we first check if a new version of this value is
/// available in the BBMap or GlobalMap. If the value is scop constant, we
/// assume it is a parameter and return the old value. In case it is not and
/// the value can be recomputed using SCEV, we do so. If the value can still
/// not be derived, this function will assert.
///
/// @param Old The old Value.
/// @param BBMap A mapping from old values to their new values
@ -120,20 +126,7 @@ protected:
/// o The new value, if available.
/// o NULL, if no value is found.
Value *getNewValue(const Value *Old, ValueMapT &BBMap, ValueMapT &GlobalMap,
LoopToScevMapT &LTS, Loop *L);
/// @brief Get the new version of a Value if it is available.
///
/// @param Old The old Value.
/// @param BBMap A mapping from old values to their new values
/// (for values recalculated within this basic block).
/// @param GlobalMap A mapping from old values to their new values
/// (for values recalculated in the new ScoP, but not
/// within this basic block).
///
/// @returns The new value, if available.
Value *lookupAvailableValue(const Value *Old, ValueMapT &BBMap,
ValueMapT &GlobalMap) const;
LoopToScevMapT &LTS, Loop *L) const;
void copyInstScalar(const Instruction *Inst, ValueMapT &BBMap,
ValueMapT &GlobalMap, LoopToScevMapT &LTS);

View File

@ -72,8 +72,9 @@ BlockGenerator::BlockGenerator(PollyIRBuilder &B, ScopStmt &Stmt, Pass *P,
: Builder(B), Statement(Stmt), P(P), LI(LI), SE(SE), Build(Build),
ExprBuilder(ExprBuilder) {}
Value *BlockGenerator::lookupAvailableValue(const Value *Old, ValueMapT &BBMap,
ValueMapT &GlobalMap) const {
Value *BlockGenerator::getNewValue(const Value *Old, ValueMapT &BBMap,
ValueMapT &GlobalMap, LoopToScevMapT &LTS,
Loop *L) const {
// We assume constants never change.
// This avoids map lookups for many calls to this function.
if (isa<Constant>(Old))
@ -99,15 +100,6 @@ Value *BlockGenerator::lookupAvailableValue(const Value *Old, ValueMapT &BBMap,
if (Value *New = BBMap.lookup(Old))
return New;
return nullptr;
}
Value *BlockGenerator::getNewValue(const Value *Old, ValueMapT &BBMap,
ValueMapT &GlobalMap, LoopToScevMapT &LTS,
Loop *L) {
if (Value *New = lookupAvailableValue(Old, BBMap, GlobalMap))
return New;
if (SCEVCodegen && SE.isSCEVable(Old->getType()))
if (const SCEV *Scev = SE.getSCEVAtScope(const_cast<Value *>(Old), L)) {
if (!isa<SCEVCouldNotCompute>(Scev)) {