https://gcc.gnu.org/g:f1ebc346ac933408ceea78965303282d11859e1d

commit f1ebc346ac933408ceea78965303282d11859e1d
Author: Mikael Morin <[email protected]>
Date:   Tue Sep 16 18:50:18 2025 +0200

    Déplacement accumulation index dans conv_array_index_offset

Diff:
---
 gcc/fortran/trans-array.cc | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index f2a0d5ffe304..64b26433e86c 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3456,7 +3456,7 @@ array_bound_check_elemental (gfc_se * se, gfc_ss * ss, 
gfc_expr * expr)
    dimensions.  Single element references are processed separately.
    DIM is the array dimension, I is the loop dimension.  */
 
-static tree
+static void
 conv_array_index_offset (gfc_se * se, gfc_ss * ss, int dim, int i,
                         gfc_array_ref * ar, tree stride)
 {
@@ -3564,7 +3564,11 @@ 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.  */
+  info->element_ref.index = fold_build2_loc (input_location, PLUS_EXPR,
+                                            gfc_array_index_type,
+                                            info->element_ref.index, index);
 }
 
 
@@ -3707,12 +3711,8 @@ gfc_conv_scalarized_array_ref (gfc_se * se, 
gfc_array_ref * ar,
   else
     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);
+  conv_array_index_offset (se, ss, ss->dim[n], n, ar, info->stride0);
+  index = info->element_ref.index;
 
   base = build_fold_indirect_ref_loc (input_location, info->element_ref.base);
 
@@ -4018,7 +4018,7 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo 
*loop, gfc_ss *ss,
 {
   gfc_se se;
   gfc_array_info *info;
-  tree stride, index;
+  tree stride;
 
   info = &ss->info->data.array;
 
@@ -4026,12 +4026,9 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo 
*loop, gfc_ss *ss,
   se.loop = loop;
   se.expr = info->descriptor;
   stride = gfc_conv_array_stride (info->descriptor, array_dim);
-  index = conv_array_index_offset (&se, ss, array_dim, loop_dim, ar, stride);
+  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);
 }
 
@@ -4170,6 +4167,7 @@ gfc_start_scalarized_body (gfc_loopinfo * loop, 
stmtblock_t * pbody)
       ss_type = ss_info->type;
       if (ss_type != GFC_SS_SECTION
          && ss_type != GFC_SS_FUNCTION
+         && ss_type != GFC_SS_INTRINSIC
          && ss_type != GFC_SS_CONSTRUCTOR
          && ss_type != GFC_SS_COMPONENT)
        continue;

Reply via email to