]> git.ipfire.org Git - thirdparty/gcc.git/commit
fortran: Add -finline-intrinsics flag for MINLOC/MAXLOC [PR90608]
authorMikael Morin <mikael@gcc.gnu.org>
Sat, 21 Sep 2024 16:33:11 +0000 (18:33 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Sat, 21 Sep 2024 16:33:11 +0000 (18:33 +0200)
commitd6cb7794dcd7d97b77283fbbe0026e63521d2375
tree6f17987ebb9d8af71991c6ac8bb0a9a12561fc3e
parent3c01ddc4ff0fdbaf32c22aed1c04d1d587821d91
fortran: Add -finline-intrinsics flag for MINLOC/MAXLOC [PR90608]

Introduce the -finline-intrinsics flag to control from the command line
whether to generate either inline code or calls to the functions from the
library, for the MINLOC and MAXLOC intrinsics.

The flag allows to specify inlining either independently for each intrinsic
(either MINLOC or MAXLOC), or all together.  For each intrinsic, a default
value is set if none was set.  The default value depends on the optimization
setting: inlining is avoided if not optimizing or if optimizing for size;
otherwise inlining is preferred.

There is no direct support for this behaviour provided by the .opt options
framework.  It is obtained by defining three different variants of the flag
(finline-intrinsics, fno-inline-intrinsics, finline-intrinsics=) all using
the same underlying option variable.  Each enum value (corresponding to an
intrinsic function) uses two identical bits, and the variable is initialized
with alternated bits, so that we can tell whether the value was set or not
by checking whether the two bits have different values.

PR fortran/90608

gcc/ChangeLog:

* flag-types.h (enum gfc_inlineable_intrinsics): New type.

gcc/fortran/ChangeLog:

* invoke.texi(finline-intrinsics): Document new flag.
* lang.opt (finline-intrinsics, finline-intrinsics=,
fno-inline-intrinsics): New flags.
* options.cc (gfc_post_options): If the option variable controlling
the inlining of MAXLOC (respectively MINLOC) has not been set, set
it or clear it depending on the optimization option variables.
* trans-intrinsic.cc (gfc_inline_intrinsic_function_p): Return false
if inlining for the intrinsic is disabled according to the option
variable.

gcc/testsuite/ChangeLog:

* gfortran.dg/minmaxloc_18.f90: New test.
* gfortran.dg/minmaxloc_18a.f90: New test.
* gfortran.dg/minmaxloc_18b.f90: New test.
* gfortran.dg/minmaxloc_18c.f90: New test.
* gfortran.dg/minmaxloc_18d.f90: New test.
gcc/flag-types.h
gcc/fortran/invoke.texi
gcc/fortran/lang.opt
gcc/fortran/options.cc
gcc/fortran/trans-intrinsic.cc
gcc/testsuite/gfortran.dg/minmaxloc_18.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/minmaxloc_18a.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/minmaxloc_18b.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/minmaxloc_18c.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/minmaxloc_18d.f90 [new file with mode: 0644]