[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Refactoring gfc_conv_descriptor_sm_get

Mikael Morin via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:4b5fe33e77e388263481b64065f6968bfc11598a

commit 4b5fe33e77e388263481b64065f6968bfc11598a
Author: Mikael Morin <[email protected]>
Date:   Tue Jul 22 11:32:27 2025 +0200

    Refactoring gfc_conv_descriptor_sm_get

Diff:
---
 gcc/fortran/trans-descriptor.cc | 7 +++++++
 gcc/fortran/trans-descriptor.h  | 1 +
 gcc/fortran/trans-expr.cc       | 6 ++----
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 43503e5ceead..4e2d0e0eabbd 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -595,6 +595,13 @@ gfc_conv_descriptor_ubound_set (stmtblock_t *block, tree desc,
   gfc_add_modify (block, t, fold_convert (TREE_TYPE (t), value));
 }
 
+tree
+gfc_conv_descriptor_sm_get (tree desc, tree dim)
+{
+  return fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
+			  gfc_conv_descriptor_stride_get (desc, dim),
+			  gfc_conv_descriptor_span_get (desc));
+}
 
 /* Obtain offsets for trans-types.cc(gfc_get_array_descr_info).  */
 
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index d16c769abe5f..afcea057ad02 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -35,6 +35,7 @@ tree gfc_conv_descriptor_span_get (tree);
 tree gfc_conv_descriptor_stride_get (tree, tree);
 tree gfc_conv_descriptor_lbound_get (tree, tree);
 tree gfc_conv_descriptor_ubound_get (tree, tree);
+tree gfc_conv_descriptor_sm_get (tree desc, tree dim);
 
 void gfc_conv_descriptor_data_set (stmtblock_t *, tree, tree);
 void gfc_conv_descriptor_offset_set (stmtblock_t *, tree, tree);
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 423a58a1d0c2..f9ba2ef337d4 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -6344,10 +6344,8 @@ gfc_conv_gfc_desc_to_cfi_desc (gfc_se *parmse, gfc_expr *e, gfc_symbol *fsym)
       tmp = fold_build2_loc (input_location, PLUS_EXPR, gfc_array_index_type,
 			     tmp, gfc_index_one_node);
       gfc_add_modify (&loop_body, gfc_get_cfi_dim_extent (cfi, idx), tmp);
-      /* d->dim[n].sm = gfc->dim[i].stride  * gfc->span); */
-      tmp = fold_build2_loc (input_location, MULT_EXPR, gfc_array_index_type,
-			     gfc_conv_descriptor_stride_get (gfc, idx),
-			     gfc_conv_descriptor_span_get (gfc));
+      /* d->dim[n].sm = gfc->dim[i].stride * gfc->span); */
+      tmp = gfc_conv_descriptor_sm_get (gfc, idx);
       gfc_add_modify (&loop_body, gfc_get_cfi_dim_sm (cfi, idx), tmp);
 
       /* Generate loop.  */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.