[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Factorisation utilisation shapeval

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

commit e38b15dcc1b5bc21a4ef70e8997b1b9d0c6397d4
Author: Mikael Morin <[email protected]>
Date:   Sun Aug 17 19:56:14 2025 +0200

    Factorisation utilisation shapeval

Diff:
---
 gcc/fortran/trans-descriptor.cc | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 91f4360eb1e0..d375fc27bc2d 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -1942,12 +1942,12 @@ gfc_set_descriptor_with_shape (stmtblock_t *block, tree desc, tree ptr,
 
   gfc_conv_expr (&shapese, shape);
   gfc_add_block_to_block (&body, &shapese.pre);
+  tree shapeval = fold_convert (gfc_array_index_type, shapese.expr);
+  shapeval = gfc_evaluate_now (shapeval, &body);
   tmp = fold_build2_loc (input_location, MINUS_EXPR, gfc_array_index_type,
 			 lbound, gfc_index_one_node);
   tree ubound = fold_build2_loc (input_location, PLUS_EXPR,
-				 gfc_array_index_type, tmp,
-				 fold_convert (gfc_array_index_type,
-					       shapese.expr));
+				 gfc_array_index_type, tmp, shapeval);
   gfc_conv_descriptor_ubound_set (&body, desc, dim, ubound);
   gfc_add_block_to_block (&body, &shapese.post);
 
@@ -1961,9 +1961,7 @@ gfc_set_descriptor_with_shape (stmtblock_t *block, tree desc, tree ptr,
   /* 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, shapeval));
   /* Finish scalarization loop.  */
   gfc_trans_scalarizing_loops (&loop, &body);
   gfc_add_block_to_block (block, &loop.pre);
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.