]> 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 16:33:00 +0000 (16:33 +0000)
committerRainer Orth <ro@gcc.gnu.org>
Mon, 7 Feb 2011 16:33:00 +0000 (16:33 +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: r169887

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 438f912b3485cff47e39918fadfab308af2962a6..ee944f198edf875c0b19344f433505898a12c586 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  Jonathan Wakely  <jwakely.gcc@gmail.com>
 
        PR c++/47589
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 8db55a103573ae5b8e8ec41705cf864113d28ff7..491da8b4c4fad795c7ce50d4e130a983a94a01fd 100644 (file)
@@ -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
index d9fae22fc4ead03c104ff14c1e8f2cfc69fed1ba..d20802ca64ea6fc758254ee1175fcfb26e32d53e 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
@@ -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.