[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:208abd62aaca27cf22b7684760658963f47ce25d

commit 208abd62aaca27cf22b7684760658963f47ce25d
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 3b7803314ee8..d8f20684084a 100644
--- a/gcc/fortran/trans-descriptor.cc
+++ b/gcc/fortran/trans-descriptor.cc
@@ -1562,7 +1562,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.  */
@@ -1570,10 +1570,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);
@@ -1598,23 +1598,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 789c9d60d7f7..658049a8b592 100644
--- a/gcc/fortran/trans-descriptor.h
+++ b/gcc/fortran/trans-descriptor.h
@@ -100,7 +100,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 1babb2d5f030..71adb9d9a44b 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.