[polly] r205958 - ScopInfo: Scalar accesses are zero dimensional

Tobias Grosser tobias at grosser.es
Thu Apr 10 01:38:02 PDT 2014


Author: grosser
Date: Thu Apr 10 03:38:02 2014
New Revision: 205958

URL: http://llvm.org/viewvc/llvm-project?rev=205958&view=rev
Log:
ScopInfo: Scalar accesses are zero dimensional

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/include/polly/TempScopInfo.h
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/lib/Analysis/TempScopInfo.cpp
    polly/trunk/test/ScopInfo/scalar.ll

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=205958&r1=205957&r2=205958&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Thu Apr 10 03:38:02 2014
@@ -172,6 +172,9 @@ public:
   /// statement.
   bool isStrideZero(__isl_take const isl_map *Schedule) const;
 
+  /// @brief Check if this is a scalar memory access.
+  bool isScalar() const;
+
   /// @brief Get the statement that contains this memory access.
   ScopStmt *getStatement() const { return Statement; }
 

Modified: polly/trunk/include/polly/TempScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/TempScopInfo.h?rev=205958&r1=205957&r2=205958&view=diff
==============================================================================
--- polly/trunk/include/polly/TempScopInfo.h (original)
+++ polly/trunk/include/polly/TempScopInfo.h Thu Apr 10 03:38:02 2014
@@ -43,9 +43,6 @@ public:
   enum TypeKind {
     READ = 0x1,
     WRITE = 0x2,
-    SCALAR = 0x4,
-    SCALARREAD = SCALAR | READ,
-    SCALARWRITE = SCALAR | WRITE
   };
 
 private:
@@ -73,11 +70,11 @@ public:
 
   bool isAffine() const { return IsAffine; }
 
-  bool isRead() const { return Type & READ; }
+  bool isRead() const { return Type == READ; }
 
-  bool isWrite() const { return Type & WRITE; }
+  bool isWrite() const { return Type == WRITE; }
 
-  bool isScalar() const { return Type & SCALAR; }
+  bool isScalar() const { return Subscripts.size() == 0; }
 
   void print(raw_ostream &OS) const;
 };

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=205958&r1=205957&r2=205958&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Thu Apr 10 03:38:02 2014
@@ -335,11 +335,11 @@ MemoryAccess::MemoryAccess(const IRAcces
 
   Type = Access.isRead() ? READ : MUST_WRITE;
 
-  int Size = Access.Subscripts.size();
-  assert(Size > 0 && "access function with no subscripts");
-  AccessRelation = NULL;
+  isl_space *Space = isl_space_alloc(Statement->getIslCtx(), 0,
+                                     Statement->getNumIterators(), 0);
+  AccessRelation = isl_map_universe(Space);
 
-  for (int i = 0; i < Size; ++i) {
+  for (int i = 0, Size = Access.Subscripts.size(); i < Size; ++i) {
     isl_pw_aff *Affine =
         SCEVAffinator::getPwAff(Statement, Access.Subscripts[i]);
 
@@ -360,13 +360,10 @@ MemoryAccess::MemoryAccess(const IRAcces
 
     isl_map *SubscriptMap = isl_map_from_pw_aff(Affine);
 
-    if (!AccessRelation)
-      AccessRelation = SubscriptMap;
-    else
-      AccessRelation = isl_map_flat_range_product(AccessRelation, SubscriptMap);
+    AccessRelation = isl_map_flat_range_product(AccessRelation, SubscriptMap);
   }
 
-  isl_space *Space = Statement->getDomainSpace();
+  Space = Statement->getDomainSpace();
   AccessRelation = isl_map_set_tuple_id(
       AccessRelation, isl_dim_in, isl_space_get_tuple_id(Space, isl_dim_set));
   isl_space_free(Space);
@@ -490,6 +487,10 @@ bool MemoryAccess::isStrideZero(const is
   return isStrideX(Schedule, 0);
 }
 
+bool MemoryAccess::isScalar() const {
+  return isl_map_n_out(AccessRelation) == 0;
+}
+
 bool MemoryAccess::isStrideOne(const isl_map *Schedule) const {
   return isStrideX(Schedule, 1);
 }

Modified: polly/trunk/lib/Analysis/TempScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/TempScopInfo.cpp?rev=205958&r1=205957&r2=205958&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/TempScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/TempScopInfo.cpp Thu Apr 10 03:38:02 2014
@@ -132,13 +132,11 @@ bool TempScopInfo::buildScalarDependence
     assert(!isa<PHINode>(UI) && "Non synthesizable PHINode found in a SCoP!");
 
     SmallVector<const SCEV *, 4> Subscripts, Sizes;
-    Subscripts.push_back(SE->getConstant(ZeroOffset->getType(), 0));
-    Sizes.push_back(SE->getConstant(ZeroOffset->getType(), 1));
 
     // Use the def instruction as base address of the IRAccess, so that it will
     // become the name of the scalar access in the polyhedral form.
-    IRAccess ScalarAccess(IRAccess::SCALARREAD, Inst, ZeroOffset, 1, true,
-                          Subscripts, Sizes);
+    IRAccess ScalarAccess(IRAccess::READ, Inst, ZeroOffset, 1, true, Subscripts,
+                          Sizes);
     AccFuncMap[UseParent].push_back(std::make_pair(ScalarAccess, UI));
   }
 
@@ -212,9 +210,7 @@ void TempScopInfo::buildAccessFunctions(
       // If the Instruction is used outside the statement, we need to build the
       // write access.
       SmallVector<const SCEV *, 4> Subscripts, Sizes;
-      Subscripts.push_back(SE->getConstant(ZeroOffset->getType(), 0));
-      Sizes.push_back(SE->getConstant(ZeroOffset->getType(), 1));
-      IRAccess ScalarAccess(IRAccess::SCALARWRITE, Inst, ZeroOffset, 1, true,
+      IRAccess ScalarAccess(IRAccess::WRITE, Inst, ZeroOffset, 1, true,
                             Subscripts, Sizes);
       Functions.push_back(std::make_pair(ScalarAccess, Inst));
     }

Modified: polly/trunk/test/ScopInfo/scalar.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/scalar.ll?rev=205958&r1=205957&r2=205958&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/scalar.ll (original)
+++ polly/trunk/test/ScopInfo/scalar.ll Thu Apr 10 03:38:02 2014
@@ -38,13 +38,13 @@ return:
 ; CHECK:       ReadAccess :=
 ; CHECK:           [N] -> { Stmt_S1[i0] -> MemRef_a[i0] };
 ; CHECK:       MustWriteAccess :=
-; CHECK:           [N] -> { Stmt_S1[i0] -> MemRef_val[0] };
+; CHECK:           [N] -> { Stmt_S1[i0] -> MemRef_val[] };
 ; CHECK: Stmt_S2
 ; CHECK:       Domain :=
 ; CHECK:           [N] -> { Stmt_S2[i0] : i0 >= 0 and i0 <= -1 + N };
 ; CHECK:       Scattering :=
 ; CHECK:           [N] -> { Stmt_S2[i0] -> scattering[0, i0, 1] };
 ; CHECK:       ReadAccess :=
-; CHECK:           [N] -> { Stmt_S2[i0] -> MemRef_val[0] };
+; CHECK:           [N] -> { Stmt_S2[i0] -> MemRef_val[] };
 ; CHECK:       MustWriteAccess :=
 ; CHECK:           [N] -> { Stmt_S2[i0] -> MemRef_a[i0] };





More information about the llvm-commits mailing list