https://gcc.gnu.org/g:74c33c78889b967d0e701c031d2b7aa10f9fe396
commit 74c33c78889b967d0e701c031d2b7aa10f9fe396 Author: Mikael Morin <[email protected]> Date: Tue Sep 16 18:50:18 2025 +0200 Déplacement accumulation index dans conv_array_index_offset Revert partiel "Déplacement accumulation index dans conv_array_index_offset" This reverts commit f1ebc346ac933408ceea78965303282d11859e1d. Mise à jour motif dump array_reference_3.f90 Diff: --- gcc/fortran/trans-array.cc | 18 +++++++----------- gcc/testsuite/gfortran.dg/array_reference_3.f90 | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc index 9e4a908b1507..5f905b836115 100644 --- a/gcc/fortran/trans-array.cc +++ b/gcc/fortran/trans-array.cc @@ -3564,7 +3564,10 @@ conv_array_index_offset (gfc_se * se, gfc_ss * ss, int dim, int i, index = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type, index, stride); - return index; + /* Add the offset for this dimension to the stored offset for all other + dimensions. */ + return fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, + info->element_ref.index, index); } @@ -3708,11 +3711,6 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref * ar, n = 0; index = conv_array_index_offset (se, ss, ss->dim[n], n, ar, info->stride0); - /* Add the offset for this dimension to the stored offset for all other - dimensions. */ - if (info->element_ref.index && !integer_zerop (info->element_ref.index)) - index = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type, - index, info->element_ref.index); base = build_fold_indirect_ref_loc (input_location, info->element_ref.base); @@ -4018,7 +4016,8 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo *loop, gfc_ss *ss, { gfc_se se; gfc_array_info *info; - tree stride, index; + tree stride; + tree index; info = &ss->info->data.array; @@ -4029,10 +4028,7 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo *loop, gfc_ss *ss, index = conv_array_index_offset (&se, ss, array_dim, loop_dim, ar, stride); gfc_add_block_to_block (pblock, &se.pre); - info->element_ref.index = fold_build2_loc (input_location, PLUS_EXPR, - gfc_array_index_type, - info->element_ref.index, index); - info->element_ref.index = gfc_evaluate_now (info->element_ref.index, pblock); + info->element_ref.index = gfc_evaluate_now (index, pblock); } diff --git a/gcc/testsuite/gfortran.dg/array_reference_3.f90 b/gcc/testsuite/gfortran.dg/array_reference_3.f90 index ae05db559cd8..9f985579116e 100644 --- a/gcc/testsuite/gfortran.dg/array_reference_3.f90 +++ b/gcc/testsuite/gfortran.dg/array_reference_3.f90 @@ -137,7 +137,7 @@ contains allocatable_y = 21 if (any(allocatable_y /= 21)) stop 21 ! Allocatable arrays are referenced with array indexing. - ! { dg-final { scan-tree-dump-times "\\(\\*D.\\d+\\)\\\[S.\\d+ \\+ \\D.\\d+\\\] = 21;" 1 "original" } } + ! { dg-final { scan-tree-dump-times {\(\*D.\d+\)\[D.\d+ \+ S.\d+\] = 21;} 1 "original" } } end subroutine check_allocatable_array_scalarized subroutine cares(assumed_rank_x) integer :: assumed_rank_x(..)
