[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:f9af93216125614730d9b0a8e73f5ce21e9edace

commit f9af93216125614730d9b0a8e73f5ce21e9edace
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 cbd270305828..46b5d70bbecf 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -10912,7 +10912,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;
@@ -11011,22 +11010,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 38180990fd9c..217664f4b5e0 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -2932,3 +2932,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 f97bc76391fb..9a7c2ea69348 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -139,5 +139,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.