This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Check AVX runtime support


AVX tests needs bit_OSXSAVE enabled.  We can check it in each test or
we can put it in check_effective_target_avx.  This patch adds bit_OSXSAVE
check to check_effective_target_avx.  


H.J.
---
2010-07-22  H.J. Lu  <hongjiu.lu@intel.com>

	* lib/target-supports.exp (check_effective_target_avx): Check
	AVX runtime support.

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 9c1369a..b9a64ab 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -3323,15 +3323,28 @@ proc check_effective_target_automatic_stack_alignment  { } {
     }
 }
 
-# Return 1 if avx instructions can be compiled.
+# Return 1 if avx instructions can be compiled and run.
 
 proc check_effective_target_avx { } {
-    return [check_no_compiler_messages avx object {
-	void _mm256_zeroall (void)
+    return [check_runtime avx {
+	#include <cpuid.h>
+
+	/* Check if assembler accepts AVX instructons.  */
+	void foo (void)
 	{
-	   __builtin_ia32_vzeroall ();
+	    __asm__ volatile ("vzeroall");
+	}
+	int main ()
+	{
+	    unsigned int eax, ebx, ecx, edx;
+	    if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
+		return 1;
+
+	    /* Run AVX test only if host has AVX runtime support.  */
+	    return ((ecx & (bit_AVX | bit_OSXSAVE))
+		    == (bit_AVX | bit_OSXSAVE)) ? 0 : 1;
 	}
-    } "-O2 -mavx" ]
+    } "-O2" ]
 }
 
 # Return 1 if sse instructions can be compiled.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]