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

commit c93bf6e4dbd66ffb8ea04f41f53554ed41f39511
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Sat Aug 16 18:19:27 2025 +0200

    Factorisation set_dimension_fields

Diff:
---
 gcc/fortran/trans-descriptor.cc | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 632fef449d16..d226ca85b037 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -1974,25 +1974,20 @@ gfc_set_descriptor_with_shape (stmtblock_t *block, tree 
desc,
   tree dim = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
                              loop.loopvar[0], loop.from[0]);
 
-  /* Set bounds and stride.  */
-  gfc_conv_descriptor_lbound_set (&body, desc, dim, gfc_index_one_node);
-  gfc_conv_descriptor_stride_set (&body, desc, dim, stride);
-
   gfc_conv_expr (&shapese, shape);
   gfc_add_block_to_block (&body, &shapese.pre);
-  gfc_conv_descriptor_ubound_set (&body, desc, dim, shapese.expr);
+  tree ubound = fold_convert (gfc_array_index_type, shapese.expr);
+  ubound = gfc_evaluate_now (ubound, &body);
   gfc_add_block_to_block (&body, &shapese.post);
 
-  /* Calculate offset.  */
-  gfc_add_modify (&body, offset,
-                 fold_build2_loc (input_location, PLUS_EXPR,
-                                  gfc_array_index_type, offset, stride));
+  set_dimension_fields (&body, desc, dim, gfc_index_one_node, ubound, stride,
+                       offset);
+
   /* Update stride.  */
   gfc_add_modify (&body, stride,
                  fold_build2_loc (input_location, MULT_EXPR,
-                                  gfc_array_index_type, stride,
-                                  fold_convert (gfc_array_index_type,
-                                                shapese.expr)));
+                                  gfc_array_index_type, stride, ubound));
+
   /* Finish scalarization loop.  */
   gfc_trans_scalarizing_loops (&loop, &body);
   gfc_add_block_to_block (block, &loop.pre);

Reply via email to