aboutsummaryrefslogtreecommitdiff
path: root/gcc/analyzer/infinite-recursion.cc
diff options
context:
space:
mode:
authorMikael Morin <morin-mikael@orange.fr>2024-07-11 21:55:58 +0200
committerMikael Morin <mikael@gcc.gnu.org>2024-07-12 10:28:15 +0200
commita55d24b3cf7f4d07492bb8e6fcee557175b47ea3 (patch)
tree8824085b1ed930f76e7026155b17f77894fbf1e4 /gcc/analyzer/infinite-recursion.cc
parent63d7d5998e3768f6e3703c29e8774e8b54af108c (diff)
downloadgcc-a55d24b3cf7f4d07492bb8e6fcee557175b47ea3.zip
gcc-a55d24b3cf7f4d07492bb8e6fcee557175b47ea3.tar.gz
gcc-a55d24b3cf7f4d07492bb8e6fcee557175b47ea3.tar.bz2
fortran: Factor the evaluation of MINLOC/MAXLOC's BACK argument
Move the evaluation of the BACK argument out of the loop in the inline code generated for MINLOC or MAXLOC. For that, add a new (scalar) element associated with BACK to the scalarization loop chain, evaluate the argument with the context of that element, and let the scalarizer do its job. The problem was not only a missed optimisation, but also a wrong code one in the cases where the expression associated with BACK is not free of side-effects, making multiple evaluations observable. The new tests check the evaluation count of the BACK argument, and try to cover all the variations (integral or floating-point type, constant or unknown shape, absent or scalar or array MASK) supported by the inline implementation of the functions. Care has been taken to not check the case of a constant .FALSE. MASK, for which the evaluation of BACK can be elided. gcc/fortran/ChangeLog: * trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Create a new scalar scalarization chain element if BACK is present. Add it to the loop. Set the scalarization chain before evaluating the argument. gcc/testsuite/ChangeLog: * gfortran.dg/maxloc_5.f90: New test. * gfortran.dg/minloc_5.f90: New test.
Diffstat (limited to 'gcc/analyzer/infinite-recursion.cc')
0 files changed, 0 insertions, 0 deletions