Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -1085,9 +1085,18 @@ "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"); + } + auto Dims = SAI->getNumberOfDimensions(); assert(isl_space_dim(NewAccessSpace, isl_dim_set) == Dims && "Access dims must match array dims"); Index: lib/CodeGen/IslNodeBuilder.cpp =================================================================== --- lib/CodeGen/IslNodeBuilder.cpp +++ 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: test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll =================================================================== --- test/Isl/CodeGen/MemAccess/invariant_base_ptr.ll +++ 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