]> git.ipfire.org Git - thirdparty/gcc.git/commit
fortran: Inline MINLOC/MAXLOC with no DIM and ARRAY of rank 1 [PR90608]
authorMikael Morin <mikael@gcc.gnu.org>
Sat, 21 Sep 2024 16:32:25 +0000 (18:32 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Sat, 21 Sep 2024 16:32:25 +0000 (18:32 +0200)
commitc313924c3bcb4fa672c7c1880fe686bd5af2cc7a
tree04f30664db6e428a4b18419b6d02931ede579123
parent053cec9a5f4513537ca20a246c39d1bbfe6ce4be
fortran: Inline MINLOC/MAXLOC with no DIM and ARRAY of rank 1 [PR90608]

Enable inline code generation for the MINLOC and MAXLOC intrinsic, if the
DIM argument is not present and ARRAY has rank 1.  This case is similar to
the case where the result is scalar (DIM present and rank 1 ARRAY), which
already supports inline expansion of the intrinsic.  Both cases return
the same value, with the difference that the result is an array of size 1 if
DIM is absent, whereas it's a scalar if DIM  is present.  So all there is
to do for the new case to work is hook the inline expansion with the
scalarizer.

PR fortran/90608

gcc/fortran/ChangeLog:

* trans-array.cc (gfc_conv_ss_startstride): Set the scalarization
rank based on the MINLOC/MAXLOC rank if needed.  Call the inline
code generation and setup the scalarizer array descriptor info
in the MINLOC and MAXLOC cases.
* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Return the
result array element if the scalarizer is setup and we are inside
the loops.  Restrict library function call dispatch to the case
where inline expansion is not supported.  Declare an array result
if the expression isn't scalar.  Initialize the array result single
element and return the result variable if the expression isn't
scalar.
(walk_inline_intrinsic_minmaxloc): New function.
(walk_inline_intrinsic_function): Add MINLOC and MAXLOC cases,
dispatching to walk_inline_intrinsic_minmaxloc.
(gfc_add_intrinsic_ss_code): Add MINLOC and MAXLOC cases.
(gfc_inline_intrinsic_function_p): Return true if ARRAY has rank 1,
regardless of DIM.
gcc/fortran/trans-array.cc
gcc/fortran/trans-intrinsic.cc