mbox series

[0/7] fortran: Inline MINLOC/MAXLOC with DIM [PR90608]

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

Message

Mikael Morin Oct. 14, 2024, 3:08 p.m. UTC
From: Mikael Morin <mikael@gcc.gnu.org>

Hello,

this is the second (and last) series of patches to inline MINLOC and MAXLOC.

The previous series added support for inlining without DIM.  This one
focuses on the cases where the DIM argument is present (and is a
constant), using the existing support for reduction functions in the
scalarizer.

The changes involve the creation of a nested loop at expression walking
time, and its usage in gfc_conv_intrinsic_minmaxloc as a replacement of
the local loop variable used when DIM is absent, the existing scalarizer
code taking care of its full setup in between.

The series is split similarly to the previous one, with the unmasked
integral cases being inlined first, followed by scalar MASK cases,
and finally REAL and masked cases.

Mikael Morin (7):
  fortran: Add tests covering inline MINLOC/MAXLOC with DIM [PR90608]
  fortran: Inline unmasked integral MINLOC/MAXLOC with DIM [PR90608]
  fortran: Inline MINLOC/MAXLOC with DIM and scalar MASK [PR90608]
  fortran: Check MASK directly instead of its scalarization chain
  fortran: Inline non-character MINLOC/MAXLOC with DIM [PR90608]
  fortran: Check for empty MINLOC/MAXLOC ARRAY along DIM only
  fortran: Evaluate once BACK argument of MINLOC/MAXLOC with DIM
    [PR90608]

 gcc/fortran/trans-intrinsic.cc                | 362 +++++++----
 .../gfortran.dg/ieee/maxloc_nan_2.f90         |  64 ++
 .../gfortran.dg/ieee/minloc_nan_2.f90         |  64 ++
 gcc/testsuite/gfortran.dg/maxloc_8.f90        | 349 +++++++++++
 gcc/testsuite/gfortran.dg/maxloc_bounds_1.f90 |   4 +-
 gcc/testsuite/gfortran.dg/maxloc_bounds_2.f90 |   4 +-
 gcc/testsuite/gfortran.dg/maxloc_bounds_3.f90 |   4 +-
 gcc/testsuite/gfortran.dg/maxloc_bounds_8.f90 |   4 +-
 .../gfortran.dg/maxloc_with_dim_1.f90         | 201 ++++++
 .../maxloc_with_dim_and_mask_1.f90            | 452 ++++++++++++++
 gcc/testsuite/gfortran.dg/minloc_9.f90        | 349 +++++++++++
 .../gfortran.dg/minloc_with_dim_1.f90         | 201 ++++++
 .../minloc_with_dim_and_mask_1.f90            | 452 ++++++++++++++
 gcc/testsuite/gfortran.dg/minmaxloc_19.f90    | 182 ++++++
 gcc/testsuite/gfortran.dg/minmaxloc_20.f90    | 182 ++++++
 gcc/testsuite/gfortran.dg/minmaxloc_21.f90    | 572 ++++++++++++++++++
 gcc/testsuite/gfortran.dg/minmaxloc_22.f90    |  26 +
 17 files changed, 3354 insertions(+), 118 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/ieee/maxloc_nan_2.f90
 create mode 100644 gcc/testsuite/gfortran.dg/ieee/minloc_nan_2.f90
 create mode 100644 gcc/testsuite/gfortran.dg/maxloc_8.f90
 create mode 100644 gcc/testsuite/gfortran.dg/maxloc_with_dim_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/maxloc_with_dim_and_mask_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minloc_9.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minloc_with_dim_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minloc_with_dim_and_mask_1.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_19.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_20.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_21.f90
 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_22.f90