https://gcc.gnu.org/g:b85f9cee91bd50e3da7a00b825b7894a642e5f34

commit b85f9cee91bd50e3da7a00b825b7894a642e5f34
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Sun Jul 6 17:08:15 2025 +0200

    fortran: Remove useless scalarization delta update on reallocation
    
    Remove the recalculation of delta (offset between loop bounds and array
    bounds) for the variable being reallocated on assignment.  This
    recalculation is unnecessary, because reallocation changes neither of
    the array lower bound (tied to the variable or component declaration),
    or the loop bounds.
    
    gcc/fortran/ChangeLog:
    
            * trans-array.cc (gfc_alloc_allocatable_for_assignment): Remove
            the loop recalculating the scalarisation deltas for the variable
            being reallocated on assignment.

Diff:
---
 gcc/fortran/trans-array.cc | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 7be2d7b11a62..821f9a5d0530 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -11368,7 +11368,6 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo 
*loop,
   tree lbd;
   tree class_expr2 = NULL_TREE;
   int n;
-  int dim;
   gfc_array_spec * as;
   bool coarray = (flag_coarray == GFC_FCOARRAY_LIB
                  && gfc_caf_attr (expr1, true).codimension);
@@ -11740,18 +11739,6 @@ gfc_alloc_allocatable_for_assignment (gfc_loopinfo 
*loop,
       && VAR_P (linfo->saved_offset))
     gfc_add_modify (&fblock, linfo->saved_offset, tmp);
 
-  /* Now set the deltas for the lhs.  */
-  for (n = 0; n < expr1->rank; n++)
-    {
-      tmp = gfc_conv_descriptor_lbound_get (desc, gfc_rank_cst[n]);
-      dim = lss->dim[n];
-      tmp = fold_build2_loc (input_location, MINUS_EXPR,
-                            gfc_array_index_type, tmp,
-                            loop->from[dim]);
-      if (linfo->delta[dim] && VAR_P (linfo->delta[dim]))
-       gfc_add_modify (&fblock, linfo->delta[dim], tmp);
-    }
-
   /* Take into account _len of unlimited polymorphic entities, so that span
      for array descriptors and allocation sizes are computed correctly.  */
   if (UNLIMITED_POLY (expr2))

Reply via email to