Index: polly/trunk/lib/Analysis/ScopInfo.cpp =================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp +++ polly/trunk/lib/Analysis/ScopInfo.cpp @@ -1078,16 +1078,24 @@ 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(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"); Index: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp =================================================================== --- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp +++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp @@ -759,8 +759,6 @@ } 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); Index: polly/trunk/test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll =================================================================== --- polly/trunk/test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll +++ polly/trunk/test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll @@ -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