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,testsuite] remove runtime altivec checking


In the same way that trying to check for 64-bit instruction support at
runtime is bad:

  http://gcc.gnu.org/ml/gcc-patches/2009-01/msg00616.html

checking for AltiVec instruction support at runtime is bad.  Simulator
boards don't like it, and real boards are likely to spontaneously
reboot.  And signal() doesn't work with newlib anyway.

This patch modifies the testsuite so the relevant tests are run if
AltiVec is detected as available by DejaGNU.  A similar tack is taken
for the lone test that checks for Cell instructions at runtime as well.

Tested on powerpc-none-eabi{,spe}.  OK to commit?

2009-01-12  Daniel Jacobowitz  <dan@codesourcery.com>
	    Nathan Froyd  <froydnj@codesourcery.com>
	    Joseph Myers  <joseph@codesourcery.com>

	* gcc.target/powerpc/altivec-consts.c: Run if vmx_hw, compile
	otherwise.  Do not check for AltiVec at runtime.
	* gcc.target/powerpc/altivec-varargs-1.c: Likewise.
	* gcc.target/powerpc/altivec-vec-merge.c: Likewise.
	* gcc.target/powerpc/altivec-1.c: Likewise.
	* gcc.target/powerpc/altivec-3.c: Likewise.
	* gcc.target/powerpc/altivec-10.c: Likewise.
	* gcc.target/powerpc/altivec-12.c: Likewise.
	* gcc.target/powerpc/altivec-24.c: Likewise.
	* gcc.target/powerpc/altivec-cell-2.c: Likewise.
	* gcc.target/powerpc/altivec-cell-3.c: Likewise.
	* gcc.target/powerpc/altivec-cell-4.c: Likewise.
	* gcc.target/powerpc/pr35907.c: Likewise.
	* gcc.target/powerpc/altivec-cell-8.c: Run if cell_hw, compile
	otherwise.  Do not check for Cell at runtime.
	* gcc.target/powerpc/altivec_check.h: Delete.

	* g++.dg/ext/altivec-2.C: Do not check for AltiVec at runtime.
	* g++.dg/ext/altivec-3.C: Run if vmx_hw, compile otherwise.  Do
	not check for AltiVec at runtime.
	* g++.dg/eh/simd-2.C: Only use -maltivec if vmx_hw.
	* g++.dg/eh/check-vect.h (sig_ill_handler): Remove AltiVec runtime
	check.
	* g++.dg/ext/altivec_check.h: Delete.
	
Index: gcc.target/powerpc/altivec-10.c
===================================================================
--- gcc.target/powerpc/altivec-10.c	(revision 143323)
+++ gcc.target/powerpc/altivec-10.c	(working copy)
@@ -1,11 +1,12 @@
-/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec -mabi=altivec -fno-inline" } */
 
 #include <altivec.h>
-#include <signal.h>
 
