[gcc(refs/users/mikael/heads/refactor_descriptor_v206.01)] fortran: array descriptor: Don't set the span in the scalar case [PR122521]
Mikael Morin via Gcc-cvs <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:8a7f70eed55752f44677db2379838dfc98af76c8 commit 8a7f70eed55752f44677db2379838dfc98af76c8 Author: Mikael Morin <[email protected]> Date: Thu Aug 20 20:43:23 2026 +0200 fortran: array descriptor: Don't set the span in the scalar case [PR122521] Fortran-tested on aarch64-unknown-linux-gnu. OK for mainline? -- >8 -- The span in an array descriptor is a multiplier of the stride representing the address difference between two consecutive array elements. For scalar descriptors, there is a single element, so it can't be used in any useful way. This patch removes the initialization of the span of descriptors in the scalar case. One additional tweak is required to avoid regressing. In the library implementation of the ASSOCIATED intrinsic, the two descriptors are checked to have the same span, assuming the span to be always set. Make that check conditional on the rank being non-zero. PR fortran/122521 gcc/fortran/ChangeLog: * trans-descriptor.cc (gfc_set_descriptor_from_scalar): Remove descriptor span initialization. libgfortran/ChangeLog: * intrinsics/associated.c (associated): Only compare spans if the rank is non-zero. gcc/testsuite/ChangeLog: * gfortran.dg/coarray_collectives_18.f90: Update pattern count. Revert "Correction ajout assertion" This reverts commit e66a32c1aa4ba9fe9b720470b46e022b506a390d. Revert "Ajout assertion type pointeur" This reverts commit 7112a8a7cb05231f75adf79364a6b2edad5aedc8. Revert partiel "fortran: array descriptor: Don't set the span in the scalar case [PR122521]" This reverts commit d58f307f3adf6b76ae721c2ef037ac507924be64. Diff: --- gcc/fortran/trans-descriptor.cc | 2 -- gcc/testsuite/gfortran.dg/coarray_collectives_18.f90 | 2 +- libgfortran/intrinsics/associated.c | 5 +++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc index 29f2c07b8c89..e491a9ea1fac 100644 --- a/gcc/fortran/trans-descriptor.cc +++ b/gcc/fortran/trans-descriptor.cc @@ -899,8 +899,6 @@ gfc_set_descriptor_from_scalar (stmtblock_t *block, tree descr, tree scalar) gfc_conv_descriptor_dtype_set (block, descr, gfc_get_dtype_rank_type (0, etype)); gfc_conv_descriptor_data_set (block, descr, scalar); - gfc_conv_descriptor_span_set (block, descr, - gfc_conv_descriptor_elem_len_get (descr)); } diff --git a/gcc/testsuite/gfortran.dg/coarray_collectives_18.f90 b/gcc/testsuite/gfortran.dg/coarray_collectives_18.f90 index c83899de0e5b..5636a89e94a9 100644 --- a/gcc/testsuite/gfortran.dg/coarray_collectives_18.f90 +++ b/gcc/testsuite/gfortran.dg/coarray_collectives_18.f90 @@ -33,5 +33,5 @@ end program ! This lead to access to non exsitant memory in opencoarrays. ! In single image mode just checking for reduced number of ! descriptors is possible, i.e., execute always works. -! { dg-final { scan-tree-dump-times "desc\\.\[0-9\]+" 12 "original" } } +! { dg-final { scan-tree-dump-times "desc\\.\[0-9\]+" 8 "original" } } diff --git a/libgfortran/intrinsics/associated.c b/libgfortran/intrinsics/associated.c index fecc1b3a2832..b597b862d031 100644 --- a/libgfortran/intrinsics/associated.c +++ b/libgfortran/intrinsics/associated.c @@ -37,13 +37,14 @@ associated (const gfc_array_void *pointer, const gfc_array_void *target) return 0; if (GFC_DESCRIPTOR_DATA (pointer) != GFC_DESCRIPTOR_DATA (target)) return 0; - if (GFC_DESCRIPTOR_SPAN (pointer) != GFC_DESCRIPTOR_SPAN (target)) - return 0; if (GFC_DESCRIPTOR_DTYPE (pointer).type != GFC_DESCRIPTOR_DTYPE (target).type) return 0; rank = GFC_DESCRIPTOR_RANK (pointer); if (rank != GFC_DESCRIPTOR_RANK (target)) return 0; + if (rank != 0 + && GFC_DESCRIPTOR_SPAN (pointer) != GFC_DESCRIPTOR_SPAN (target)) + return 0; for (n = 0; n < rank; n++) { long extent;