[gcc(refs/users/mikael/heads/refactor_descriptor_v08)] fortran: Factor array descriptor references
Mikael Morin
mikael@gcc.gnu.org
Wed Sep 17 16:43:58 GMT 2025
https://gcc.gnu.org/g:736983d60bd44e5b8a78ea49fd04166a16fa51a8
commit 736983d60bd44e5b8a78ea49fd04166a16fa51a8
Author: Mikael Morin <mikael@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 0449c26ce6d5..dcf1cbecb54d 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3656,7 +3656,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)
More information about the Gcc-cvs
mailing list