[polly] r248882 - [NFC] Extract materialization of parameters

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 02:52:09 PDT 2015


Author: jdoerfert
Date: Wed Sep 30 04:52:08 2015
New Revision: 248882

URL: http://llvm.org/viewvc/llvm-project?rev=248882&view=rev
Log:
[NFC] Extract materialization of parameters

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

Modified: polly/trunk/include/polly/CodeGen/IslNodeBuilder.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/IslNodeBuilder.h?rev=248882&r1=248881&r2=248882&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/IslNodeBuilder.h (original)
+++ polly/trunk/include/polly/CodeGen/IslNodeBuilder.h Wed Sep 30 04:52:08 2015
@@ -117,6 +117,15 @@ protected:
   /// llvm::Values to new llvm::Values.
   polly::ValueMapT ValueMap;
 
+  /// @brief Materialize code for @p Id if it was not done before.
+  void materializeValue(__isl_take isl_id *Id);
+
+  /// @brief Materialize parameters of @p Set.
+  ///
+  /// @param All If not set only parameters referred to by the constraints in
+  ///            @p Set will be materialized, otherwise all.
+  void materializeParameters(__isl_take isl_set *Set, bool All);
+
   // Extract the upper bound of this loop
   //
   // The isl code generation can generate arbitrary expressions to check if the

Modified: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslNodeBuilder.cpp?rev=248882&r1=248881&r2=248882&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp Wed Sep 30 04:52:08 2015
@@ -814,6 +814,25 @@ void IslNodeBuilder::create(__isl_take i
   llvm_unreachable("Unknown isl_ast_node type");
 }
 
+void IslNodeBuilder::materializeValue(isl_id *Id) {
+  Value *&V = IDToValue[Id];
+
+  // If the Id is already mapped, skip it.
+  if (!V)
+    V = generateSCEV((const SCEV *)isl_id_get_user(Id));
+
+  isl_id_free(Id);
+}
+
+void IslNodeBuilder::materializeParameters(isl_set *Set, bool All) {
+  for (unsigned i = 0, e = isl_set_dim(Set, isl_dim_param); i < e; ++i) {
+    if (!All && !isl_set_involves_dims(Set, isl_dim_param, i, 1))
+      continue;
+    isl_id *Id = isl_set_get_dim_id(Set, isl_dim_param, i);
+    materializeValue(Id);
+  }
+}
+
 /// @brief Create the actual preload memory access for @p MA.
 static inline Value *createPreloadLoad(Scop &S, const MemoryAccess &MA,
                                        isl_ast_build *Build,
@@ -944,14 +963,8 @@ void IslNodeBuilder::preloadInvariantLoa
 
 void IslNodeBuilder::addParameters(__isl_take isl_set *Context) {
 
-  for (unsigned i = 0; i < isl_set_dim(Context, isl_dim_param); ++i) {
-    isl_id *Id;
-
-    Id = isl_set_get_dim_id(Context, isl_dim_param, i);
-    IDToValue[Id] = generateSCEV((const SCEV *)isl_id_get_user(Id));
-
-    isl_id_free(Id);
-  }
+  // Materialize values for the parameters of the SCoP.
+  materializeParameters(Context, /* all */ true);
 
   // Generate values for the current loop iteration for all surrounding loops.
   //




More information about the llvm-commits mailing list