Some vect-simd-clone tests fail when targeting ancient x86 variants, because the expected transformations only take place with -msse4 or higher.
So arrange for these tests to take an -msse4 option on x86, so that the expected vectorization takes place, but decay to a compile test if vect.exp would enable execution but the target doesn't have an sse4 runtime. This requires the new dg-do-if to override the action on a target while retaining the default action on others, instead of disabling the test. We can count on avx512f compile-time support for these tests, because vect_simd_clones requires that on x86, and that implies sse4 support, so we need not complicate the scan conditionals with tests for sse4, except on the last test. Regstrapped on x86_64-linux-gnu, also tested with gcc-14 targeting x86_64-elf, targeting a cpu without sse4 support. Ok to install? for gcc/ChangeLog * doc/sourcebuild.texi (dg-do-if): Document. for gcc/testsuite/ChangeLog * lib/target-supports-dg.exp (dg-do-if): New. * gcc.dg/vect/vect-simd-clone-16f.c: Use -msse4 on x86, and skip in case execution is enabled but the runtime isn't. * gcc.dg/vect/vect-simd-clone-17f.c: Likewise. * gcc.dg/vect/vect-simd-clone-18f.c: Likewise. * gcc.dg/vect/vect-simd-clone-20.c: Likewise, but only skip the scan test. --- gcc/doc/sourcebuild.texi | 5 ++++ gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c | 2 ++ gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c | 2 ++ gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c | 2 ++ gcc/testsuite/gcc.dg/vect/vect-simd-clone-20.c | 6 +++-- gcc/testsuite/lib/target-supports-dg.exp | 29 +++++++++++++++++++++++ 6 files changed, 44 insertions(+), 2 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 98ede70f23c05..255d1a451e44d 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1128,6 +1128,11 @@ by the specified floating-point factor. @subsubsection Skip a test for some targets @table @code +@item @{ dg-do-if @var{action} @{ @var{selector} @} @} +Same as dg-do if the selector matches and the test hasn't already been +marked as unsupported. Use it to override an action on a target while +leaving the default action alone for other targets. + @item @{ dg-skip-if @var{comment} @{ @var{selector} @} [@{ @var{include-opts} @} [@{ @var{exclude-opts} @}]] @} Arguments @var{include-opts} and @var{exclude-opts} are lists in which each element is a string of zero or more GCC options. diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c index 7cd29e894d050..bb3b081b0e3d8 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-16f.c @@ -1,5 +1,7 @@ +/* { dg-do-if compile { target { sse2_runtime && { ! sse4_runtime } } } } */ /* { dg-require-effective-target vect_simd_clones } */ /* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-msse4" { target sse4 } } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ /* { dg-additional-options "-mno-avx512f" { target { { i?86*-*-* x86_64-*-* } && { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c index 177521dc44531..504465614c989 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-17f.c @@ -1,5 +1,7 @@ +/* { dg-do-if compile { target { sse2_runtime && { ! sse4_runtime } } } } */ /* { dg-require-effective-target vect_simd_clones } */ /* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-msse4" { target sse4 } } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ /* { dg-additional-options "-mno-avx512f" { target { { i?86*-*-* x86_64-*-* } && { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c index 4dd51381d73c0..0c418d4324821 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-18f.c @@ -1,5 +1,7 @@ +/* { dg-do-if compile { target { sse2_runtime && { ! sse4_runtime } } } } */ /* { dg-require-effective-target vect_simd_clones } */ /* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-msse4" { target sse4 } } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ /* { dg-additional-options "-mno-avx512f" { target { { i?86*-*-* x86_64-*-* } && { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-20.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-20.c index 9f51a68f3a0c8..3e626fc4d4d56 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-20.c +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-20.c @@ -1,5 +1,7 @@ +/* { dg-do-if compile { target { sse2_runtime && { ! sse4_runtime } } } } */ /* { dg-require-effective-target vect_simd_clones } */ /* { dg-additional-options "-fopenmp-simd --param vect-epilogues-nomask=0" } */ +/* { dg-additional-options "-msse4" { target sse4 } } */ /* { dg-additional-options "-mavx" { target avx_runtime } } */ /* Test that simd inbranch clones work correctly. */ @@ -80,8 +82,8 @@ main () } /* Ensure the the in-branch simd clones are used on targets that support them. */ -/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { aarch64*-*-* } } } } */ -/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 4 "vect" { target { x86_64*-*-* } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 2 "vect" { target { aarch64*-*-* || { sse4 && { ! avx_runtime } } } } } } */ +/* { dg-final { scan-tree-dump-times {[\n\r] [^\n]* = foo\.simdclone} 4 "vect" { target { avx_runtime } } } } */ /* The LTO test produces two dump files and we scan the wrong one. */ /* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp index d4ecd1deb914b..c307258db836a 100644 --- a/gcc/testsuite/lib/target-supports-dg.exp +++ b/gcc/testsuite/lib/target-supports-dg.exp @@ -393,6 +393,35 @@ proc check-flags { args } { return $result } +# Override dg-do action on target, without setting the test as +# unsupported on other targets. Multiple such overriders can be +# present. If the test is already marked as unsupported, it has no +# effect. Otherwise, if the target selector matches, call dg-do, +# otherwise leave dg-do-what alone, so that any earlier setting +# (possibly the default) prevails. + +proc dg-do-if { args } { + set args [lreplace $args 0 0] + # Verify the number of arguments. + if { [llength $args] != 2 } { + error "syntax error, need a single action and target selector" + } + + # Don't bother if we're already skipping the test. + upvar dg-do-what dg-do-what + if { [lindex ${dg-do-what} 1] == "N" } { + return + } + + # Evaluate selector, return if it does not match. + switch [dg-process-target-1 [lindex $args 1]] { + "N" { return } + "P" { return } + } + + eval dg-do $args +} + # Skip the test (report it as UNSUPPORTED) if the target list and # included flags are matched and the excluded flags are not matched. # -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity Excluding neuro-others for not behaving ""normal"" is *not* inclusive