[polly] r292213 - Relax assert when setting access functions with invariant base pointers

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 04:00:42 PST 2017


Author: grosser
Date: Tue Jan 17 06:00:42 2017
New Revision: 292213

URL: http://llvm.org/viewvc/llvm-project?rev=292213&view=rev
Log:
Relax assert when setting access functions with invariant base pointers

Summary:
Instead of forbidding such access functions completely, we verify that their
base pointer has been hoisted and only assert in case the base pointer was
not hoisted.

I was trying for a little while to get a test case that ensures the assert is
correctly fired in case of invariant load hoisting being disabled, but I could
not find a good way to do so, as llvm-lit immediately aborts if a command
yields a non-zero return value. As we do not generally test our asserts,
not having a test case here seems OK.

This resolves http://llvm.org/PR31494

Suggested-by: Michael Kruse <llvm at meinersbur.de>

Reviewers: efriedma, jdoerfert, Meinersbur, gareevroman, sebpop, zinob, huihuiz, pollydev

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D28798

Modified:
    polly/trunk/lib/Analysis/ScopInfo.cpp
    polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
    polly/trunk/test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll

Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=292213&r1=292212&r2=292213&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Jan 17 06:00:42 2017
@@ -1078,16 +1078,24 @@ void MemoryAccess::setNewAccessRelation(
   isl_set_free(NewDomain);
   isl_set_free(StmtDomain);
 
-  // Check whether access dimensions correspond to number of dimensions of the
-  // accesses array.
   auto *NewAccessSpace = isl_space_range(NewSpace);
   assert(isl_space_has_tuple_id(NewAccessSpace, isl_dim_set) &&
          "Must specify the array that is accessed");
   auto *NewArrayId = isl_space_get_tuple_id(NewAccessSpace, isl_dim_set);
   auto *SAI = static_cast<ScopArrayInfo *>(isl_id_get_user(NewArrayId));
   assert(SAI && "Must set a ScopArrayInfo");
-  assert(!SAI->getBasePtrOriginSAI() &&
-         "Indirect array not supported by codegen");
+
+  if (SAI->isArrayKind() && SAI->getBasePtrOriginSAI()) {
+    InvariantEquivClassTy *EqClass =
+        getStatement()->getParent()->lookupInvariantEquivClass(
+            SAI->getBasePtr());
+    assert(EqClass &&
+           "Access functions to indirect arrays must have an invariant and "
+           "hoisted base pointer");
+  }
+
+  // Check whether access dimensions correspond to number of dimensions of the
+  // accesses array.
   auto Dims = SAI->getNumberOfDimensions();
   assert(isl_space_dim(NewAccessSpace, isl_dim_set) == Dims &&
          "Access dims must match array dims");

Modified: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslNodeBuilder.cpp?rev=292213&r1=292212&r2=292213&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp Tue Jan 17 06:00:42 2017
@@ -759,8 +759,6 @@ IslNodeBuilder::createNewAccesses(ScopSt
     }
     assert(MA->isAffine() &&
            "Only affine memory accesses can be code generated");
-    assert(!MA->getLatestScopArrayInfo()->getBasePtrOriginSAI() &&
-           "Generating new index expressions to indirect arrays not working");
 
     auto Schedule = isl_ast_build_get_schedule(Build);
 

Modified: polly/trunk/test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll?rev=292213&r1=292212&r2=292213&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll (original)
+++ polly/trunk/test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll Tue Jan 17 06:00:42 2017
@@ -1,13 +1,11 @@
 ; RUN: opt %loadPolly -polly-import-jscop -polly-import-jscop-dir=%S \
-; RUN:   -polly-codegen -analyze 2 >&1 < %s | FileCheck %s
-
-; XFAIL: *
+; RUN:   -polly-codegen -polly-invariant-load-hoisting -S \
+; RUN:   2>&1 < %s | FileCheck %s
 
 ; Setting new access functions where the base pointer of the array that is newly
 ; accessed is only loaded within the scop itself caused incorrect code to be
-; generated when invariant load hoisting is disabled. Since r282893 we assert
-; in such situations. This test case was added to demonstrate what needs to be
-; resolved to support such access functions.
+; generated when invariant load hoisting is disabled. This test case checks
+; that in case invariant load hoisting is enabled, we generate correct code.
 
 ; CHECK: %polly.access.polly.access.X.load = getelementptr float, float* %polly.access.X.load, i64 %polly.indvar
 




More information about the llvm-commits mailing list