avx-os-support.h: New.

* gcc.target/i386/avx-os-support.h: New.
	* gcc.target/i386/avx-check.h: Include avx-os-support.h
	(main): Check avx_os_support before the test is run.
	* gcc.target/i386/aes-avx-check.h: Ditto.
	* gcc.target/i386/pclmul-avx-check.h: Ditto.

From-SVN: r176832
This commit is contained in:
Uros Bizjak 2011-07-27 17:54:59 +02:00 committed by Uros Bizjak
parent 610fa10b17
commit 045f94d62c
5 changed files with 29 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2011-07-27 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/avx-os-support.h: New.
* gcc.target/i386/avx-check.h: Include avx-os-support.h
(main): Check avx_os_support before the test is run.
* gcc.target/i386/aes-avx-check.h: Ditto.
* gcc.target/i386/pclmul-avx-check.h: Ditto.
2011-07-22 Uros Bizjak <ubizjak@gmail.com>
* lib/target-supports.exp (check_avx_os_support_available): New.

View File

@ -3,6 +3,7 @@
#endif
#include <stdlib.h>
#include "cpuid.h"
#include "avx-os-support.h"
static void aes_avx_test (void);
@ -15,7 +16,9 @@ main ()
return 0;
/* Run AES + AVX test only if host has AES + AVX support. */
if ((ecx & (bit_AVX | bit_AES)) == (bit_AVX | bit_AES))
if (((ecx & (bit_AVX | bit_OSXSAVE | bit_AES))
== (bit_AVX | bit_OSXSAVE | bit_AES))
&& avx_os_support ())
{
aes_avx_test ();
#ifdef DEBUG

View File

@ -1,6 +1,7 @@
#include <stdlib.h>
#include "cpuid.h"
#include "m256-check.h"
#include "avx-os-support.h"
static void avx_test (void);
@ -13,7 +14,8 @@ main ()
return 0;
/* Run AVX test only if host has AVX support. */
if ((ecx & (bit_AVX | bit_OSXSAVE)) == (bit_AVX | bit_OSXSAVE))
if (((ecx & (bit_AVX | bit_OSXSAVE)) == (bit_AVX | bit_OSXSAVE))
&& avx_os_support ())
{
avx_test ();
#ifdef DEBUG

View File

@ -0,0 +1,10 @@
/* Check if the OS supports executing AVX instructions. */
static int
avx_os_support (void)
{
unsigned int eax, edx;
__asm__ ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
return (eax & 6) == 6;
}

View File

@ -3,6 +3,7 @@
#endif
#include <stdlib.h>
#include "cpuid.h"
#include "avx-os-support.h"
static void pclmul_avx_test (void);
@ -15,7 +16,9 @@ main ()
return 0;
/* Run PCLMUL + AVX test only if host has PCLMUL + AVX support. */
if ((ecx & (bit_AVX | bit_PCLMUL)) == (bit_AVX | bit_PCLMUL))
if (((ecx & (bit_AVX | bit_OSXSAVE | bit_PCLMUL))
== (bit_AVX | bit_OSXSAVE | bit_PCLMUL))
&& avx_os_support ())
{
pclmul_avx_test ();
#ifdef DEBUG