Hi!

Ok, 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).

Ok for trunk?

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.

--- gcc/testsuite/lib/gfortran-dg.exp.jj        2025-01-02 11:47:41.416065957 
+0100
+++ gcc/testsuite/lib/gfortran-dg.exp   2025-03-28 12:32:02.413256582 +0100
@@ -149,7 +149,13 @@ proc gfortran-dg-runtest { testcases fla
        # 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 } ]
        }
--- gcc/testsuite/gfortran.dg/cray_pointers_2.f90.jj    2025-03-27 
21:21:24.084411693 +0100
+++ gcc/testsuite/gfortran.dg/cray_pointers_2.f90       2025-03-28 
12:26:10.129071424 +0100
@@ -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 }
 !


        Jakub

Reply via email to