https://gcc.gnu.org/g:2cb728e14b5640849dad7571b9bbb0091ff5fcab
commit r15-9015-g2cb728e14b5640849dad7571b9bbb0091ff5fcab Author: Jakub Jelinek <ja...@redhat.com> Date: Fri Mar 28 20:29:31 2025 +0100 testsuite: Don't cycle through option list for gfortran.dg and libgomp.fortran dg-do run tests with -O in dg*options Here is a new version of the patch. The current behavior in gfortran.dg/ and libgomp.fortran/libgomp.oacc-fortran is that tests without any dg-do directive are implicitly dg-do compile and tests with dg-do compile or without dg-do don't cycle through options (-O is implicitly added but can be overridden), while test with dg-do run cycle through the optimization options. The following patch modifies this, so that even tests with dg-do run with -O in dg-options or dg-additional-options (after [ \t"{]) don't cycle either and also get implicit -O which is overridden by that -O{,0,1,2,3,s,z,g,fast} in dg-{,additional-}options. Previously we were mostly wasting test time on those, because e.g. -O0 -O2 -O1 -O2 -O2 -O2 -Os -O2 are still effectively -O2 and so the same thing, while -O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions -O2 and -O3 -g -O2 are not the same thing (effectively -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer -finline-functions -O2 and -g -O2) I think it isn't worth to test those combinations (especially when with e.g. -O0 in dg-options it mostly doesn't do much). Tested with make check-gfortran where this results in slight decrease of tests: # of expected passes 73809 # of expected failures 343 # of unsupported tests 78 with unmodified trunk vs. # of expected passes 72734 # of expected failures 343 # of unsupported tests 73 with the patch, and on the libgomp side # of expected passes 11162 # of expected failures 238 # of unsupported tests 274 to # of expected passes 11092 # of expected failures 238 # of unsupported tests 274 (when counting just fortran.exp tests). Before the patch I see grep -- '-O[^ ].*-O' testsuite/gfortran/gfortran.log | grep -v '/vect/\|/graphite/' | wc -l 1008 and with the patch grep -- '-O[^ ].*-O' testsuite/gfortran/gfortran.log | grep -v '/vect/\|/graphite/' | wc -l 0 (vect and graphite have a few occurrences, but not too much). 2025-03-28 Jakub Jelinek <ja...@redhat.com> * lib/gfortran-dg.exp: Don't cycle through the option list if dg-options or dg-additional-options contains -O after space, tab, double quote or open curly bracket. * gfortran.dg/cray_pointers_2.f90: Remove extraneous space between dg-do and run and remove comment about it. Diff: --- gcc/testsuite/gfortran.dg/cray_pointers_2.f90 | 4 +--- gcc/testsuite/lib/gfortran-dg.exp | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/cray_pointers_2.f90 b/gcc/testsuite/gfortran.dg/cray_pointers_2.f90 index 4351874825ed..e646fc86b802 100644 --- a/gcc/testsuite/gfortran.dg/cray_pointers_2.f90 +++ b/gcc/testsuite/gfortran.dg/cray_pointers_2.f90 @@ -1,6 +1,4 @@ -! Using two spaces between dg-do and run is a hack to keep gfortran-dg-runtest -! from cycling through optimization options for this expensive test. -! { dg-do run } +! { dg-do run } ! { dg-options "-O3 -fcray-pointer -fbounds-check -fno-inline" } ! { dg-timeout-factor 4 } ! diff --git a/gcc/testsuite/lib/gfortran-dg.exp b/gcc/testsuite/lib/gfortran-dg.exp index a516babdc3be..4abf2fe5dccf 100644 --- a/gcc/testsuite/lib/gfortran-dg.exp +++ b/gcc/testsuite/lib/gfortran-dg.exp @@ -149,7 +149,13 @@ proc gfortran-dg-runtest { testcases flags default-extra-flags } { # look if this is dg-do run test, in which case # we cycle through the option list, otherwise we don't if [expr [search_for $test "dg-do run"]] { - set option_list $torture_with_loops + if { [ expr [search_for $test "dg-options*\[ \t\"\{]-O"] ] \ + || [ expr [search_for $test \ + "dg-additional-options*\[ \t\"\{]-O"] ] } { + set option_list [list { -O } ] + } else { + set option_list $torture_with_loops + } } else { set option_list [list { -O } ] }