https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90608

--- Comment #37 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Mikael Morin <mik...@gcc.gnu.org>:

https://gcc.gnu.org/g:f5a87c8d8c6a8cfcd23595e67d3b86939e01c75c

commit r15-5477-gf5a87c8d8c6a8cfcd23595e67d3b86939e01c75c
Author: Mikael Morin <mik...@gcc.gnu.org>
Date:   Thu Aug 8 12:23:16 2024 +0200

    fortran: Inline non-character MINLOC/MAXLOC with DIM [PR90608]

    Enable generation of inline MINLOC/MAXLOC code in the cases where DIM is a
    constant, and either ARRAY is of REAL type or MASK is an array.  Those
cases
    are the remaining bits to fully support inlining of non-CHARACTER
    MINLOC/MAXLOC with constant DIM.  They are treated together because they
    generate similar code, the NANs for REAL types being handled a bit like a
    second level of masking.  These are the cases for which we generate two
    loops.

    This change affects the code generating the second loop, that was
    previously accessible only in cases ARRAY had rank 1.

    The main changes are in gfc_conv_intrinsic_minmaxloc the replacement of the
    locally initialized scalarization loop with the one provided and previously
    initialized by the scalarizer.  Same goes for the locally initialized MASK
    scalarizer chain.

    As this is enabling the code generating a second loop in a context of
    reduction and nested loops, care is taken not to advance the parent
    scalarization chain twice.

    The scalarization chain element(s) for an array MASK are inserted in the
    chain at a different place from that of a scalar MASK.  This is done on
    purpose to match the code consuming the chains which are in different
places
    for scalar and array MASK.

            PR fortran/90608

    gcc/fortran/ChangeLog:

            * trans-intrinsic.cc (gfc_inline_intrinsic_function_p): Return TRUE
            for MINLOC/MAXLOC with constant DIM and either REAL ARRAY or
            non-scalar MASK.
            (walk_inline_intrinsic_minmaxloc): Walk MASK and if it's an array
            add the chain obtained before that of ARRAY.
            (gfc_conv_intrinsic_minmaxloc): Use the nested loop if there is
one.
            To evaluate MASK (respectively ARRAY in the second loop), inherit
            the scalarizer chain if in a nested loop, otherwise keep using the
            chain obtained by walking MASK (respectively ARRAY).  If there is a
            nested loop, avoid advancing the parent scalarization chain a
second
            time in the second loop.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/minmaxloc_21.f90: New test.

Reply via email to