[gcc(refs/users/mikael/heads/refactor_descriptor_v291.01)] Simplification initialisation offset remap descriptor

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

commit 2396d19f5ae91ca978d3b1d4a44d1f5704f555cd
Author: Mikael Morin <[email protected]>
Date:   Sat Aug 16 15:13:04 2025 +0200

    Simplification initialisation offset remap descriptor
    
    Modif initialisation stride
    
    Revert partiel initialisation stride
    
    Suppression warning argument inutilisé
    
    Suppression argument inutilisé

Diff:
---
 gcc/fortran/trans-descriptor.cc | 24 ++++--------------------
 gcc/fortran/trans-descriptor.h  |  2 +-
 gcc/fortran/trans-expr.cc       |  2 +-
 3 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/gcc/fortran/trans-descriptor.cc b/gcc/fortran/trans-descriptor.cc
index 15a9cb1ee0bf..75c7feeacf12 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -1547,7 +1547,7 @@ gfc_copy_descriptor (stmtblock_t *block, tree dest, tree src, tree ptr,
 
 void
 gfc_conv_remap_descriptor (stmtblock_t *block, tree dest, int dest_rank,
-			   tree src, gfc_expr *src_expr, gfc_array_ref *ar,
+			   tree src, gfc_typespec *src_type, gfc_array_ref *ar,
 			   bool unlimited_poly_dest)
 {
   /* Set dtype.  */
@@ -1555,10 +1555,10 @@ gfc_conv_remap_descriptor (stmtblock_t *block, tree dest, int dest_rank,
 				 gfc_get_dtype (TREE_TYPE (dest)));
 
   /* For unlimited polymorphic LHS use elem_len from RHS.  */
-  if (unlimited_poly_dest && src_expr->ts.type != BT_CLASS)
+  if (unlimited_poly_dest && src_type->type != BT_CLASS)
     {
       tree elem_len;
-      tree tmp = TYPE_SIZE_UNIT (gfc_typenode_for_spec (&src_expr->ts));
+      tree tmp = TYPE_SIZE_UNIT (gfc_typenode_for_spec (src_type));
       elem_len = fold_convert (gfc_array_index_type, tmp);
       elem_len = gfc_evaluate_now (elem_len, block);
       gfc_conv_descriptor_elem_len_set (block, dest, elem_len);
@@ -1583,23 +1583,7 @@ gfc_conv_remap_descriptor (stmtblock_t *block, tree dest, int dest_rank,
 
   /* Copy offset but adjust it such that it would correspond
      to a lbound of zero.  */
-  if (src_expr->rank == -1)
-    gfc_conv_descriptor_offset_set (block, dest,
-				    gfc_index_zero_node);
-  else
-    {
-      tree offs = gfc_conv_descriptor_offset_get (src);
-      for (int dim = 0; dim < src_expr->rank; ++dim)
-	{
-	  tree stride = gfc_conv_descriptor_stride_get (src, gfc_rank_cst[dim]);
-	  tree lbound = gfc_conv_descriptor_lbound_get (src, gfc_rank_cst[dim]);
-	  tree tmp = fold_build2_loc (input_location, MULT_EXPR,
-				      gfc_array_index_type, stride, lbound);
-	  offs = fold_build2_loc (input_location, PLUS_EXPR,
-				  gfc_array_index_type, offs, tmp);
-	}
-      gfc_conv_descriptor_offset_set (block, dest, offs);
-    }
+  gfc_conv_descriptor_offset_set (block, dest, gfc_index_zero_node);
 
   /* Set the bounds as declared for the LHS and calculate strides as
      well as another offset update accordingly.  */
diff --git a/gcc/fortran/trans-descriptor.h b/gcc/fortran/trans-descriptor.h
index d58ab2d28788..9478392e81f8 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -98,7 +98,7 @@ void gfc_copy_descriptor (stmtblock_t *, tree, tree, gfc_expr *, bool);
 void gfc_copy_descriptor (stmtblock_t *, tree, tree, tree, int);
 void gfc_copy_descriptor (stmtblock_t *, tree, tree, bool);
 
-void gfc_conv_remap_descriptor (stmtblock_t *, tree, int, tree, gfc_expr *,
+void gfc_conv_remap_descriptor (stmtblock_t *, tree, int, tree, gfc_typespec *,
 				gfc_array_ref *, bool);
 
 void gfc_set_descriptor_from_scalar_class (stmtblock_t *, tree, tree, gfc_expr *);
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 06545d782d86..ef0fd8406cd0 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -11284,7 +11284,7 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, gfc_expr * expr2)
 		 converted in rse and now have to build the correct LHS
 		 descriptor for it.  */
 	      gfc_conv_remap_descriptor (&block, desc, expr1->rank, rse.expr,
-					 expr2, &remap->u.ar,
+					 &expr2->ts, &remap->u.ar,
 					 UNLIMITED_POLY (expr1));
 	    }
 	  else
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.