]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: target-supports.exp (check_avx_hw_available): New procedure.
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Mon, 7 Feb 2011 13:15:14 +0000 (13:15 +0000)
committerRainer Orth <ro@gcc.gnu.org>
Mon, 7 Feb 2011 13:15:14 +0000 (13:15 +0000)
Backport from mainline:
2010-07-23  Uros Bizjak  <ubizjak@gmail.com>

* 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: r169883

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/compat/vector-1b_main.c
gcc/testsuite/gcc.dg/compat/vector-2b_main.c
gcc/testsuite/gcc.target/i386/avx-check.h
gcc/testsuite/lib/target-supports.exp

index 6f9339e50cf9202aadcbaa8d584ec2b8502443c0..2de08079c7bc3f9de2ee8b945293c4ddae1c7578 100644 (file)
@@ -1,3 +1,17 @@
+2011-02-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       Backport from mainline:
+       2010-07-23  Uros Bizjak  <ubizjak@gmail.com>
+
+       * 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  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        Backport from mainline:
index fb5a5a93d792f9a1dd114e82aab67aa51f520933..427e8caf38b11fc200f63eb51a1c774da55236e6 100644 (file)
@@ -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);
 }
index c5a9300c8ac502fc94635af53c24f5a73dfffb51..2c195764249a6c6765bca645aef072bd145cd0d9 100644 (file)
@@ -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);
 }
index 7736fc9f40ba40fb3718d161c41ca6a6cde10fac..b15584ad274e875a7d1976e0c4dc84f8cb83e594 100644 (file)
@@ -20,7 +20,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))
     {
       do_test ();
 #ifdef DEBUG
index 0587ebcfaa4956889a8cd269a1b0c2e1f2bb50a1..da23650f2b923c8a9faad95785f8cf939e530868 100644 (file)
@@ -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
@@ -1005,6 +1005,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 { } {
@@ -1025,6 +1049,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 VSX instructions, 0
 # otherwise.  Cache the result.