[polly] r221388 - BlockGenerator: inline lookupAvailableValue into getValue [NFC]

Tobias Grosser tobias at grosser.es
Wed Nov 5 11:46:04 PST 2014


Author: grosser
Date: Wed Nov  5 13:46:04 2014
New Revision: 221388

URL: http://llvm.org/viewvc/llvm-project?rev=221388&view=rev
Log:
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.

Modified:
    polly/trunk/include/polly/CodeGen/BlockGenerators.h
    polly/trunk/lib/CodeGen/BlockGenerators.cpp

Modified: polly/trunk/include/polly/CodeGen/BlockGenerators.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/BlockGenerators.h?rev=221388&r1=221387&r2=221388&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/BlockGenerators.h (original)
+++ polly/trunk/include/polly/CodeGen/BlockGenerators.h Wed Nov  5 13:46:04 2014
@@ -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);

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=221388&r1=221387&r2=221388&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Wed Nov  5 13:46:04 2014
@@ -72,8 +72,9 @@ BlockGenerator::BlockGenerator(PollyIRBu
     : 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::lookupAvailableVa
   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)) {





More information about the llvm-commits mailing list