[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Extraction gfc_set_empty_descriptor_bounds

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

commit a30a79163ebc4dce3623fb72473085cf29c38a18
Author: Mikael Morin <[email protected]>
Date:   Thu Jul 31 17:47:15 2025 +0200

    Extraction gfc_set_empty_descriptor_bounds
    
    Suppression gfc_descriptor_init_count en doublon

Diff:
---
 gcc/fortran/trans-array.cc      | 18 ++----------------
 gcc/fortran/trans-descriptor.cc | 17 +++++++++++++++++
 gcc/fortran/trans-descriptor.h  |  1 +
 3 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 09be833cd5e0..20ac6236636e 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -10925,7 +10925,6 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
   stmtblock_t realloc_block;
   stmtblock_t alloc_block;
   stmtblock_t fblock;
-  stmtblock_t loop_pre_block;
   gfc_ref *ref;
   gfc_ss *rss;
   gfc_ss *lss;
@@ -11024,22 +11023,9 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo *loop,
       tree guard = gfc_create_var (logical_type_node, "unallocated_init_guard");
       gfc_add_modify (&unalloc_init_block, guard, logical_false_node);
 
+      stmtblock_t loop_pre_block;
       gfc_start_block (&loop_pre_block);
-      for (n = 0; n < expr1->rank; n++)
-	{
-	  gfc_conv_descriptor_lbound_set (&loop_pre_block, desc,
-					  gfc_rank_cst[n],
-					  gfc_index_one_node);
-	  gfc_conv_descriptor_ubound_set (&loop_pre_block, desc,
-					  gfc_rank_cst[n],
-					  gfc_index_zero_node);
-	  gfc_conv_descriptor_stride_set (&loop_pre_block, desc,
-					  gfc_rank_cst[n],
-					  gfc_index_zero_node);
-	}
-
-      gfc_conv_descriptor_offset_set (&loop_pre_block, desc,
-				      gfc_index_zero_node);
+      gfc_set_empty_descriptor_bounds (&loop_pre_block, desc, expr1->rank);
 
       tmp = fold_build2_loc (input_location, EQ_EXPR,
 			     logical_type_node, array1,
diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 51f75d4ee6db..52cb8c0162bc 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -2947,3 +2947,20 @@ gfc_descriptor_init_count (tree descriptor, int rank, int corank,
 
   return stride;
 }
+
+
+void
+gfc_set_empty_descriptor_bounds (stmtblock_t *block, tree descr, int rank)
+{
+  for (int n = 0; n < rank; n++)
+    {
+      gfc_conv_descriptor_lbound_set (block, descr, gfc_rank_cst[n],
+				      gfc_index_one_node);
+      gfc_conv_descriptor_ubound_set (block, descr, gfc_rank_cst[n],
+				      gfc_index_zero_node);
+      gfc_conv_descriptor_stride_set (block, descr, gfc_rank_cst[n],
+				      gfc_index_zero_node);
+    }
+
+  gfc_conv_descriptor_offset_set (block, descr, gfc_index_zero_node);
+}
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index 842489805229..782b2154f572 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -141,5 +141,6 @@ gfc_descriptor_init_count (tree, int, int, gfc_expr **, gfc_expr **,
 			   stmtblock_t * pblock, stmtblock_t *, tree *,
 			   tree, gfc_expr *, tree, bool, gfc_expr *, tree,
 			   bool, tree *);
+void gfc_set_empty_descriptor_bounds (stmtblock_t *, tree, int);
 
 #endif /* GFC_TRANS_DESCRIPTOR_H */
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.