]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Fix delinearization regression
authorTobias Burnus <tobias@codesourcery.com>
Wed, 19 Oct 2022 13:53:25 +0000 (15:53 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 19 Oct 2022 14:09:47 +0000 (16:09 +0200)
commit76b773a4a2d1daf0b83e50cd999bc38f8dd047be
tree40313840139b5d19314fc3c6b92fae8f248413fe
parent764db096e7f6f984d24ed0bfd03c4a6a2ad4fa78
Fortran: Fix delinearization regression

The delinearization patch "Fortran: delinearize multi-dimensional array
accesses", OG12 commit 39a8c371fda6136cf77c74895a00b136409e0ba3 uses
gfc_build_array_ref for the non-delinearization path. The generated
code depends on whether there can be negative strides or not, an
addition to that function in r12-8230-g7964ab6c364 - adding a Boolean
argument.

The follow-up OG12 commit "Fix Fortran array-access regressions",
9fb0076b11eb2774b620bcf2171d55c7d1fb899f also added this argument
to the call in gfc_conv_array_ref, but always evaluating as false.

This commit changes it to a call to non_negative_strides_array_p
(Note: for 'se->expr' not 'base'; the former could be 'arraydesc'
while the later is then 'arraydesc.data' whose TREE_TYPE does not
contain information about the array type.)

However, doing so revealed a bug in non_negative_strides_array_p,
fixed in this commit but also submitted as "Fortran: Fix
non_negative_strides_array_p" to mainline,
https://gcc.gnu.org/pipermail/gcc-patches/2022-October/603883.html

As a side effect of this commit, several testcases now pass and the
OG12-only changes to depend-{4,5,6}.f90 and affinity-clause-1.f90
could be undone, except that the latter now uses the delinearized
array syntax in one case, which is an improvement (as honored in
the scan-dump-tree). Hence, this commit (partially) reverts the
commits:

21c806f73fc gfortran.dg/gomp/{depend-5,scope-6}.f90: Update scan-tree-dump
014fc7cd451 Fix dg- pattern for gomp/{affinity-clause-1.f90,uses_allocators-3.f90}
2d8aa5cc5d3 gfortran.dg/gomp/depend-6.f90: minor fix + dump update
d77133b29fc gfortran.dg/gomp/depend-4.f90: minor fix + dump update

The main testcase for non_negative_strides_array_p is
gfortran.dg/array_reference_3.f90, which now also passes as well.

Additionally, this changes prevents some unintended implicit
mapping such that libgomp.fortran/map-alloc-comp-{4,6}.f90 failed
before - and now passes again.
gcc/fortran/trans-array.cc
gcc/testsuite/gfortran.dg/gomp/affinity-clause-1.f90
gcc/testsuite/gfortran.dg/gomp/depend-4.f90
gcc/testsuite/gfortran.dg/gomp/depend-5.f90
gcc/testsuite/gfortran.dg/gomp/depend-6.f90