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

Mikael Morin mikael@gcc.gnu.org
Mon Jul 27 17:33:40 GMT 2026


https://gcc.gnu.org/g:650d0a481b26d3fa28ed89775b661a246c5817d6

commit 650d0a481b26d3fa28ed89775b661a246c5817d6
Author: Mikael Morin <mikael@gcc.gnu.org>
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);


More information about the Gcc-cvs mailing list