On Wed, Sep 27, 2017 at 8:04 AM, Richard Biener <rguent...@suse.de> wrote: > > Another thing I notice is that we don't handle the multi-dimensional > accesses the fortran frontend produces: > > (gdb) p debug_data_reference (dr) > #(Data Ref: > # bb: 18 > # stmt: _43 = *a_141(D)[_42]; > # ref: *a_141(D)[_42]; > # base_object: *a_141(D); > # Access function 0: {{(_38 + stride.88_115) + 1, +, 1}_4, +, > stride.88_115}_5 > > ultimatively we fail here because we try to build a constraint for > > {{(_38 + stride.88_115) + 1, +, 1}_4, +, stride.88_115}_5 > > which ends up computing isl_pw_aff_mul (A, stride.88_115) with > A being the non-constant constraint generated for > {(_38 + stride.88_115) + 1, +, 1}_4 and stride.88_115 being > a parameter. ISL doesn't like that multiplication as the result > isn't affine (well - it is, we just have parameters in there). > > I suppose ISL doesn't handle this form of accesses given the > two "dimensions" in this scalarized form may overlap? So we'd > really need to turn those into references with different access > functions (even if that's not 100% a valid semantic transformation > as scalarization isn't reversible without extra information)?
You are right. This multivariate memory access would be better handled in delinearized form: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66981 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14741 There are two ways to handle this issue: - fix the FORTRAN front-end to emit multi dimensions ARRAY_REFs, - implement an array delinearization pass, as I implemented in LLVM http://llvm.org/doxygen/Delinearization_8cpp_source.html "On Recovering Multi-Dimensional Arrays in Polly" http://impact.gforge.inria.fr/impact2015/papers/impact2015-grosser.pdf "Optimistic Delinearization of Parametrically Sized Arrays" https://dl.acm.org/citation.cfm?id=2751248 LLVM does not have an equivalent for multi-dim ARRAY_REF description it only reasons about linearized memory accesses like in GCC's RTL: gep = Get Element Pointer, so we had no other option than to delinearize. Sebastian