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

commit d008ebc84597e5a5e89cdca5a031e3d4c75f1063
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Sun Jul 6 18:41:32 2025 +0200

    Sauvegarde data

Diff:
---
 gcc/fortran/trans-array.cc | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 6af8ee0a9544..5d1312bb8c4c 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3420,6 +3420,17 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, 
bool subscript,
 }
 
 
+static bool
+non_saved_descriptor_data_p (tree descr, tree data)
+{
+  return DECL_P (data)
+        || (TREE_CODE (data) == ADDR_EXPR
+            && DECL_P (TREE_OPERAND (data, 0)))
+        || (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (descr))
+            && TREE_CODE (descr) == COMPONENT_REF
+            && GFC_CLASS_TYPE_P (TREE_TYPE (TREE_OPERAND (descr, 0))));
+}
+
 /* Translate expressions for the descriptor and data pointer of a SS.  */
 /*GCC ARRAYS*/
 
@@ -3466,12 +3477,7 @@ gfc_conv_ss_descriptor (stmtblock_t * block, gfc_ss * 
ss, int base)
          Otherwise we must evaluate it now to avoid breaking dependency
         analysis by pulling the expressions for elemental array indices
         inside the loop.  */
-      if (!(DECL_P (tmp)
-           || (TREE_CODE (tmp) == ADDR_EXPR
-               && DECL_P (TREE_OPERAND (tmp, 0)))
-           || (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (se.expr))
-               && TREE_CODE (se.expr) == COMPONENT_REF
-               && GFC_CLASS_TYPE_P (TREE_TYPE (TREE_OPERAND (se.expr, 0)))))
+      if (!non_saved_descriptor_data_p (se.expr, tmp)
          && !ss->is_alloc_lhs)
        tmp = gfc_evaluate_now (tmp, block);
       info->data = tmp;
@@ -11366,6 +11372,8 @@ update_reallocated_descriptor (stmtblock_t *block, 
gfc_loopinfo *loop)
                } \
              while (0)
 
+      if (!non_saved_descriptor_data_p (desc, info->data))
+       UPDATE_VALUE (info->data, gfc_conv_descriptor_data_get (desc)); 
       UPDATE_VALUE (info->offset, gfc_conv_descriptor_offset_get (desc));
       info->saved_offset = info->offset;
       for (int i = 0; i < s->dimen; i++)

Reply via email to