diff --git a/polly/include/polly/CodeGen/BlockGenerators.h b/polly/include/polly/CodeGen/BlockGenerators.h index c44d2667a742..0e6d0cbdcdb1 100644 --- a/polly/include/polly/CodeGen/BlockGenerators.h +++ b/polly/include/polly/CodeGen/BlockGenerators.h @@ -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 <S, 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 <S, Loop *L) const; void copyInstScalar(const Instruction *Inst, ValueMapT &BBMap, ValueMapT &GlobalMap, LoopToScevMapT <S); diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index 73fb6e23697d..8d1734c39485 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -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 <S, + Loop *L) const { // We assume constants never change. // This avoids map lookups for many calls to this function. if (isa(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 <S, - 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(Old), L)) { if (!isa(Scev)) {