mbox series

[v3,00/10] fortran: Inline MINLOC/MAXLOC without DIM argument [PR90608]

Message ID 20240823083150.149099-1-morin-mikael@orange.fr
Headers show
Series fortran: Inline MINLOC/MAXLOC without DIM argument [PR90608] | expand

Message

Mikael Morin Aug. 23, 2024, 8:31 a.m. UTC
From: Mikael Morin <mikael@gcc.gnu.org>

Hello,

this is the third version of the inline MINLOC/MAXLOC without DIM patchset
whose second version was posted before at:
https://gcc.gnu.org/pipermail/gcc-patches/2024-August/660599.html

Compared to the previous version, it contains a change of wording of the
documentation in patch 10.  The rest is rebased on a recent master
without any other change (as announced by Harald, there was a minor
conflict for patch 4/10 as a result of Andre's corank patch).

I need a ack for the newly added option in patch 10.

This series of patches enable the generation of inline code for the MINLOC
and MAXLOC intrinsics, when the DIM argument is not present.  The
generated code is based on the inline implementation already generated in
the scalar case, that is when ARRAY has rank 1 and DIM is present.  The
code is extended by using several variables (one for each dimension) where
the scalar code used just one, and collecting the variables to an array
before returning.

The patches are split in a way that allows inlining in more and more cases
as controlled by the gfc_inline_intrinsic_p predicate which evolves with
the patches.  The last patch (10/10) adds a flag to control inlining
from the command line.

v2 -> v3 changes:

 - In patch 10/10, rework the documentation:
   Add a summary statement as first sentence of the new flag documentation.
   Reword the documentation of the flag limitations to omit the ambiguous
   "scalar" qualification of intrinsic function results.
   Incorporate the sentence suggested during review.

v1 -> v2 changes:

 - In patch 1/10, use intrinsic ieee_arithmetic module to get NAN values in
   tests.  This required to split the tests using ieee_arithmetic to
   a separate file in the ieee/ subdirectory.

 - Add patch 4/10 removing the frontend minmaxloc pass.

 - Add patch 10/10 adding -finline-intrinsics flag to control MINLOC/MAXLOC
   inlining from the command line.

Mikael Morin (10):
  fortran: Add tests covering inline MINLOC/MAXLOC without DIM [PR90608]
  fortran: Disable frontend passes for inlinable MINLOC/MAXLOC [PR90608]
  fortran: Inline MINLOC/MAXLOC with no DIM and ARRAY of rank 1
    [PR90608]
  fortran: Remove MINLOC/MAXLOC frontend optimization
  fortran: Outline array bound check generation code
  fortran: Inline integral MINLOC/MAXLOC with no DIM and no MASK
    [PR90608]
  fortran: Inline integral MINLOC/MAXLOC with no DIM and scalar MASK
    [PR90608]
  fortran: Inline non-character MINLOC/MAXLOC with no DIM [PR90608]
  fortran: Continue MINLOC/MAXLOC second loop where the first stopped
    [PR90608]
  fortran: Add -finline-intrinsics flag for MINLOC/MAXLOC [PR90608]

 gcc/flag-types.h                              |  30 +
 gcc/fortran/frontend-passes.cc                |  57 --
 gcc/fortran/invoke.texi                       |  31 +
 gcc/fortran/lang.opt                          |  27 +
 gcc/fortran/options.cc                        |  21 +-
 gcc/fortran/trans-array.cc                    | 382 +++++----
 gcc/fortran/trans-intrinsic.cc                | 489 ++++++++---
 .../gfortran.dg/ieee/maxloc_nan_1.f90         |  44 +
 .../gfortran.dg/ieee/minloc_nan_1.f90         |  44 +
 gcc/testsuite/gfortran.dg/maxloc_7.f90        | 208 +++++
 gcc/testsuite/gfortran.dg/maxloc_bounds_4.f90 |   4 +-
 gcc/testsuite/gfortran.dg/maxloc_bounds_5.f90 |   4 +-
 gcc/testsuite/gfortran.dg/maxloc_bounds_6.f90 |   4 +-
 gcc/testsuite/gfortran.dg/maxloc_bounds_7.f90 |   4 +-
 .../gfortran.dg/maxloc_with_mask_1.f90        | 373 +++++++++
 gcc/testsuite/gfortran.dg/minloc_8.f90        | 208 +++++
 .../gfortran.dg/minloc_with_mask_1.f90        | 372 +++++++++
 gcc/testsuite/gfortran.dg/minmaxloc_18.f90    | 772 ++++++++++++++++++
 gcc/testsuite/gfortran.dg/minmaxloc_18a.f90   |  10 +
 gcc/testsuite/gfortran.dg/minmaxloc_18b.f90   |  10 +
 gcc/testsuite/gfortran.dg/minmaxloc_18c.f90   |  10 +
 gcc/testsuite/gfortran.dg/minmaxloc_18d.f90   |  10 +
 22 files changed, 2767 insertions(+), 347 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/ieee/maxloc_nan_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/ieee/minloc_nan_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/maxloc_7.f90
 create mode 100644 gcc/testsuite/gfortran.dg/maxloc_with_mask_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minloc_8.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minloc_with_mask_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18a.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18b.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18c.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18d.f90