From patchwork Mon Nov 22 18:35:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [testsuite] : Split out vect.exp target capabilities detection [was: Re: [vect] Ask for review and approving the patch about vect and loongson] Date: Mon, 22 Nov 2010 08:35:20 -0000 From: Uros Bizjak X-Patchwork-Id: 72570 Message-Id: To: Mingjie Xing Cc: rdsandiford@googlemail.com, richard.guenther@gmail.com, gcc-patches@gcc.gnu.org, Sebastian Pop On Tue, Aug 17, 2010 at 11:49 AM, Mingjie Xing wrote: > 2010/8/17 Uros Bizjak : >> On Tue, Aug 17, 2010 at 8:37 AM, Mingjie Xing wrote: >> The difference is not intentional, it looks that someone changed only >> gcc.dg/vect/vect.exp. So, in case of doubt, simply copy the >> functionality from gcc.dg/vect, this should be the master copy for >> your function. > > All right. The current function is based on gcc.dg/vect/vect.exp. > >> +# Check whether the vect tests are supported by the target and set additional >> +# target-dependent vector flags, which can be overriden by using dg-options >> +# in individual tests. Return 1 if the target supports, 0 otherwise. >> >> ... whether the vectorizer tests are supported ... Return 1 if >> vectorizer tests are supported by target, 0 otherwise. > > Updated. See the attachment. If there are no objections, I plan to commit this patch, together with an enhancement of graphite.exp to add appropriate DEFAULT_VECTFLAGS to mainline SVN. The patch also fixes some unnecessary dg-do directives in graphite directory. 2010-11-22 Uros Bizjak * gcc.dg/graphite/graphite.exp: Use check_vect_support_and_set_flags for vectorizer tests. * gcc.dg/graphite/vect-pr43423.c: Add "dg-do compile" dg directive. * gcc.dg/graphite/pr40281.c: Remove "dg-do compile" dg directive. * gcc.dg/graphite/pr41888.c: Ditto. * gcc.dg/graphite/pr42729.c: Ditto. 2010-11-22 Mingjie Xing Uros Bizjak * lib/target-supports.exp (check_vect_support_and_set_flags): New procedure to check if the target supports vectorizer tests. Set DEFAULT_VECTFLAGS and dg-do-what-default depending on vectorization capabilites. * gcc.dg/vect/vect.exp: Use check_vect_support_and_set_flags. * g++.dg/vect/vect.exp: Ditto. * gfortran.dg/vect/vect.exp: Ditto. Patch was tested on x86_64-pc-linux-gnu {,-m32} and alphaev68-pc-linux-gnu, where it removes following FAIL: gcc.dg/graphite/vect-pr43423.c scan-tree-dump-times vect "vectorized 2 loops" 1 due to inadequate (IOW, missing) vectorization capabilities on alpha. Uros. Index: gcc.dg/graphite/pr40281.c =================================================================== --- gcc.dg/graphite/pr40281.c (revision 167037) +++ gcc.dg/graphite/pr40281.c (working copy) @@ -1,4 +1,3 @@ -/* { dg-do compile } */ /* { dg-options "-O -fprefetch-loop-arrays -w" } */ /* { dg-options "-O -fprefetch-loop-arrays -march=i686 -msse -w" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ /* { dg-require-effective-target sse { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ Index: gcc.dg/graphite/vect-pr43423.c =================================================================== --- gcc.dg/graphite/vect-pr43423.c (revision 167037) +++ gcc.dg/graphite/vect-pr43423.c (working copy) @@ -1,3 +1,4 @@ +/* { dg-do compile } */ /* { dg-require-effective-target vect_int } */ int a[100], b[100], c[100]; Index: gcc.dg/graphite/graphite.exp =================================================================== --- gcc.dg/graphite/graphite.exp (revision 167037) +++ gcc.dg/graphite/graphite.exp (working copy) @@ -49,7 +49,6 @@ set dg-do-what-default compile dg-runtest $scop_files "" "-O2 -fgraphite -fdump-tree-graphite-all" dg-runtest $id_files "" "-O2 -fgraphite-identity -ffast-math" -dg-runtest $vect_files "" "-O2 -fgraphite-identity -ftree-vectorize -fno-vect-cost-model -fdump-tree-vect-details" # Tests to be run. set dg-do-what-default run @@ -57,6 +56,14 @@ dg-runtest $interchange_files "" "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all" dg-runtest $block_files "" "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all" +# Vectorizer tests, to be run or compiled, depending on target capabilities. +global DEFAULT_VECTFLAGS +set DEFAULT_VECTCFLAGS "-O2 -fgraphite-identity -ftree-vectorize -fno-vect-cost-model -fdump-tree-vect-details" + +if [check_vect_support_and_set_flags] { + dg-runtest $vect_files "" $DEFAULT_VECTFLAGS +} + # The default action for the rest of the files is 'compile'. set dg-do-what-default compile foreach f $scop_files {lremove wait_to_run_files $f} Index: gcc.dg/graphite/pr41888.c =================================================================== --- gcc.dg/graphite/pr41888.c (revision 167037) +++ gcc.dg/graphite/pr41888.c (working copy) @@ -1,4 +1,3 @@ -/* { dg-do compile } */ /* { dg-options "-g -O2 -ftree-loop-distribution -fgraphite-identity" } */ int Index: gcc.dg/graphite/pr42729.c =================================================================== --- gcc.dg/graphite/pr42729.c (revision 167037) +++ gcc.dg/graphite/pr42729.c (working copy) @@ -1,4 +1,3 @@ -/* { dg-do compile } */ /* { dg-options "-O1 -fgraphite-identity -fcompare-debug" } */ int A[10]; Index: gcc.dg/vect/vect.exp =================================================================== --- gcc.dg/vect/vect.exp (revision 167037) +++ gcc.dg/vect/vect.exp (working copy) @@ -21,6 +21,7 @@ load_lib gcc-dg.exp # Set up flags used for tests that don't specify options. +global DEFAULT_VECTFLAGS set DEFAULT_VECTCFLAGS "" # If the target system supports vector instructions, the default action @@ -34,85 +35,8 @@ # Skip these tests for targets that do not support generating vector # code. Set additional target-dependent vector flags, which can be # overridden by using dg-options in individual tests. -if [istarget "powerpc-*paired*"] { - lappend DEFAULT_VECTCFLAGS "-mpaired" - if [check_750cl_hw_available] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif [istarget "powerpc*-*-*"] { - # Skip targets not supporting -maltivec. - if ![is-effective-target powerpc_altivec_ok] { - return - } - - lappend DEFAULT_VECTCFLAGS "-maltivec" - if [check_vsx_hw_available] { - lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign" - } - - if [check_vmx_hw_available] { - set dg-do-what-default run - } else { - if [is-effective-target ilp32] { - # Specify a cpu that supports VMX for compile-only tests. - lappend DEFAULT_VECTCFLAGS "-mcpu=970" - } - set dg-do-what-default compile - } -} elseif { [istarget "spu-*-*"] } { - set dg-do-what-default run -} elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } { - lappend DEFAULT_VECTCFLAGS "-msse2" - if { [check_effective_target_sse2_runtime] } { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif { [istarget "mips*-*-*"] - && ([check_effective_target_mpaired_single] - || [check_effective_target_mips_loongson]) - && [check_effective_target_nomips16] } { - if { [check_effective_target_mpaired_single] } { - lappend DEFAULT_VECTCFLAGS "-mpaired-single" - } - set dg-do-what-default run -} elseif [istarget "sparc*-*-*"] { - lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis" - if [check_effective_target_ultrasparc_hw] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif [istarget "alpha*-*-*"] { - # Alpha's vectorization capabilities are extremely limited. - # It's more effort than its worth disabling all of the tests - # that it cannot pass. But if you actually want to see what - # does work, command out the return. +if ![check_vect_support_and_set_flags] { return - - lappend DEFAULT_VECTCFLAGS "-mmax" - if [check_alpha_max_hw_available] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif [istarget "ia64-*-*"] { - set dg-do-what-default run -} elseif [is-effective-target arm_neon_ok] { - eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""] - # NEON does not support denormals, so is not used for vectorization by - # default to avoid loss of precision. We must pass -ffast-math to test - # vectorization of float operations. - lappend DEFAULT_VECTCFLAGS "-ffast-math" - if [is-effective-target arm_neon_hw] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} else { - return } global VEC_FLAGS Index: g++.dg/vect/vect.exp =================================================================== --- g++.dg/vect/vect.exp (revision 167037) +++ g++.dg/vect/vect.exp (working copy) @@ -36,6 +36,7 @@ set save-dg-do-what-default ${dg-do-what-default} # Set up flags used for tests that don't specify options. +global DEFAULT_VECTFLAGS set DEFAULT_VECTCFLAGS "" # These flags are used for all targets. @@ -45,81 +46,8 @@ # Skip these tests for targets that do not support generating vector # code. Set additional target-dependent vector flags, which can be # overridden by using dg-options in individual tests. -if [istarget "powerpc-*paired*"] { - lappend DEFAULT_VECTCFLAGS "-mpaired" - if [check_750cl_hw_available] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif [istarget "powerpc*-*-*"] { - # Skip targets not supporting -maltivec. - if ![is-effective-target powerpc_altivec_ok] { - return - } - - lappend DEFAULT_VECTCFLAGS "-maltivec" - if [check_vsx_hw_available] { - lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign" - } - - if [check_vmx_hw_available] { - set dg-do-what-default run - } else { - if [is-effective-target ilp32] { - # Specify a cpu that supports VMX for compile-only tests. - lappend DEFAULT_VECTCFLAGS "-mcpu=970" - } - set dg-do-what-default compile - } -} elseif { [istarget "spu-*-*"] } { - set dg-do-what-default run -} elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } { - lappend DEFAULT_VECTCFLAGS "-msse2" - if { [check_effective_target_sse2_runtime] } { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif { [istarget "mips*-*-*"] - && ([check_effective_target_mpaired_single] - || [check_effective_target_mips_loongson]) - && [check_effective_target_nomips16] } { - if { [check_effective_target_mpaired_single] } { - lappend DEFAULT_VECTCFLAGS "-mpaired-single" - } - set dg-do-what-default run -} elseif [istarget "sparc*-*-*"] { - lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis" - if [check_effective_target_ultrasparc_hw] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif [istarget "alpha*-*-*"] { - # Alpha's vectorization capabilities are extremely limited. - # It's more effort than its worth disabling all of the tests - # that it cannot pass. But if you actually want to see what - # does work, command out the return. +if ![check_vect_support_and_set_flags] { return - - lappend DEFAULT_VECTCFLAGS "-mmax" - if [check_alpha_max_hw_available] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif [istarget "ia64-*-*"] { - set dg-do-what-default run -} elseif [is-effective-target arm_neon_ok] { - eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""] - if [is-effective-target arm_neon_hw] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} else { - return } # Initialize `dg'. Index: lib/target-supports.exp =================================================================== --- lib/target-supports.exp (revision 167037) +++ lib/target-supports.exp (working copy) @@ -3768,3 +3768,98 @@ proc check_effective_target_mempcpy {} { return [check_function_available "mempcpy"] } + +# Check whether the vectorizer tests are supported by the target and +# append additional target-dependent compile flags to DEFAULT_VECTFLAGS. +# Set dg-do-what-default to either compile or run, depending on target +# capabilities. Return 1 if vectorizer tests are supported by +# target, 0 otherwise. + +proc check_vect_support_and_set_flags { } { + global DEFAULT_VECTCFLAGS + global dg-do-what-default + + if [istarget "powerpc-*paired*"] { + lappend DEFAULT_VECTCFLAGS "-mpaired" + if [check_750cl_hw_available] { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } + } elseif [istarget "powerpc*-*-*"] { + # Skip targets not supporting -maltivec. + if ![is-effective-target powerpc_altivec_ok] { + return 0 + } + + lappend DEFAULT_VECTCFLAGS "-maltivec" + if [check_vsx_hw_available] { + lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign" + } + + if [check_vmx_hw_available] { + set dg-do-what-default run + } else { + if [is-effective-target ilp32] { + # Specify a cpu that supports VMX for compile-only tests. + lappend DEFAULT_VECTCFLAGS "-mcpu=970" + } + set dg-do-what-default compile + } + } elseif { [istarget "spu-*-*"] } { + set dg-do-what-default run + } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } { + lappend DEFAULT_VECTCFLAGS "-msse2" + if { [check_effective_target_sse2_runtime] } { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } + } elseif { [istarget "mips*-*-*"] + && ([check_effective_target_mpaired_single] + || [check_effective_target_mips_loongson]) + && [check_effective_target_nomips16] } { + if { [check_effective_target_mpaired_single] } { + lappend DEFAULT_VECTCFLAGS "-mpaired-single" + } + set dg-do-what-default run + } elseif [istarget "sparc*-*-*"] { + lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis" + if [check_effective_target_ultrasparc_hw] { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } + } elseif [istarget "alpha*-*-*"] { + # Alpha's vectorization capabilities are extremely limited. + # It's more effort than its worth disabling all of the tests + # that it cannot pass. But if you actually want to see what + # does work, command out the return. + return 0 + + lappend DEFAULT_VECTCFLAGS "-mmax" + if [check_alpha_max_hw_available] { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } + } elseif [istarget "ia64-*-*"] { + set dg-do-what-default run + } elseif [is-effective-target arm_neon_ok] { + eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""] + # NEON does not support denormals, so is not used for vectorization by + # default to avoid loss of precision. We must pass -ffast-math to test + # vectorization of float operations. + lappend DEFAULT_VECTCFLAGS "-ffast-math" + if [is-effective-target arm_neon_hw] { + set dg-do-what-default run + } else { + set dg-do-what-default compile + } + } else { + return 0 + } + + return 1 +} + Index: gfortran.dg/vect/vect.exp =================================================================== --- gfortran.dg/vect/vect.exp (revision 167037) +++ gfortran.dg/vect/vect.exp (working copy) @@ -21,6 +21,7 @@ load_lib target-supports.exp # Set up flags used for tests that don't specify options. +global DEFAULT_VECTFLAGS set DEFAULT_VECTCFLAGS "" # These flags are used for all targets. @@ -38,81 +39,8 @@ # Skip these tests for targets that do not support generating vector # code. Set additional target-dependent vector flags, which can be # overridden by using dg-options in individual tests. -if [istarget "powerpc-*paired*"] { - lappend DEFAULT_VECTCFLAGS "-mpaired" - if [check_750cl_hw_available] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif [istarget "powerpc*-*-*"] { - # Skip targets not supporting -maltivec. - if ![is-effective-target powerpc_altivec_ok] { - return - } - - lappend DEFAULT_VECTCFLAGS "-maltivec" - if [check_vsx_hw_available] { - lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign" - } - - if [check_vmx_hw_available] { - set dg-do-what-default run - } else { - if [is-effective-target ilp32] { - # Specify a cpu that supports VMX for compile-only tests. - lappend DEFAULT_VECTCFLAGS "-mcpu=970" - } - set dg-do-what-default compile - } -} elseif { [istarget "spu-*-*"] } { - set dg-do-what-default run -} elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } { - lappend DEFAULT_VECTCFLAGS "-msse2" - if { [check_effective_target_sse2_runtime] } { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif { [istarget "mips*-*-*"] - && ([check_effective_target_mpaired_single] - || [check_effective_target_mips_loongson]) - && [check_effective_target_nomips16] } { - if { [check_effective_target_mpaired_single] } { - lappend DEFAULT_VECTCFLAGS "-mpaired-single" - } - set dg-do-what-default run -} elseif [istarget "sparc*-*-*"] { - lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis" - if [check_effective_target_ultrasparc_hw] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif [istarget "alpha*-*-*"] { - # Alpha's vectorization capabilities are extremely limited. - # It's more effort than its worth disabling all of the tests - # that it cannot pass. But if you actually want to see what - # does work, command out the return. +if ![check_vect_support_and_set_flags] { return - - lappend DEFAULT_VECTCFLAGS "-mmax" - if [check_alpha_max_hw_available] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} elseif [istarget "ia64-*-*"] { - set dg-do-what-default run -} elseif [is-effective-target arm_neon_ok] { - eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""] - if [is-effective-target arm_neon_hw] { - set dg-do-what-default run - } else { - set dg-do-what-default compile - } -} else { - return } # Initialize `dg'.