[polly] r184658 - ScopInfo: Clarify may-write and must-write accesses

Tobias Grosser grosser at fim.uni-passau.de
Sat Jun 22 22:21:18 PDT 2013


Author: grosser
Date: Sun Jun 23 00:21:18 2013
New Revision: 184658

URL: http://llvm.org/viewvc/llvm-project?rev=184658&view=rev
Log:
ScopInfo: Clarify may-write and must-write accesses

Modified:
    polly/trunk/include/polly/ScopInfo.h
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/test/ScopInfo/loop_carry.ll
    polly/trunk/test/ScopInfo/multidim_ivs_and_integer_offsets_3d.ll
    polly/trunk/test/ScopInfo/multidim_ivs_and_parameteric_offsets_3d.ll
    polly/trunk/test/ScopInfo/multidim_only_ivs_2d.ll

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=184658&r1=184657&r2=184658&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Sun Jun 23 00:21:18 2013
@@ -65,7 +65,6 @@ class MemoryAccess {
   // DO NOT IMPLEMENT
   const MemoryAccess &operator=(const MemoryAccess &);
 
-public:
   /// @brief The access type of a memory access
   ///
   /// There are three kind of access types:
@@ -75,24 +74,23 @@ public:
   /// A certain set of memory locations are read and may be used for internal
   /// calculations.
   ///
-  /// * A write access
+  /// * A must-write access
   ///
   /// A certain set of memory locactions is definitely written. The old value is
   /// replaced by a newly calculated value. The old value is not read or used at
   /// all.
   ///
-  /// * A may write access
+  /// * A may-write access
   ///
   /// A certain set of memory locactions may be written. The memory location may
   /// contain a new value if there is actually a write or the old value may
   /// remain, if no write happens.
   enum AccessType {
     Read,
-    Write,
+    MustWrite,
     MayWrite
   };
 
-private:
   isl_map *AccessRelation;
   enum AccessType Type;
 
@@ -127,8 +125,16 @@ public:
   /// @brief Is this a read memory access?
   bool isRead() const { return Type == MemoryAccess::Read; }
 
+  /// @brief Is this a must-write memory access?
+  bool isMustWrite() const { return Type == MemoryAccess::MustWrite; }
+
+  /// @brief Is this a may-write memory access?
+  bool isMayWrite() const { return Type == MemoryAccess::MayWrite; }
+
   /// @brief Is this a write memory access?
-  bool isWrite() const { return Type == MemoryAccess::Write; }
+  bool isWrite() const {
+    return Type == MemoryAccess::MustWrite || Type == MemoryAccess::MayWrite;
+  }
 
   isl_map *getAccessRelation() const;
 

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=184658&r1=184657&r2=184658&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Sun Jun 23 00:21:18 2013
@@ -277,18 +277,23 @@ MemoryAccess::MemoryAccess(const IRAcces
                            ScopStmt *Statement)
     : Inst(AccInst) {
   newAccessRelation = NULL;
-  Type = Access.isRead() ? Read : Write;
   statement = Statement;
 
   BaseAddr = Access.getBase();
   setBaseName();
 
   if (!Access.isAffine()) {
-    Type = (Type == Read) ? Read : MayWrite;
-    AccessRelation = isl_map_from_basic_map(createBasicAccessMap(Statement));
+    // We overapproximate non-affine accesses with a possible access to the
+    // whole array. For read accesses it does not make a difference, if an
+    // access must or may happen. However, for write accesses it is important to
+    // differentiate between writes that must happen and writes that may happen.
+  AccessRelation = isl_map_from_basic_map(createBasicAccessMap(Statement));
+    Type = Access.isRead() ? Read : MayWrite;
     return;
   }
 
+  Type = Access.isRead() ? Read: MustWrite;
+
   isl_pw_aff *Affine = SCEVAffinator::getPwAff(Statement, Access.getOffset());
 
   // Divide the access function by the size of the elements in the array.
@@ -330,7 +335,17 @@ MemoryAccess::MemoryAccess(const Value *
 }
 
 void MemoryAccess::print(raw_ostream &OS) const {
-  OS.indent(12) << (isRead() ? "Read" : "Write") << "Access := \n";
+  switch (Type) {
+  case Read:
+    OS.indent(12) << "ReadAccess := \n";
+    break;
+  case MustWrite:
+    OS.indent(12) << "MustWriteAccess := \n";
+    break;
+  case MayWrite:
+    OS.indent(12) << "MayWriteAccess := \n";
+    break;
+  }
   OS.indent(16) << getAccessRelationStr() << ";\n";
 }
 

Modified: polly/trunk/test/ScopInfo/loop_carry.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/loop_carry.ll?rev=184658&r1=184657&r2=184658&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/loop_carry.ll (original)
+++ polly/trunk/test/ScopInfo/loop_carry.ll Sun Jun 23 00:21:18 2013
@@ -56,9 +56,9 @@ bb2:
 ; CHECK:                 [n] -> { Stmt_bb_nph[] -> scattering[0, 0, 0] };
 ; CHECK:             ReadAccess :=
 ; CHECK:                 [n] -> { Stmt_bb_nph[] -> MemRef_a[0] };
-; CHECK:             WriteAccess :=
+; CHECK:             MustWriteAccess :=
 ; CHECK:                 [n] -> { Stmt_bb_nph[] -> MemRef_k_05_reg2mem[0] };
-; CHECK:             WriteAccess :=
+; CHECK:             MustWriteAccess :=
 ; CHECK:                 [n] -> { Stmt_bb_nph[] -> MemRef__reg2mem[0] };
 ; CHECK:     	Stmt_bb
 ; CHECK:             Domain :=
@@ -69,13 +69,13 @@ bb2:
 ; CHECK:                 [n] -> { Stmt_bb[i0] -> MemRef__reg2mem[0] };
 ; CHECK:             ReadAccess :=
 ; CHECK:                 [n] -> { Stmt_bb[i0] -> MemRef_k_05_reg2mem[0] };
-; CHECK:             WriteAccess :=
+; CHECK:             MustWriteAccess :=
 ; CHECK:                 [n] -> { Stmt_bb[i0] -> MemRef_a[1 + i0] };
 ; CHECK:             ReadAccess :=
 ; CHECK:                 [n] -> { Stmt_bb[i0] -> MemRef_a[2 + 2i0] };
 ; CHECK:             ReadAccess :=
 ; CHECK:                 [n] -> { Stmt_bb[i0] -> MemRef_a[4 + i0] };
-; CHECK:             WriteAccess :=
+; CHECK:             MustWriteAccess :=
 ; CHECK:                 [n] -> { Stmt_bb[i0] -> MemRef_k_05_reg2mem[0] };
-; CHECK:             WriteAccess :=
+; CHECK:             MustWriteAccess :=
 ; CHECK:                 [n] -> { Stmt_bb[i0] -> MemRef__reg2mem[0] };

Modified: polly/trunk/test/ScopInfo/multidim_ivs_and_integer_offsets_3d.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_ivs_and_integer_offsets_3d.ll?rev=184658&r1=184657&r2=184658&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_ivs_and_integer_offsets_3d.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_ivs_and_integer_offsets_3d.ll Sun Jun 23 00:21:18 2013
@@ -71,6 +71,6 @@ end:
 ; CHECK:   [n, m, o] -> { Stmt_for_k[i0, i1, i2] : i0 >= 0 and i0 <= -1 + n and i1 >= 0 and i1 <= -1 + m and i2 >= 0 and i2 <= -1 + o };
 ; CHECK: Scattering
 ; CHECK:   [n, m, o] -> { Stmt_for_k[i0, i1, i2] -> scattering[0, i0, 0, i1, 0, i2, 0] };
-; CHECK: WriteAccess
+; CHECK: MayWriteAccess
 ; CHECK:   [n, m, o] -> { Stmt_for_k[i0, i1, i2] -> MemRef_A[o0] };
 

Modified: polly/trunk/test/ScopInfo/multidim_ivs_and_parameteric_offsets_3d.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_ivs_and_parameteric_offsets_3d.ll?rev=184658&r1=184657&r2=184658&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_ivs_and_parameteric_offsets_3d.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_ivs_and_parameteric_offsets_3d.ll Sun Jun 23 00:21:18 2013
@@ -70,5 +70,5 @@ end:
 ; CHECK:   [n, m, o] -> { Stmt_for_k[i0, i1, i2] : i0 >= 0 and i0 <= -1 + n and i1 >= 0 and i1 <= -1 + m and i2 >= 0 and i2 <= -1 + o };
 ; CHECK: Scattering
 ; CHECK:   [n, m, o] -> { Stmt_for_k[i0, i1, i2] -> scattering[0, i0, 0, i1, 0, i2, 0] };
-; CHECK: WriteAccess
+; CHECK: MayWriteAccess
 ; CHECK:   [n, m, o] -> { Stmt_for_k[i0, i1, i2] -> MemRef_A[o0] };

Modified: polly/trunk/test/ScopInfo/multidim_only_ivs_2d.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/multidim_only_ivs_2d.ll?rev=184658&r1=184657&r2=184658&view=diff
==============================================================================
--- polly/trunk/test/ScopInfo/multidim_only_ivs_2d.ll (original)
+++ polly/trunk/test/ScopInfo/multidim_only_ivs_2d.ll Sun Jun 23 00:21:18 2013
@@ -50,6 +50,6 @@ end:
 ; CHECK:   [n, m] -> { Stmt_for_j[i0, i1] : i0 >= 0 and i0 <= -1 + n and i1 >= 0 and i1 <= -1 + m };
 ; CHECK: Scattering :=
 ; CHECK:   [n, m] -> { Stmt_for_j[i0, i1] -> scattering[0, i0, 0, i1, 0] };
-; CHECK: WriteAccess :=
+; CHECK: MayWriteAccess :=
 ; CHECK:   [n, m] -> { Stmt_for_j[i0, i1] -> MemRef_A[o0] };
 





More information about the llvm-commits mailing list