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

commit e859603b97b1d1f98561179cf87f2eb83c5a7d67
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Wed Jul 9 21:18:18 2025 +0200

    fortran: Factor array descriptor references
    
    Regression tested on x86_64-pc-linux-gnu.
    OK for master?
    
    -- >8 --
    
    Save subexpressions of array descriptor references to variables, so that
    all the expressions using the descriptor as base object benefit from a
    simplified reference using the variables.
    
    This limits the size of the expressions generated in the original tree
    dump, easing analysis of the code involving those expressions.
    This is especially helpful with chains of array references where each
    array in the chain uses a descriptor.
    
    After optimizations, the effect of the change shouldn't be visible in
    the vast majority of cases.  In rare cases it seems to permit a couple
    more jump threadings.
    
    gcc/fortran/ChangeLog:
    
            * trans-array.cc (gfc_conv_ss_descriptor): Move the descriptor
            expression initialisation...
            (set_factored_descriptor_value): ... to this new function.
            Before initialisation, walk the reference expression passed as
            argument and save some of its subexpressions to a variable.
            (substitute_t): New struct.
            (maybe_substitute_expr): New function.
            (substitute_subexpr_in_expr): New function.

Diff:
---
 gcc/fortran/trans-array.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 9a738bd5204d..a043e8607935 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3664,7 +3664,7 @@ gfc_conv_ss_descriptor (stmtblock_t * block, gfc_ss * ss, 
int base)
       /* Also the data pointer.  */
       tmp = gfc_conv_array_data (se.expr);
       /* If this is a variable or address or a class array, use it directly.
-         Otherwise we must evaluate it now to avoid breaking dependency
+        Otherwise we must evaluate it now to avoid breaking dependency
         analysis by pulling the expressions for elemental array indices
         inside the loop.  */
       if (save_descriptor_data (se.expr, tmp) && !ss->is_alloc_lhs)

Reply via email to