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]

[testsuite, 4.4/4.5] Backport dg-require-effective-target avx_runtime


I noticed that the gcc.dg/compat/vector-[12]b execution test fails on
the 4.4 and 4.5 branches on Solaris 10 and 11/x86 with Sun as:

ld.so.1: gcc-dg-compat-vector-1b-01.exe: fatal: gcc-dg-compat-vector-1b-01.exe: hardware capability (CA_SUNW_HW_1) unsupported: 0x20000000  [ AVX ]
FAIL: gcc.dg/compat/vector-1b c_compat_x_tst.o-c_compat_y_tst.o execute 

This can be fixed by backporting the support for the avx_runtime
effective-target keyword, which is what the following patch does.

Bootstrapped without regressions on i386-pc-solaris2.11 on the 4.5
branch.

Ok for 4.5 branch now and the 4.4 branch after testing?

	Rainer


2011-01-28  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.

diff -r c7d4df667a37 gcc/testsuite/gcc.dg/compat/vector-1b_main.c
--- a/gcc/testsuite/gcc.dg/compat/vector-1b_main.c	Fri Jan 28 21:44:51 2011 +0100
+++ b/gcc/testsuite/gcc.dg/compat/vector-1b_main.c	Fri Jan 28 21:57:53 2011 +0100
@@ -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);
 }
diff -r c7d4df667a37 gcc/testsuite/gcc.dg/compat/vector-2b_main.c
--- a/gcc/testsuite/gcc.dg/compat/vector-2b_main.c	Fri Jan 28 21:44:51 2011 +0100
+++ b/gcc/testsuite/gcc.dg/compat/vector-2b_main.c	Fri Jan 28 21:57:53 2011 +0100
@@ -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);
 }
diff -r c7d4df667a37 gcc/testsuite/gcc.target/i386/avx-check.h
--- a/gcc/testsuite/gcc.target/i386/avx-check.h	Fri Jan 28 21:44:51 2011 +0100
+++ b/gcc/testsuite/gcc.target/i386/avx-check.h	Fri Jan 28 21:57:53 2011 +0100
@@ -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
diff -r c7d4df667a37 gcc/testsuite/lib/target-supports.exp
--- a/gcc/testsuite/lib/target-supports.exp	Fri Jan 28 21:44:51 2011 +0100
+++ b/gcc/testsuite/lib/target-supports.exp	Fri Jan 28 21:57:53 2011 +0100
@@ -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.
 

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


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