-#include "altivec_check.h"
+extern void exit (int);
+extern void abort (void);
 
 typedef union
 {
@@ -72,8 +73,6 @@ check_cmple()
 int 
 main()
 {
-  altivec_check ();
-
   check_cmple ();
   check_vec_all_num ();
   exit (0);
Index: gcc.target/powerpc/altivec-12.c
===================================================================
--- gcc.target/powerpc/altivec-12.c	(revision 143323)
+++ gcc.target/powerpc/altivec-12.c	(working copy)
@@ -1,11 +1,11 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec" } */
 
 /* Program to test PowerPC AltiVec instructions.  */
 
 #include <altivec.h>
-#include "altivec_check.h"
 
 extern void abort (void);
 #define CHECK_IF(E) if(!(E)) abort()
@@ -26,9 +26,6 @@ vector float f, g, h;
 
 int main ()
 {
-
-  altivec_check();  /* Exit if AltiVec not available.  */
-
   k = vec_add (a1, a2);
   CHECK_IF (vec_all_eq (addi, k));
   CHECK_IF (vec_all_ge (addi, k));
Index: gcc.target/powerpc/altivec-1.c
===================================================================
--- gcc.target/powerpc/altivec-1.c	(revision 143323)
+++ gcc.target/powerpc/altivec-1.c	(working copy)
@@ -1,11 +1,11 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec" } */
 
 /* Program to test PowerPC AltiVec instructions.  */
 
 #include <altivec.h>
-#include "altivec_check.h"
 
 extern void abort (void);
 
@@ -24,8 +24,6 @@ vector float f, g, h;
 
 int main ()
 {
-  altivec_check();  /* Exits if AltiVec not supported */
-
   k = vec_add (a1, a2);
   if (!vec_all_eq (addi, k))
     abort ();
Index: gcc.target/powerpc/altivec-24.c
===================================================================
--- gcc.target/powerpc/altivec-24.c	(revision 143323)
+++ gcc.target/powerpc/altivec-24.c	(working copy)
@@ -1,9 +1,9 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec" } */
 
 #include <altivec.h>
-#include "altivec_check.h"
 
 extern void abort (void);
 
@@ -28,7 +28,6 @@ int verify (void)
 
 int main (void)
 {
-  altivec_check ();   /* Exit if hardware doesn't support AltiVec.  */
   initialize (MAGIC_NUMBER);
   verify ();
   return 0;
Index: gcc.target/powerpc/altivec-3.c
===================================================================
--- gcc.target/powerpc/altivec-3.c	(revision 143323)
+++ gcc.target/powerpc/altivec-3.c	(working copy)
@@ -1,8 +1,10 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec" } */
 
-#include "altivec_check.h"
+extern void exit (int);
+extern void abort (void);
 
 typedef int int4 __attribute__ ((vector_size (16)));
 typedef float float4 __attribute__ ((vector_size (16)));
@@ -73,7 +75,6 @@ main1 ()
 int
 main ()
 {
-  altivec_check ();
   main1 ();
   exit (0);
 }
Index: gcc.target/powerpc/altivec-cell-2.c
===================================================================
--- gcc.target/powerpc/altivec-cell-2.c	(revision 143323)
+++ gcc.target/powerpc/altivec-cell-2.c	(working copy)
@@ -1,9 +1,9 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec" } */
 /* Test the vec_extract VMX intrinsics.  */
 #include <altivec.h>
-#include "altivec_check.h"
 
 extern void abort (void);
 
@@ -137,6 +137,5 @@ int main1(void)
 
 int main(void)
 { 
-  altivec_check();  /* Exits if AltiVec not supported */
   return main1 ();
 }
Index: gcc.target/powerpc/altivec-cell-3.c
===================================================================
--- gcc.target/powerpc/altivec-cell-3.c	(revision 143323)
+++ gcc.target/powerpc/altivec-cell-3.c	(working copy)
@@ -1,9 +1,9 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec" } */
 /* Test the vec_splats and vec_promote VMX intrinsics.  */
 #include <altivec.h>
-#include "altivec_check.h"
     
 extern void abort (void);
         
@@ -33,6 +33,5 @@ int main1(int t)
     
 int main(void)
 { 
-  altivec_check();  /* Exits if AltiVec not supported */
   return main1 (0);
 }
Index: gcc.target/powerpc/altivec-cell-4.c
===================================================================
--- gcc.target/powerpc/altivec-cell-4.c	(revision 143323)
+++ gcc.target/powerpc/altivec-cell-4.c	(working copy)
@@ -1,10 +1,10 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec" } */
 
 /* Test the vec_splats and vec_promote VMX intrinsics.  */
 #include <altivec.h>
-#include "altivec_check.h"
     
 extern void abort (void);
         
@@ -38,6 +38,5 @@ int main1(int t)
   
 int main(void)
 {
-  altivec_check();  /* Exits if AltiVec not supported */
   return main1 (0);
 }
Index: gcc.target/powerpc/altivec-cell-8.c
===================================================================
--- gcc.target/powerpc/altivec-cell-8.c	(revision 143323)
+++ gcc.target/powerpc/altivec-cell-8.c	(working copy)
@@ -1,9 +1,9 @@
-/* { dg-do run } */
+/* { dg-do run { target { powerpc*-*-* && cell_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! cell_hw } } } } */
 /* { dg-require-effective-target powerpc_ppu_ok } */
 /* { dg-options "-O2 -maltivec -mabi=altivec -mcpu=cell" } */
 #include <altivec.h>
 #include <string.h>
-#include "altivec_check.h"
 
 typedef short int sint16;
 typedef signed char int8;
@@ -51,6 +51,5 @@ return 0;
 
 int main(void)
 {
-  altivec_cell_check ();
   return main1();
 }
Index: gcc.target/powerpc/altivec-consts.c
===================================================================
--- gcc.target/powerpc/altivec-consts.c	(revision 143323)
+++ gcc.target/powerpc/altivec-consts.c	(working copy)
@@ -1,11 +1,10 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec -mabi=altivec -O2" } */
 
 /* Check that "easy" AltiVec constants are correctly synthesized.  */
 
-#include "altivec_check.h"
-
 extern void abort (void);
 
 typedef __attribute__ ((vector_size (16))) unsigned char v16qi;
@@ -283,8 +282,6 @@ void v4si_vspltisw_neg_addself ()
 
 int main ()
 {
-  altivec_check ();   /* Exit if hardware doesn't support AltiVec.  */
-
   v16qi_vspltisb ();
   v16qi_vspltisb_neg ();
   v16qi_vspltisb_addself ();
Index: gcc.target/powerpc/altivec-varargs-1.c
===================================================================
--- gcc.target/powerpc/altivec-varargs-1.c	(revision 143323)
+++ gcc.target/powerpc/altivec-varargs-1.c	(working copy)
@@ -1,11 +1,12 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec -mabi=altivec -fno-inline" } */
 
 #include <stdarg.h>
-#include <signal.h>
 
-#include "altivec_check.h"
+extern void exit (int);
+extern void abort (void);
 
 #define vector __attribute__((vector_size (16)))
 
@@ -77,8 +78,5 @@ int main1(void)
 
 int main (void)
 {
-  /* Exit on systems without AltiVec.  */
-  altivec_check ();
-
   return main1 ();
 }
Index: gcc.target/powerpc/altivec-vec-merge.c
===================================================================
--- gcc.target/powerpc/altivec-vec-merge.c	(revision 143323)
+++ gcc.target/powerpc/altivec-vec-merge.c	(working copy)
@@ -1,9 +1,9 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec -O2" } */
 
 #include <altivec.h>
-#include "altivec_check.h"
 
 int printf(const char * , ...);
 extern void abort();
@@ -600,7 +600,6 @@ int main(int argc, char **argv)
 {
     char toto[32] __attribute__((aligned(16)));
 
-    altivec_check ();	/* Exit if hardware doesn't support AltiVec.  */
     foo(toto, toto, 0, 0);
     return 0;
 }
Index: gcc.target/powerpc/pr35907.c
===================================================================
--- gcc.target/powerpc/pr35907.c	(revision 143323)
+++ gcc.target/powerpc/pr35907.c	(working copy)
@@ -1,10 +1,9 @@
 /* PR target/35907 */
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-O2 -maltivec" } */
 
-#include "altivec_check.h"
-
 #define vector __attribute__((vector_size (16)))
 union
 {
@@ -53,7 +52,6 @@ test (void)
 int
 main ()
 {
-  altivec_check ();
   test ();
   return 0;
 }
Index: g++.dg/eh/check-vect.h
===================================================================
--- g++.dg/eh/check-vect.h	(revision 143323)
+++ g++.dg/eh/check-vect.h	(working copy)
@@ -13,10 +13,7 @@ sig_ill_handler (int sig)
 void check_vect (void)
 {
   signal(SIGILL, sig_ill_handler);
-#if defined(__ppc__) || defined(__ppc64__) || defined(__powerpc__) || defined(powerpc)
-  /* Altivec instruction, 'vor %v0,%v0,%v0'.  */
-  asm volatile (".long 0x10000484");
-#elif defined(__i386__) || defined(__x86_64__)
+#if defined(__i386__) || defined(__x86_64__)
   /* SSE2 instruction: movsd %xmm0,%xmm0 */
   asm volatile (".byte 0xf2,0x0f,0x10,0xc0");
 #elif defined(__sparc__)
Index: g++.dg/eh/simd-2.C
===================================================================
--- g++.dg/eh/simd-2.C	(revision 143323)
+++ g++.dg/eh/simd-2.C	(working copy)
@@ -3,9 +3,7 @@
 // { dg-options "-O" }
 // { dg-options "-O -w" { target { { i?86-*-* x86_64-*-* } && ilp32 } } }
 // { dg-options "-O -w" { target powerpc*-*-* } }
-// { dg-options "-O -w -maltivec" { target { powerpc*-*-linux* && powerpc_altivec_ok } } }
-// { dg-options "-O -w -maltivec" { target { powerpc*-*-darwin* && powerpc_altivec_ok } } }
-// { dg-xfail-if "" { "powerpc-*-eabispe*" "powerpc-ibm-aix*" } { "*" } { "" } }
+// { dg-options "-O -w -maltivec" { target { powerpc*-*-* && vmx_hw } } }
 // { dg-do run }
 
 #include "check-vect.h"
Index: g++.dg/ext/altivec-2.C
===================================================================
--- g++.dg/ext/altivec-2.C	(revision 143323)
+++ g++.dg/ext/altivec-2.C	(working copy)
@@ -6,7 +6,6 @@
    arguments.  */
 
 #include <altivec.h>
-#include "altivec_check.h"
 
 int main (int argc, const char * argv[])
 {
@@ -15,8 +14,6 @@ int main (int argc, const char * argv[])
   vector float v;
   const vector float cv = (vector float){1.0, 2.0, 3.0, 4.0};
 
-  altivec_check ();
-
   vec_dst(&cv, i, 0);
   v = vec_ld(0, &cv);	
   v = vec_lde(0, &cf);
Index: g++.dg/ext/altivec-3.C
===================================================================
--- g++.dg/ext/altivec-3.C	(revision 143323)
+++ g++.dg/ext/altivec-3.C	(working copy)
@@ -1,4 +1,5 @@
-/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
 /* { dg-require-effective-target powerpc_altivec_ok } */
 /* { dg-options "-maltivec" } */
 
@@ -10,7 +11,6 @@
 #include <stdlib.h>
 
 #include <altivec.h>
-#include "altivec_check.h"
 
 #define CHECK_INVARIANT(expr) \
   if (!(expr)) { \
@@ -132,7 +132,6 @@ void main1(void)
 
 int main(void)
 {
-    altivec_check();
     main1();
     return 0;
 }
Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp	(revision 143326)
+++ lib/target-supports.exp	(working copy)
@@ -905,6 +905,40 @@ proc check_vmx_hw_available { } {
     }]
 }
 
+# Return 1 if the target supports executing AltiVec and Cell PPU
+# instructions, 0 otherwise.  Cache the result.
+
+proc check_effective_target_cell_hw { } {
+    return [check_cached_effective_target cell_hw_available {
+	# Some simulators are known to not support VMX and PPU instructions.
+	if { [istarget powerpc-*-eabi*] } {
+	    expr 0
+	} else {
+	    # Most targets don't require special flags for this test
+	    # case, but Darwin and AIX do.
+	    if { [istarget *-*-darwin*]
+		 || [istarget *-*-aix*] } {
+		set options "-maltivec -mcpu=cell"
+	    } else {
+		set options "-mcpu=cell"
+	    }
+	    check_runtime_nocache cell_hw_available {
+		int main()
+		{
+		#ifdef __MACH__
+		  asm volatile ("vor v0,v0,v0");
+                  asm volatile ("lvlx v0,r0,r0");
+		#else
+		  asm volatile ("vor 0,0,0");
+                  asm volatile ("lvlx 0,0,0");
+	        #endif
+		  return 0;
+		}
+	    } $options
+	}
+    }]
+}
+
 # Return 1 if the target supports executing 64-bit instructions, 0
 # otherwise.  Cache the result.
 


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