Message ID | 20100722212738.GA13339@intel.com |
---|---|
State | New |
Headers | show |
"H.J. Lu" <hongjiu.lu@intel.com> writes: > -# Return 1 if avx instructions can be compiled. > +# Return 1 if avx instructions can be compiled and run. The corresponding sse/sse2 effective-target tests used separate sse and sse_runtime. AVX should be the same for symmetry. > proc check_effective_target_avx { } { > - return [check_no_compiler_messages avx object { > - void _mm256_zeroall (void) > + return [check_runtime avx { > + #include <cpuid.h> > + > + /* Check if assembler accepts AVX instructons. */ ^ typo Rainer
On Thu, Jul 22, 2010 at 2:39 PM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote: > "H.J. Lu" <hongjiu.lu@intel.com> writes: > >> -# Return 1 if avx instructions can be compiled. >> +# Return 1 if avx instructions can be compiled and run. > > The corresponding sse/sse2 effective-target tests used separate sse and > sse_runtime. AVX should be the same for symmetry. check_effective_target_avx is used on runtime tests. /* { dg-do run } */ /* { dg-require-effective-target avx } */ -- /* { dg-do run } */ /* { dg-require-effective-target avx } */ /* { dg-require-effective-target avx-runt-time } */ -- is redundant. >> proc check_effective_target_avx { } { >> - return [check_no_compiler_messages avx object { >> - void _mm256_zeroall (void) >> + return [check_runtime avx { >> + #include <cpuid.h> >> + >> + /* Check if assembler accepts AVX instructons. */ > ^ typo I will fix it. Thanks.
On Thu, Jul 22, 2010 at 11:59 PM, H.J. Lu <hjl.tools@gmail.com> wrote: > On Thu, Jul 22, 2010 at 2:39 PM, Rainer Orth > <ro@cebitec.uni-bielefeld.de> wrote: >> "H.J. Lu" <hongjiu.lu@intel.com> writes: >> >>> -# Return 1 if avx instructions can be compiled. >>> +# Return 1 if avx instructions can be compiled and run. >> >> The corresponding sse/sse2 effective-target tests used separate sse and >> sse_runtime. AVX should be the same for symmetry. > > check_effective_target_avx is used on runtime tests. > > /* { dg-do run } */ > /* { dg-require-effective-target avx } */ > > -- > /* { dg-do run } */ > /* { dg-require-effective-target avx } */ > /* { dg-require-effective-target avx-runt-time } */ > -- > > is redundant. No, it isn't. "dg-require-effective-target avx" means that the toolchain can compile avx assembly, so executable can be produced. "dg-require-effective-target avx-runtime" means that the OS can run produced executable. Uros.
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 9c1369a..b9a64ab 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -3323,15 +3323,28 @@ proc check_effective_target_automatic_stack_alignment { } { } } -# Return 1 if avx instructions can be compiled. +# Return 1 if avx instructions can be compiled and run. proc check_effective_target_avx { } { - return [check_no_compiler_messages avx object { - void _mm256_zeroall (void) + return [check_runtime avx { + #include <cpuid.h> + + /* Check if assembler accepts AVX instructons. */ + void foo (void) { - __builtin_ia32_vzeroall (); + __asm__ volatile ("vzeroall"); + } + int main () + { + unsigned int eax, ebx, ecx, edx; + if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + return 1; + + /* Run AVX test only if host has AVX runtime support. */ + return ((ecx & (bit_AVX | bit_OSXSAVE)) + == (bit_AVX | bit_OSXSAVE)) ? 0 : 1; } - } "-O2 -mavx" ] + } "-O2" ] } # Return 1 if sse instructions can be compiled.