mbox series

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

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

Message

Mikael Morin Aug. 16, 2024, 10:22 a.m. UTC
From: Mikael Morin <mikael@gcc.gnu.org>

Hello,

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

Appart from the NAN skipping conditional likeliness which is left unchanged,
it takes into account the review comments I got so far, including the still
controversial -finline-intrinsics flag.  Regarding the conditional
likeliness, I looked at its effect on the generated assembly for
minmaxloc_18, and I really can't tell which is better just from the look
of it.  I prefer to not touch that part.

Patches 4 (minmaxloc frontend pass removal) and 10 (-finline-intrinsics flag)
are new, and patch 1 (tests) has been modified to move the NAN tests to a
separate file and use the ieee_arithmetic intrinsic module.  The rest of the
patches are rebased versions of the previously posted patches.
Details below and in the patches themselves.

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.

Changes from V1:

 - 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                |  56 --
 gcc/fortran/invoke.texi                       |  24 +
 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, 2760 insertions(+), 346 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