[polly] r252607 - ScopInfo: Make getDimensionSize better reflect which dimensions carry sizes

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 06:24:21 PST 2015


Author: grosser
Date: Tue Nov 10 08:24:21 2015
New Revision: 252607

URL: http://llvm.org/viewvc/llvm-project?rev=252607&view=rev
Log:
ScopInfo: Make getDimensionSize better reflect which dimensions carry sizes

In polly the first dimensions of an array as well as all scalars do not carry
any size information. This commit makes this explicit in the interface of
getDimensionSize. Before this commit getDimensionSize(0) returned the size of
the first dimension that carried a size. After this commit getDimensionSize(i)
will either return the size of dimension 'i' or assert in case 'i' does not
carry a size or does not exist at all.

This very same behaviour was already present in getDimensionSizePw(). This
commit also adds assertions that ensure getDimensionSizePw() is called
appropriately.

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

Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=252607&r1=252606&r2=252607&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Tue Nov 10 08:24:21 2015
@@ -127,15 +127,25 @@ public:
   unsigned getNumberOfDimensions() const { return DimensionSizes.size(); }
 
   /// @brief Return the size of dimension @p dim as SCEV*.
-  const SCEV *getDimensionSize(unsigned dim) const {
-    assert(dim < getNumberOfDimensions() && "Invalid dimension");
-    return DimensionSizes[dim];
+  //
+  //  Scalars do not have array dimensions and the first dimension of
+  //  a (possibly multi-dimensional) array also does not carry any size
+  //  information.
+  const SCEV *getDimensionSize(unsigned Dim) const {
+    assert(Dim > 0 && "Only dimensions larger than zero are sized.");
+    assert(Dim < getNumberOfDimensions() && "Invalid dimension");
+    return DimensionSizes[Dim - 1];
   }
 
   /// @brief Return the size of dimension @p dim as isl_pw_aff.
-  __isl_give isl_pw_aff *getDimensionSizePw(unsigned dim) const {
-    assert(dim < getNumberOfDimensions() && "Invalid dimension");
-    return isl_pw_aff_copy(DimensionSizesPw[dim - 1]);
+  //
+  //  Scalars do not have array dimensions and the first dimension of
+  //  a (possibly multi-dimensional) array also does not carry any size
+  //  information.
+  __isl_give isl_pw_aff *getDimensionSizePw(unsigned Dim) const {
+    assert(Dim > 0 && "Only dimensions larger than zero are sized.");
+    assert(Dim < getNumberOfDimensions() && "Invalid dimension");
+    return isl_pw_aff_copy(DimensionSizesPw[Dim - 1]);
   }
 
   /// @brief Get the type of the elements stored in this array.

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=252607&r1=252606&r2=252607&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Nov 10 08:24:21 2015
@@ -217,13 +217,16 @@ void ScopArrayInfo::print(raw_ostream &O
   OS.indent(8) << *getElementType() << " " << getName();
   if (getNumberOfDimensions() > 0)
     OS << "[*]";
-  for (unsigned u = 0; u + 1 < getNumberOfDimensions(); u++) {
+  for (unsigned u = 1; u < getNumberOfDimensions(); u++) {
     OS << "[";
 
-    if (SizeAsPwAff)
-      OS << " " << DimensionSizesPw[u] << " ";
-    else
-      OS << *DimensionSizes[u];
+    if (SizeAsPwAff) {
+      auto Size = getDimensionSizePw(u);
+      OS << " " << Size << " ";
+      isl_pw_aff_free(Size);
+    } else {
+      OS << *getDimensionSize(u);
+    }
 
     OS << "]";
   }

Modified: polly/trunk/lib/CodeGen/IslExprBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=252607&r1=252606&r2=252607&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslExprBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslExprBuilder.cpp Tue Nov 10 08:24:21 2015
@@ -151,7 +151,7 @@ Value *IslExprBuilder::createAccessAddre
     if (u + 1 >= e)
       break;
 
-    const SCEV *DimSCEV = SAI->getDimensionSize(u - 1);
+    const SCEV *DimSCEV = SAI->getDimensionSize(u);
 
     llvm::ValueToValueMap Map(GlobalMap.begin(), GlobalMap.end());
     DimSCEV = SCEVParameterRewriter::rewrite(DimSCEV, SE, Map);




More information about the llvm-commits mailing list