From: Rainer Orth Date: Mon, 7 Feb 2011 16:33:00 +0000 (+0000) Subject: backport: target-supports.exp (check_avx_hw_available): New procedure. X-Git-Tag: releases/gcc-4.4.6~137 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2f64ff5003d3cde1a58440bede1357907177339;p=thirdparty%2Fgcc.git backport: target-supports.exp (check_avx_hw_available): New procedure. Backport from mainline: 2010-07-23 Uros Bizjak * lib/target-supports.exp (check_avx_hw_available): New procedure. (check_effective_target_avx_runtime): New procedure. * gcc.dg/compat/vector-1b_main.c: Use avx_runtime effective target. Remove cpuid.h include and __get_cpuid test. * gcc.dg/compat/vector-2b_main.c: Ditto. * gcc.target/i386/avx-check.h (main): Also check bit_OSXSAVE. From-SVN: r169887 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 438f912b3485..ee944f198edf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,17 @@ +2011-02-07 Rainer Orth + + Backport from mainline: + 2010-07-23 Uros Bizjak + + * lib/target-supports.exp (check_avx_hw_available): New procedure. + (check_effective_target_avx_runtime): New procedure. + + * gcc.dg/compat/vector-1b_main.c: Use avx_runtime effective target. + Remove cpuid.h include and __get_cpuid test. + * gcc.dg/compat/vector-2b_main.c: Ditto. + + * gcc.target/i386/avx-check.h (main): Also check bit_OSXSAVE. + 2011-02-03 Jonathan Wakely PR c++/47589 diff --git a/gcc/testsuite/gcc.dg/compat/vector-1b_main.c b/gcc/testsuite/gcc.dg/compat/vector-1b_main.c index fb5a5a93d792..427e8caf38b1 100644 --- a/gcc/testsuite/gcc.dg/compat/vector-1b_main.c +++ b/gcc/testsuite/gcc.dg/compat/vector-1b_main.c @@ -1,12 +1,10 @@ /* { dg-skip-if "test AVX vector" { ! { i?86-*-* x86_64-*-* } } } */ -/* { dg-require-effective-target avx } */ +/* { dg-require-effective-target avx_runtime } */ /* Test compatibility of vector types: layout between separately-compiled modules, parameter passing, and function return. This test uses vectors of integer values. */ -#include "cpuid.h" - extern void vector_1_x (void); extern void exit (int); int fails; @@ -14,14 +12,6 @@ int fails; int main () { - unsigned int eax, ebx, ecx, edx; - - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) - return 0; - - /* Run AVX vector test only if host has AVX support. */ - if (ecx & bit_AVX) - vector_1_x (); - + vector_1_x (); exit (0); } diff --git a/gcc/testsuite/gcc.dg/compat/vector-2b_main.c b/gcc/testsuite/gcc.dg/compat/vector-2b_main.c index c5a9300c8ac5..2c195764249a 100644 --- a/gcc/testsuite/gcc.dg/compat/vector-2b_main.c +++ b/gcc/testsuite/gcc.dg/compat/vector-2b_main.c @@ -1,12 +1,10 @@ /* { dg-skip-if "test AVX support" { ! { i?86-*-* x86_64-*-* } } } */ -/* { dg-require-effective-target avx } */ +/* { dg-require-effective-target avx_runtime } */ /* Test compatibility of vector types: layout between separately-compiled modules, parameter passing, and function return. This test uses vectors of floating points values. */ -#include "cpuid.h" - extern void vector_2_x (void); extern void exit (int); int fails; @@ -14,14 +12,6 @@ int fails; int main () { - unsigned int eax, ebx, ecx, edx; - - if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) - return 0; - - /* Run AVX vector test only if host has AVX support. */ - if (ecx & bit_AVX) - vector_2_x (); - + vector_2_x (); exit (0); } diff --git a/gcc/testsuite/gcc.target/i386/avx-check.h b/gcc/testsuite/gcc.target/i386/avx-check.h index 8db55a103573..491da8b4c4fa 100644 --- a/gcc/testsuite/gcc.target/i386/avx-check.h +++ b/gcc/testsuite/gcc.target/i386/avx-check.h @@ -13,7 +13,7 @@ main () return 0; /* Run AVX test only if host has AVX support. */ - if (ecx & bit_AVX) + if ((ecx & (bit_AVX | bit_OSXSAVE)) == (bit_AVX | bit_OSXSAVE)) { avx_test (); #ifdef DEBUG diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index d9fae22fc4ea..d20802ca64ea 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -1,5 +1,5 @@ -# Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 -# Free Software Foundation, Inc. +# Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -926,6 +926,30 @@ proc check_sse2_hw_available { } { }] } +# Return 1 if the target supports executing AVX instructions, 0 +# otherwise. Cache the result. + +proc check_avx_hw_available { } { + return [check_cached_effective_target avx_hw_available { + # If this is not the right target then we can skip the test. + if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } { + expr 0 + } else { + check_runtime_nocache avx_hw_available { + #include "cpuid.h" + int main () + { + unsigned int eax, ebx, ecx, edx; + if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + return ((ecx & (bit_AVX | bit_OSXSAVE)) + != (bit_AVX | bit_OSXSAVE)); + return 1; + } + } "" + } + }] +} + # Return 1 if the target supports running SSE executables, 0 otherwise. proc check_effective_target_sse_runtime { } { @@ -946,6 +970,16 @@ proc check_effective_target_sse2_runtime { } { } } +# Return 1 if the target supports running AVX executables, 0 otherwise. + +proc check_effective_target_avx_runtime { } { + if { [check_effective_target_avx] + && [check_avx_hw_available] } { + return 1 + } + return 0 +} + # Return 1 if the target supports executing AltiVec instructions, 0 # otherwise. Cache the result.