]> git.ipfire.org Git - thirdparty/gcc.git/commit
fortran: Factor array descriptor references
authorMikael Morin <mikael@gcc.gnu.org>
Mon, 21 Jul 2025 08:31:35 +0000 (10:31 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Mon, 21 Jul 2025 08:31:35 +0000 (10:31 +0200)
commit8f41c87654fd819e48c9f6f1ac3d87e35794d310
tree54560eee485ab9a36471bd657d65771108637ed4
parent84ee229910f8b73d0fea8be6717cdd8257138d30
fortran: Factor array descriptor references

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.
gcc/fortran/trans-array.cc