@@ -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
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);
}
@@ -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
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);
}
@@ -20,7 +20,7 @@
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
@@ -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 @@
}]
}
+# 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 @@
}
}
+# 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.