[llvm-commits] [polly] r148326 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/ScopInfo.cpp

Tobias Grosser grosser at fim.uni-passau.de
Tue Jan 17 12:34:23 PST 2012


Author: grosser
Date: Tue Jan 17 14:34:23 2012
New Revision: 148326

URL: http://llvm.org/viewvc/llvm-project?rev=148326&view=rev
Log:
ScopInfo: Simplify some code

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/ScopInfo.cpp

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=148326&r1=148325&r2=148326&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Tue Jan 17 14:34:23 2012
@@ -294,6 +294,11 @@
   /// @return The iteration domain of this ScopStmt.
   isl_set *getDomain() const;
 
+  /// @brief Get the space of the iteration domain
+  ///
+  /// @return The space of the iteration domain
+  isl_space *getDomainSpace() const;
+
   /// @brief Get an isl string representing this domain.
   std::string getDomainStr() const;
 

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=148326&r1=148325&r2=148326&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Jan 17 14:34:23 2012
@@ -529,54 +529,30 @@
 }
 
 void ScopStmt::buildScattering(SmallVectorImpl<unsigned> &Scatter) {
-  unsigned NumberOfIterators = getNumIterators();
-  unsigned ScatSpace = Parent.getMaxLoopDepth() * 2 + 1;
-  isl_space *Space = isl_space_alloc(getIslCtx(), 0, NumberOfIterators,
-                                     ScatSpace);
+  unsigned NbIterators = getNumIterators();
+  unsigned NbScatteringDims = Parent.getMaxLoopDepth() * 2 + 1;
+
+  isl_space *Space = isl_space_alloc(getIslCtx(), 0, NbIterators,
+                                     NbScatteringDims);
   Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering");
   Space = isl_space_set_tuple_name(Space, isl_dim_in, getBaseName());
-  isl_local_space *LSpace = isl_local_space_from_space(isl_space_copy(Space));
-  isl_basic_map *bmap = isl_basic_map_universe(Space);
-  isl_int v;
-  isl_int_init(v);
 
-  // Loop dimensions.
-  for (unsigned i = 0; i < NumberOfIterators; ++i) {
-    isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LSpace));
-    isl_int_set_si(v, 1);
-    isl_constraint_set_coefficient(c, isl_dim_out, 2 * i + 1, v);
-    isl_int_set_si(v, -1);
-    isl_constraint_set_coefficient(c, isl_dim_in, i, v);
+  Scattering = isl_map_universe(Space);
 
-    bmap = isl_basic_map_add_constraint(bmap, c);
-  }
+  // Loop dimensions.
+  for (unsigned i = 0; i < NbIterators; ++i)
+    Scattering = isl_map_equate(Scattering, isl_dim_out, 2 * i + 1,
+                                isl_dim_in, i);
 
   // Constant dimensions
-  for (unsigned i = 0; i < NumberOfIterators + 1; ++i) {
-    isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LSpace));
-    isl_int_set_si(v, -1);
-    isl_constraint_set_coefficient(c, isl_dim_out, 2 * i, v);
-    isl_int_set_si(v, Scatter[i]);
-    isl_constraint_set_constant(c, v);
-
-    bmap = isl_basic_map_add_constraint(bmap, c);
-  }
+  for (unsigned i = 0; i < NbIterators + 1; ++i)
+    Scattering = isl_map_fix_si(Scattering, isl_dim_out, 2 * i, Scatter[i]);
 
   // Fill scattering dimensions.
-  for (unsigned i = 2 * NumberOfIterators + 1; i < ScatSpace ; ++i) {
-    isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LSpace));
-    isl_int_set_si(v, 1);
-    isl_constraint_set_coefficient(c, isl_dim_out, i, v);
-    isl_int_set_si(v, 0);
-    isl_constraint_set_constant(c, v);
-
-    bmap = isl_basic_map_add_constraint(bmap, c);
-  }
+  for (unsigned i = 2 * NbIterators + 1; i < NbScatteringDims; ++i)
+    Scattering = isl_map_fix_si(Scattering, isl_dim_out, i, 0);
 
-  isl_int_clear(v);
-  Scattering = isl_map_from_basic_map(bmap);
   Scattering = isl_map_align_params(Scattering, Parent.getParamSpace());
-  isl_local_space_free(LSpace);
 }
 
 void ScopStmt::buildAccesses(TempScop &tempScop, const Region &CurRegion) {
@@ -815,6 +791,10 @@
   return isl_set_copy(Domain);
 }
 
+isl_space *ScopStmt::getDomainSpace() const {
+  return isl_set_get_space(Domain);
+}
+
 ScopStmt::~ScopStmt() {
   while (!MemAccs.empty()) {
     delete MemAccs.back();





More information about the llvm-commits mailing list