GPGPU: Sort dimension sizes of multi-dimensional shared memory arrays correctly

Before this commit we generated the array type in reverse order and we also
added the outermost dimension size to the new array declaration, which is
incorrect as Polly additionally assumed an additional unsized outermost
dimension, such that we had an off-by-one error in the linearization of access
expressions.

llvm-svn: 277802
This commit is contained in:
Tobias Grosser
2016-08-05 08:27:24 +00:00
parent 870bf1788c
commit 928d7573dd
2 changed files with 110 additions and 1 deletions

View File

@@ -1292,11 +1292,17 @@ void GPUNodeBuilder::createKernelVariables(ppcg_kernel *Kernel, Function *FN) {
Type *ArrayTy = EleTy;
SmallVector<const SCEV *, 4> Sizes;
for (unsigned int j = 0; j < Var.array->n_index; ++j) {
for (unsigned int j = 1; j < Var.array->n_index; ++j) {
isl_val *Val = isl_vec_get_element_val(Var.size, j);
long Bound = isl_val_get_num_si(Val);
isl_val_free(Val);
Sizes.push_back(S.getSE()->getConstant(Builder.getInt64Ty(), Bound));
}
for (int j = Var.array->n_index - 1; j >= 0; --j) {
isl_val *Val = isl_vec_get_element_val(Var.size, j);
long Bound = isl_val_get_num_si(Val);
isl_val_free(Val);
ArrayTy = ArrayType::get(ArrayTy, Bound);
}