]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
avx-os-support.h: New.
authorUros Bizjak <ubizjak@gmail.com>
Wed, 27 Jul 2011 15:50:13 +0000 (17:50 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 27 Jul 2011 15:50:13 +0000 (17:50 +0200)
* 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: r176831

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/aes-avx-check.h
gcc/testsuite/gcc.target/i386/avx-check.h
gcc/testsuite/gcc.target/i386/avx-os-support.h [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pclmul-avx-check.h

index 04275808f2f088b8377d3c6ab3f51b1aa441ae66..201d6aa156af40979604f45170909b1cb58e2b6a 100644 (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-23  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/49708
index e91e88173cf633d0e6e42f87e0b10fd9f3900022..f2a4ead401450434c364e0b3b6c8007f3869ddc8 100644 (file)
@@ -3,6 +3,7 @@
 #endif
 #include <stdlib.h>
 #include "cpuid.h"
+#include "avx-os-support.h"
 
 static void aes_avx_test (void);
 
@@ -22,7 +23,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 ())
     {
       do_test ();
 #ifdef DEBUG
index b15584ad274e875a7d1976e0c4dc84f8cb83e594..7ddca9d7b809b2e54f128bd9f81726dfd8092351 100644 (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);
 
@@ -20,7 +21,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 ())
     {
       do_test ();
 #ifdef DEBUG
diff --git a/gcc/testsuite/gcc.target/i386/avx-os-support.h b/gcc/testsuite/gcc.target/i386/avx-os-support.h
new file mode 100644 (file)
index 0000000..21d332f
--- /dev/null
@@ -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;
+}
index 550e49904d9b72a721b07f43d675fa6b7ee9551f..5eed2e2203cf5ad37be0cc2ff9dcf6cab2d44c0d 100644 (file)
@@ -3,6 +3,7 @@
 #endif
 #include <stdlib.h>
 #include "cpuid.h"
+#include "avx-os-support.h"
 
 static void pclmul_avx_test (void);
 
@@ -22,7 +23,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 ())
     {
       do_test ();
 #ifdef DEBUG