sourcebuild.texi (Effective-Target Keywords): Document sse_runtime, sse2_runtime.
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Mon, 19 Jul 2010 08:20:59 +0000 (08:20 +0000)
committerRainer Orth <ro@gcc.gnu.org>
Mon, 19 Jul 2010 08:20:59 +0000 (08:20 +0000)
gcc:
* doc/sourcebuild.texi (Effective-Target Keywords): Document
sse_runtime, sse2_runtime.

gcc/testsuite:
* lib/target-supports.exp (check_sse_os_support_available): New
proc.
(check_sse_hw_available): New proc.
(check_effective_target_sse_runtime): New proc.
(check_effective_target_sse2_runtime): New proc.
* lib/fortran-torture.exp (get-fortran-torture-options): Only add
-msse2 if check_sse_os_support_available.
* g++.dg/vect/vect.exp: Only run -msse2 tests if
check_sse_os_support_available.
* gcc.dg/vect/vect.exp: Likewise.
* gfortran.dg/vect/vect.exp: Likewise.
* gcc.target/i386/sol2-check: Renamed to ...
* gcc.target/i386/sse-os-support.h: ... this.
(sol2_check): Renamed to ...
(sse_os_support): ... this.
Only test movss with xmm registers.
* gcc.target/i386/sse-check.h: Reflect new header and function names.
Removed ILL_INSN, ILL_INSN_LEN.
* gcc.target/i386/sse2-check.h: Likewise.
* gcc.target/i386/sse3-check.h: Likewise.
* gcc.dg/pr40550.c: Use dg-require-effective-target sse_runtime.
Removed cpuid.h, __get_cpuid test.
* g++.dg/other/i386-1.C: Use dg-require-effective-target sse2_runtime.
Removed cpuid.h, __get_cpuid test.
* g++.dg/other/pr40446.C: Likewise.
* gcc.dg/compat/union-m128-1_main.c: Likewise.
* gcc.dg/compat/vector-1a_main.c: Likewise.
* gcc.dg/compat/vector-2a_main.c: Likewise.
* gcc.dg/pr36584.c: Likewise.
* gcc.dg/pr37544.c: Likewise.
* gcc.dg/torture/pr16104-1.c: Likewise.
* gcc.dg/torture/stackalign/alloca-2.c: Likewise.
* gcc.dg/torture/stackalign/alloca-3.c: Likewise.
* gcc.dg/torture/stackalign/push-1.c: Likewise.
* gcc.dg/torture/stackalign/vararg-3.c: Likewise.
* gcc.dg/torture/pr35771.h: Removed cpuid.h, __get_cpuid test.
* gcc.dg/torture/pr35771-1.c: Use dg-require-effective-target
sse2_runtime.
* gcc.dg/torture/pr35771-2.c: Likewise.
* gcc.dg/torture/pr35771-3.c: Likewise.
* gcc.target/i386/pr39315-2.c: Likewise.
* gcc.target/i386/pr39315-4.c: Likewise.
* gcc.target/i386/vperm-v2df.c: Likewise.
* gcc.target/i386/vperm-v2di.c: Likewise.
* gcc.target/i386/vperm-v4si-1.c: Likewise.
* gcc.target/i386/vperm-v4sf-1.c: Use dg-require-effective-target
sse_runtime.

From-SVN: r162295

36 files changed:
gcc/ChangeLog
gcc/doc/sourcebuild.texi
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/i386-1.C
gcc/testsuite/g++.dg/other/pr40446.C
gcc/testsuite/g++.dg/vect/vect.exp
gcc/testsuite/gcc.dg/compat/union-m128-1_main.c
gcc/testsuite/gcc.dg/compat/vector-1a_main.c
gcc/testsuite/gcc.dg/compat/vector-2a_main.c
gcc/testsuite/gcc.dg/pr36584.c
gcc/testsuite/gcc.dg/pr37544.c
gcc/testsuite/gcc.dg/pr40550.c
gcc/testsuite/gcc.dg/torture/pr16104-1.c
gcc/testsuite/gcc.dg/torture/pr35771-1.c
gcc/testsuite/gcc.dg/torture/pr35771-2.c
gcc/testsuite/gcc.dg/torture/pr35771-3.c
gcc/testsuite/gcc.dg/torture/pr35771.h
gcc/testsuite/gcc.dg/torture/stackalign/alloca-2.c
gcc/testsuite/gcc.dg/torture/stackalign/alloca-3.c
gcc/testsuite/gcc.dg/torture/stackalign/push-1.c
gcc/testsuite/gcc.dg/torture/stackalign/vararg-3.c
gcc/testsuite/gcc.dg/vect/vect.exp
gcc/testsuite/gcc.target/i386/pr39315-2.c
gcc/testsuite/gcc.target/i386/pr39315-4.c
gcc/testsuite/gcc.target/i386/sol2-check.h [deleted file]
gcc/testsuite/gcc.target/i386/sse-check.h
gcc/testsuite/gcc.target/i386/sse-os-support.h [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/sse2-check.h
gcc/testsuite/gcc.target/i386/sse3-check.h
gcc/testsuite/gcc.target/i386/vperm-v2df.c
gcc/testsuite/gcc.target/i386/vperm-v2di.c
gcc/testsuite/gcc.target/i386/vperm-v4sf-1.c
gcc/testsuite/gcc.target/i386/vperm-v4si-1.c
gcc/testsuite/gfortran.dg/vect/vect.exp
gcc/testsuite/lib/fortran-torture.exp
gcc/testsuite/lib/target-supports.exp

index a789ecd2d88b3035c747a2def26190b8f4999c3f..0482650095e360c4509a5030068a42ce13471c4d 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * doc/sourcebuild.texi (Effective-Target Keywords): Document
+       sse_runtime, sse2_runtime.
+
 2010-07-18  Richard Sandiford  <rdsandiford@googlemail.com>
 
        * config/mips/mips.c (mips16_build_call_stub): Zero-extend the
        * config/pa/pa.h (CONSTANT_ALIGNMENT): Align strings to BITS_PER_WORD
        on all targets.
 
-Index: config/pa/pa.h
-===================================================================
---- config/pa/pa.h     (revision 162277)
-+++ config/pa/pa.h     (working copy)
-@@ -316,8 +316,9 @@
- #define BIGGEST_ALIGNMENT (2 * BITS_PER_WORD)
- /* Get around hp-ux assembler bug, and make strcpy of constants fast.  */
--#define CONSTANT_ALIGNMENT(CODE, TYPEALIGN) \
--  ((TYPEALIGN) < 32 ? 32 : (TYPEALIGN))
-+#define CONSTANT_ALIGNMENT(EXP, ALIGN)                \
-+  (TREE_CODE (EXP) == STRING_CST              \
-+   && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN))
- /* Make arrays of chars word-aligned for the same reasons.  */
- #define DATA_ALIGNMENT(TYPE, ALIGN)           \
 2010-07-17  Bernd Schmidt  <bernds@codesourcery.com>
 
        PR target/42235
index 191e42526864b4e25ebfaab7aa87fdf37daef703..33f2389db2cbe802c622fde5fee8891bdb67be09 100644 (file)
@@ -1607,9 +1607,15 @@ Target supports FPU instructions.
 @item sse
 Target supports compiling @code{sse} instructions.
 
+@item sse_runtime
+Target supports the execution of @code{sse} instructions.
+
 @item sse2
 Target supports compiling @code{sse2} instructions.
 
+@item sse2_runtime
+Target supports the execution of @code{sse2} instructions.
+
 @item sync_char_short
 Target supports atomic operations on @code{char} and @code{short}.
 
index 73fb7b78465edee68a49ae8203a13c3d3e5a0b3b..100d605e9ccd7b99cd70aa28f671d698e5b90214 100644 (file)
@@ -1,3 +1,53 @@
+2010-07-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * lib/target-supports.exp (check_sse_os_support_available): New
+       proc.
+       (check_sse_hw_available): New proc.
+       (check_effective_target_sse_runtime): New proc.
+       (check_effective_target_sse2_runtime): New proc.
+       * lib/fortran-torture.exp (get-fortran-torture-options): Only add
+       -msse2 if check_sse_os_support_available.
+       * g++.dg/vect/vect.exp: Only run -msse2 tests if
+       check_sse_os_support_available.
+       * gcc.dg/vect/vect.exp: Likewise.
+       * gfortran.dg/vect/vect.exp: Likewise.
+       * gcc.target/i386/sol2-check: Renamed to ...
+       * gcc.target/i386/sse-os-support.h: ... this.
+       (sol2_check): Renamed to ...
+       (sse_os_support): ... this.
+       Only test movss with xmm registers.
+       * gcc.target/i386/sse-check.h: Reflect new header and function names.
+       Removed ILL_INSN, ILL_INSN_LEN.
+       * gcc.target/i386/sse2-check.h: Likewise.
+       * gcc.target/i386/sse3-check.h: Likewise.
+       * gcc.dg/pr40550.c: Use dg-require-effective-target sse_runtime.
+       Removed cpuid.h, __get_cpuid test.
+       * g++.dg/other/i386-1.C: Use dg-require-effective-target sse2_runtime.
+       Removed cpuid.h, __get_cpuid test.
+       * g++.dg/other/pr40446.C: Likewise.
+       * gcc.dg/compat/union-m128-1_main.c: Likewise.
+       * gcc.dg/compat/vector-1a_main.c: Likewise.
+       * gcc.dg/compat/vector-2a_main.c: Likewise.
+       * gcc.dg/pr36584.c: Likewise.
+       * gcc.dg/pr37544.c: Likewise.
+       * gcc.dg/torture/pr16104-1.c: Likewise.
+       * gcc.dg/torture/stackalign/alloca-2.c: Likewise.
+       * gcc.dg/torture/stackalign/alloca-3.c: Likewise.
+       * gcc.dg/torture/stackalign/push-1.c: Likewise.
+       * gcc.dg/torture/stackalign/vararg-3.c: Likewise.
+       * gcc.dg/torture/pr35771.h: Removed cpuid.h, __get_cpuid test.
+       * gcc.dg/torture/pr35771-1.c: Use dg-require-effective-target
+       sse2_runtime.
+       * gcc.dg/torture/pr35771-2.c: Likewise.
+       * gcc.dg/torture/pr35771-3.c: Likewise.
+       * gcc.target/i386/pr39315-2.c: Likewise.
+       * gcc.target/i386/pr39315-4.c: Likewise.
+       * gcc.target/i386/vperm-v2df.c: Likewise.
+       * gcc.target/i386/vperm-v2di.c: Likewise.
+       * gcc.target/i386/vperm-v4si-1.c: Likewise.
+       * gcc.target/i386/vperm-v4sf-1.c: Use dg-require-effective-target
+       sse_runtime.
+
 2010-07-19  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/44353
index 5a91e603660d17b30b71b7e27e15809814a2fbd6..51048686f7f9749c395908454556b3e3716afe84 100644 (file)
@@ -1,11 +1,10 @@
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-options "-msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 #include <xmmintrin.h>
 
-#include "cpuid.h"
-
 static void
 sse2_test (void)
 {
@@ -25,14 +24,6 @@ sse2_test (void)
 int
 main ()
 {
-  unsigned int eax, ebx, ecx, edx;
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE2 test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    sse2_test ();
-
+  sse2_test ();
   return 0;
 }
index dd0aa4820750b11ec7951ba7edfcb00fd8b568ce..b4be0d05617145a93f442700a1d0a47b3fc19604 100644 (file)
@@ -2,9 +2,9 @@
 // { dg-do run { target i?86-*-* x86_64-*-* } }
 // { dg-options "-O1 -msse2" }
 // { dg-require-effective-target sse2 }
+// { dg-require-effective-target sse2_runtime }
 
 #include <emmintrin.h>
-#include "cpuid.h"
 
 extern "C" void abort ();
 
@@ -34,14 +34,6 @@ sse2_test ()
 int
 main ()
 {
-  unsigned int eax, ebx, ecx, edx;
-
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE2 test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    sse2_test ();
-
+  sse2_test ();
   return 0;
 }
index aa450661107376a9845bb7a724a3a666b4e23494..18e8355cd7a14c3559df84fde7d776bf002a56b2 100644 (file)
@@ -79,7 +79,7 @@ if  [istarget "powerpc-*paired*"]  {
        return
     }
     lappend DEFAULT_VECTCFLAGS "-msse2"
-    if [check_sse2_hw_available] {
+    if { [check_sse2_hw_available] && [check_sse_os_support_available] } {
        set dg-do-what-default run
     } else {
        set dg-do-what-default compile
index cfd081db8966873679ca238907ceb1c802ddc4fb..602acf8c112ef6e2927d6227fc4aadc32aa8c01c 100644 (file)
@@ -1,8 +1,7 @@
 /* { dg-skip-if "test SSE2 support" { ! { i?86-*-* x86_64-*-* } } } */
 /* { dg-options "-O" } */
 /* { dg-require-effective-target sse2 } */
-
-#include "cpuid.h"
+/* { dg-require-effective-target sse2_runtime } */
 
 /* Test function argument passing.  PR target/15301.  */
 
@@ -12,14 +11,6 @@ extern void exit (int);
 int
 main ()
 {
-  unsigned int eax, ebx, ecx, edx;
-
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE vector test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    union_m128_1_x ();
-
+  union_m128_1_x ();
   exit (0);
 }
index c5acc35f4d81333751f660f2f919429ba6a38b4e..11b4511749ee7e102651938dc5bacf5d84a7c13a 100644 (file)
@@ -1,12 +1,11 @@
 /* { dg-skip-if "test SSE2 vector" { ! { i?86-*-* x86_64-*-* } } } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_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 +13,6 @@ int fails;
 int
 main ()
 {
-  unsigned int eax, ebx, ecx, edx;
-
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE vector test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    vector_1_x ();
-
+  vector_1_x ();
   exit (0);
 }
index 164c4b25e2e6e261d653548d4a1c0a47337ec2f9..8457e5aedc35a755626f5a3503b70df0f6710386 100644 (file)
@@ -1,12 +1,11 @@
 /* { dg-skip-if "test SSE2 support" { ! { i?86-*-* x86_64-*-* } } } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_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 +13,6 @@ int fails;
 int
 main ()
 {
-  unsigned int eax, ebx, ecx, edx;
-
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE vector test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    vector_2_x ();
-
+  vector_2_x ();
   exit (0);
 }
index a39eb572e1d0078c0bce83b9e6b5a16409df0bf9..2af71aea1221dc93abcfc6c2f010a4fb86d01ae8 100644 (file)
@@ -2,10 +2,7 @@
 /* { dg-options "-O2 -lm" } */
 /* { dg-options "-O2 -msse2 -mfpmath=sse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
 /* { dg-require-effective-target sse2 { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
-
-#ifdef __i386__
-#include "cpuid.h"
-#endif
+/* { dg-require-effective-target sse2_runtime { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
 
 extern double fabs (double);
 extern void abort (void);
@@ -263,16 +260,6 @@ main ()
   double roots[7];
   int nroots;
 
-#ifdef __i386__
-  unsigned int eax, ebx, ecx, edx;
-
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  if (!(edx & bit_SSE2))
-    return 0;
-#endif
-
   nroots = sbisect (6, sseq, 0.0, 10000000.0, 5, 1, roots);
   if (nroots != 4)
     abort ();
index efca1db6d4a4d2ccda4287b3d0ebe123c39eb1f3..dec321bf7217cf8e5fa94d4726b33d94abe7607e 100644 (file)
@@ -2,10 +2,7 @@
 /* { dg-options "-O2" } */
 /* { dg-options "-O2 -msse2 -mtune=core2 -mfpmath=387" { target { i?86-*-* x86_64-*-* } } } */
 /* { dg-require-effective-target sse2 { target { i?86-*-* x86_64-*-* } } } */
-
-#ifdef __i386__
-#include "cpuid.h"
-#endif
+/* { dg-require-effective-target sse2_runtime { target { i?86-*-* x86_64-*-* } } } */
 
 extern void abort (void);
 
@@ -16,17 +13,6 @@ int main(void)
 
   int i;
 
-#ifdef __i386__
-  unsigned int eax, ebx, ecx, edx;
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE2 test only if host has SSE2 support.  */
-  if (!(edx & bit_SSE2))
-    return 0;
-#endif
-
   for (i = 0; i < 1000; i++)
     arr[i] = 4294967296.0 + (double)i;
 
index 3dd11eb6c714a2f3437c67faa905ba3ca14ec46d..2e477293ed17d3e6223a73ce143e54e9e1341a23 100644 (file)
@@ -1,10 +1,7 @@
 /* { dg-do run } */
 /* { dg-options "-msse" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
 /* { dg-require-effective-target sse { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
-
-#ifdef __i386__
-#include "cpuid.h"
-#endif
+/* { dg-require-effective-target sse_runtime { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
 
 typedef float v2sf __attribute__ ((vector_size (2 * sizeof(float))));
 
@@ -18,18 +15,6 @@ static void test (void)
 
 int main ()
 {
-
-#ifdef __i386__
-  unsigned int eax, ebx, ecx, edx;
-
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  if (!(edx & bit_SSE))
-    return 0;
-#endif
-
   test ();
-
   return 0;
 }
index 3eb405906a21897d07182de64f84825ec4741bb9..d4aed810a3bcbb39b06ae574da411e1f0f102550 100644 (file)
@@ -2,8 +2,7 @@
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-options "-msse2" } */
 /* { dg-require-effective-target sse2 } */
-
-#include "cpuid.h"
+/* { dg-require-effective-target sse2_runtime } */
 
 extern void abort (void);
 
@@ -76,14 +75,6 @@ do_test (void)
 int
 main (void)
 {
-  unsigned int eax, ebx, ecx, edx;
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE2 test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    do_test ();
-
+  do_test ();
   return 0;
 }
index 8def464aa6dfcd9b0305db7c8f89a5ba95e03268..4e95700c72ba1a9eac8f59ce1ca2d2bf6816e84e 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-options "-msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
 
index 3d6add10de96e7249646dce2fdacbb4e3c3c2a56..ae5bb00d91f237d7706288eb8d0e5169aa51eb77 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-options "-msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 typedef double __m128d __attribute__ ((__vector_size__ (16), __may_alias__));
 
index 9a69b21a5117bac2c2aea73c7897385cc290d34b..556f786dfaab2dbd2f5c7e79a8428eee6f1356c3 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
 /* { dg-options "-msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));
 
index 01c248751c16cc686dc0f3b83ff63096e22b1390..7b921c41ba92bfc3be8ee7c8fd4110a365e03314 100644 (file)
@@ -1,7 +1,5 @@
 typedef TYPE __attribute__((aligned(1))) unaligned;
 
-#include "cpuid.h"
-
 extern void abort (void);
 
 
@@ -27,14 +25,6 @@ do_test (void)
 int
 main (void)
 {
-  unsigned int eax, ebx, ecx, edx;
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE2 test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    do_test ();
-
+  do_test ();
   return 0;
 }
index cbbb9d03a4cbf668e6ca2d61a7f2cb550a0b62f8..54232bfae694f8a9f6297a5c391b9eb237c73928 100644 (file)
@@ -2,9 +2,9 @@
 /* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
 /* { dg-options "-msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 #include <emmintrin.h>
-#include "cpuid.h"
 #include "check.h"
 
 #ifndef ALIGNMENT
@@ -44,14 +44,7 @@ int
 main (void)
 {
   __m128 x = { 1.0 };
-  unsigned int eax, ebx, ecx, edx;
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE2 test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    foo (x, x, x, 5);
+  foo (x, x, x, 5);
 
   return 0;
 }
index ffe52f2a3e035df4be1a861ca2a80af5eac53f22..8a91121febe5264a3e17ce00c3ccf68475726c33 100644 (file)
@@ -2,9 +2,9 @@
 /* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
 /* { dg-options "-msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 #include <emmintrin.h>
-#include "cpuid.h"
 #include "check.h"
 
 #ifndef ALIGNMENT
@@ -44,14 +44,7 @@ int
 main (void)
 {
   __m128 x = { 1.0 };
-  unsigned int eax, ebx, ecx, edx;
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE2 test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    foo (x, x, x, x, 5);
+  foo (x, x, x, x, 5);
 
   return 0;
 }
index c020d73129363d6b72fd45df3d87dda3aab5f3f8..c58d1ec61aa8a98410453c3f3a83f9c9f17d3695 100644 (file)
@@ -2,9 +2,9 @@
 /* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
 /* { dg-options "-msse2 -mpreferred-stack-boundary=2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 #include <emmintrin.h>
-#include "cpuid.h"
 
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
 typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
@@ -42,19 +42,11 @@ int
 main (void)
 {
   __m128 x = { 1.0 };
-  unsigned int eax, ebx, ecx, edx;
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
 
-  /* Run SSE2 test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    {
-      foo (x, x, x, x, 5);
+  foo (x, x, x, x, 5);
 
-      if (__builtin_memcmp (&r, &x, sizeof (r)))
-       abort ();
-    }
+  if (__builtin_memcmp (&r, &x, sizeof (r)))
+    abort ();
 
   return 0;
 }
index 3e34cf148b76df3dd841ceb0f82bb7cb2b648d0b..734cf71bcae99ab875b5121341120f8d554d648a 100644 (file)
@@ -2,10 +2,10 @@
 /* { dg-do run { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
 /* { dg-options "-msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 #include <stdarg.h>
 #include <emmintrin.h>
-#include "cpuid.h"
 #include "check.h"
 
 #ifndef ALIGNMENT
@@ -72,14 +72,8 @@ int
 main (void)
 {
   __m128 x = { 1.0 };
-  unsigned int eax, ebx, ecx, edx;
-  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
-    return 0;
-
-  /* Run SSE2 test only if host has SSE2 support.  */
-  if (edx & bit_SSE2)
-    foo ("foo", 5, 5.0, x);
+
+  foo ("foo", 5, 5.0, x);
 
   return 0;
 }
index 98477c4c8cd8f7e357037b923efe72a2f2ec4f1c..eecb13a7823f0ae6fe5ad14e95f08ed16b37439f 100644 (file)
@@ -71,7 +71,7 @@ if  [istarget "powerpc-*paired*"]  {
        return
     }
     lappend DEFAULT_VECTCFLAGS "-msse2"
-    if [check_sse2_hw_available] {
+    if { [check_sse2_hw_available] && [check_sse_os_support_available] } {
        set dg-do-what-default run
     } else {
        set dg-do-what-default compile
index 5363e97509b10b7e56b938cecd0c38452bb3aa35..ee74def22469312485a231e50ed13de902e22947 100644 (file)
@@ -2,6 +2,7 @@
 /* { dg-do run } */
 /* { dg-options "-O -msse2 -mtune=generic" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 /* { dg-additional-sources pr39315-check.c } */
 
 typedef float __m128 __attribute__ ((__vector_size__ (16)));
index 4a62a1d51b93e701acdf7833d1bd75c68f3ce57e..107933fa0c0edbc60bb8291164e318a6e267e924 100644 (file)
@@ -2,6 +2,7 @@
 /* { dg-do run } */
 /* { dg-options "-O -msse2 -mtune=generic" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 /* { dg-additional-sources pr39315-check.c } */
 
 typedef float __m128 __attribute__ ((__vector_size__ (16)));
diff --git a/gcc/testsuite/gcc.target/i386/sol2-check.h b/gcc/testsuite/gcc.target/i386/sol2-check.h
deleted file mode 100644 (file)
index 25a915e..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#if defined(__sun__) && defined(__svr4__)
-/* Make sure sigaction() is declared even with -std=c99.  */
-#define __EXTENSIONS__
-#include <signal.h>
-#include <ucontext.h>
-
-static volatile sig_atomic_t sigill_caught;
-
-static void
-sigill_hdlr (int sig __attribute((unused)),
-            siginfo_t *sip __attribute__((unused)),
-            ucontext_t *ucp)
-{
-  sigill_caught = 1;
-  /* Set PC to the instruction after the faulting one to skip over it,
-     otherwise we enter an infinite loop.  */
-  ucp->uc_mcontext.gregs[EIP] += ILL_INSN_LEN;
-  setcontext (ucp);
-}
-#endif
-
-/* Solaris 2 before Solaris 9 4/04 cannot execute SSE/SSE2 instructions
-   even if the CPU supports them.  Programs receive SIGILL instead, so
-   check for that at runtime.  */
-static int
-sol2_check (void)
-{
-#if defined(__sun__) && defined(__svr4__)
-  struct sigaction act, oact;
-
-  act.sa_handler = sigill_hdlr;
-  sigemptyset (&act.sa_mask);
-  /* Need to set SA_SIGINFO so a ucontext_t * is passed to the handler.  */
-  act.sa_flags = SA_SIGINFO;
-  sigaction (SIGILL, &act, &oact);
-
-  ILL_INSN;
-
-  sigaction (SIGILL, &oact, NULL);
-
-  if (sigill_caught)
-    exit (0);
-  else
-    return 1;
-#else
-  return 1;
-#endif /* __sun__ && __svr4__ */
-}
index d6c92a35a44750870f2bb40474c3afae417d9295..11b71bc3e97513be00181c074c06d977247f35c2 100644 (file)
@@ -1,13 +1,7 @@
 #include <stdlib.h>
 #include "m128-check.h"
-
 #include "cpuid.h"
-
-/* We need a single SSE instruction here so the handler can safely skip
-   over it.  */
-#define ILL_INSN __asm__ volatile ("movss %xmm2,%xmm1")
-#define ILL_INSN_LEN 4
-#include "sol2-check.h"
+#include "sse-os-support.h"
 
 static void sse_test (void);
 
@@ -27,7 +21,7 @@ main ()
     return 0;
 
   /* Run SSE test only if host has SSE support.  */
-  if ((edx & bit_SSE) && sol2_check ())
+  if ((edx & bit_SSE) && sse_os_support ())
     do_test ();
 
   return 0;
diff --git a/gcc/testsuite/gcc.target/i386/sse-os-support.h b/gcc/testsuite/gcc.target/i386/sse-os-support.h
new file mode 100644 (file)
index 0000000..a2b4e2d
--- /dev/null
@@ -0,0 +1,55 @@
+#if defined(__sun__) && defined(__svr4__)
+/* Make sure sigaction() is declared even with -std=c99.  */
+#define __EXTENSIONS__
+#include <signal.h>
+#include <ucontext.h>
+
+static volatile sig_atomic_t sigill_caught;
+
+static void
+sigill_hdlr (int sig __attribute((unused)),
+            siginfo_t *sip __attribute__((unused)),
+            ucontext_t *ucp)
+{
+  sigill_caught = 1;
+  /* Set PC to the instruction after the faulting one to skip over it,
+     otherwise we enter an infinite loop.  */
+  ucp->uc_mcontext.gregs[EIP] += 4;
+  setcontext (ucp);
+}
+#endif
+
+/* Check if the OS supports executing SSE instructions.  This function is
+   only used in sse-check.h, sse2-check.h, and sse3-check.h so far since
+   Solaris 8 and 9 won't run on newer CPUs anyway.  */
+
+static int
+sse_os_support (void)
+{
+#if defined(__sun__) && defined(__svr4__)
+  /* Solaris 2 before Solaris 9 4/04 cannot execute SSE instructions
+     even if the CPU supports them.  Programs receive SIGILL instead, so
+     check for that at runtime.  */
+
+  struct sigaction act, oact;
+
+  act.sa_handler = sigill_hdlr;
+  sigemptyset (&act.sa_mask);
+  /* Need to set SA_SIGINFO so a ucontext_t * is passed to the handler.  */
+  act.sa_flags = SA_SIGINFO;
+  sigaction (SIGILL, &act, &oact);
+
+  /* We need a single SSE instruction here so the handler can safely skip
+     over it.  */
+  __asm__ volatile ("movss %xmm2,%xmm1");
+
+  sigaction (SIGILL, &oact, NULL);
+
+  if (sigill_caught)
+    exit (0);
+  else
+    return 1;
+#else
+  return 1;
+#endif /* __sun__ && __svr4__ */
+}
index 7e91192f8c3a704d6cc9918f91b69db2defd2c07..fd4a6ce1dbf64f14028fc27f0882607cbb6c0c9f 100644 (file)
@@ -1,12 +1,7 @@
 #include <stdlib.h>
 #include "cpuid.h"
 #include "m128-check.h"
-
-/* We need a single SSE2 instruction here so the handler can safely skip
-   over it.  */
-#define ILL_INSN __asm__ volatile ("unpcklpd %xmm0,%xmm2")
-#define ILL_INSN_LEN 4
-#include "sol2-check.h"
+#include "sse-os-support.h"
 
 static void sse2_test (void);
 
@@ -26,7 +21,7 @@ main ()
     return 0;
 
   /* Run SSE2 test only if host has SSE2 support.  */
-  if ((edx & bit_SSE2) && sol2_check ())
+  if ((edx & bit_SSE2) && sse_os_support ())
     do_test ();
 
   return 0;
index c7b1896cf12de45cc10670728d4cb6a161eacd68..5a0a0b1a02e06e752a52b6b014fb980556ac1c8c 100644 (file)
@@ -1,13 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
-
 #include "cpuid.h"
-
-/* We need a single SSE3 instruction here so the handler can safely skip
-   over it.  */
-#define ILL_INSN __asm__ volatile ("movddup %xmm1,%xmm2")
-#define ILL_INSN_LEN 4
-#include "sol2-check.h"
+#include "sse-os-support.h"
 
 static void sse3_test (void);
 
@@ -27,7 +21,7 @@ main ()
     return 0;
  
   /* Run SSE3 test only if host has SSE3 support.  */
-  if ((ecx & bit_SSE3) && sol2_check ())
+  if ((ecx & bit_SSE3) && sse_os_support ())
     do_test ();
 
   return 0;
index d0394635c59c96aac99627723c82f670e55ef247..1a237f04b5d9a07f42d6f8dfe9ee58f669415352 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-options "-O -msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 #include "isa-check.h"
 
index 940de68af195214bfed1b524f2a255dfe2d1c024..b587d90b8fbe05011a742b42a3e19d8f51d761f6 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-options "-O -msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 #include "isa-check.h"
 
index b9fc9b172fef644d0b25fe484cd25628f3c19724..d8cb9e6b7942e2df24525d3f671b9f21403560d6 100644 (file)
@@ -1,5 +1,7 @@
 /* { dg-do run } */
 /* { dg-options "-O -msse" } */
+/* { dg-require-effective-target sse } */
+/* { dg-require-effective-target sse_runtime } */
 
 #include "isa-check.h"
 
index 93c25c6826a43f27d0710337cb3cf12bb64e2e43..3c2717dd751c0363ffd8c14643fbe40aa71cd05d 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-options "-O -msse2" } */
 /* { dg-require-effective-target sse2 } */
+/* { dg-require-effective-target sse2_runtime } */
 
 #include "isa-check.h"
 
index 39a1f9d811ac85350ee6bbe1dd03bc572fc2833c..2a09df5a92ef0750269115b06d4b8eaaac0a7fef 100644 (file)
@@ -72,7 +72,7 @@ if  [istarget "powerpc-*paired*"]  {
        return
     }
     lappend DEFAULT_VECTCFLAGS "-msse2"
-    if [check_sse2_hw_available] {
+    if { [check_sse2_hw_available] && [check_sse_os_support_available] } {
        set dg-do-what-default run
     } else {
        set dg-do-what-default compile
index 72ce9d682cd4a4426770adf4d249582eabef7493..cd24ace426f068824b6fda96383ab9af25fad0c1 100644 (file)
@@ -46,7 +46,8 @@ proc get-fortran-torture-options { } {
        set test_tree_vectorize 1
     } elseif { ( [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] )
               && [check_effective_target_sse2]
-              && [check_sse2_hw_available] } {
+              && [check_sse2_hw_available]
+              && [check_sse_os_support_available] } {
        lappend vectorizer_options "-msse2"
        set test_tree_vectorize 1
     } elseif { [istarget "mips*-*-*"]
index bb28a77074802b18cf80b40a238d6b2140b1746c..0378f807d63e7d5936faa3706c182cfd8e35d216 100644 (file)
@@ -910,6 +910,53 @@ proc check_750cl_hw_available { } {
     }]
 }
 
+# Return 1 if the target OS supports running SSE executables, 0
+# otherwise.  Cache the result.
+
+proc check_sse_os_support_available { } {
+    return [check_cached_effective_target sse_os_support_available {
+       # If this is not the right target then we can skip the test.
+       if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
+           expr 0
+       } elseif { [istarget i?86-*-solaris2*] } {
+           # The Solaris 2 kernel doesn't save and restore SSE registers
+           # before Solaris 9 4/04.  Before that, executables die with SIGILL.
+           check_runtime_nocache sse_os_support_available {
+               int main ()
+               {
+                   __asm__ volatile ("movss %xmm2,%xmm1");
+                   return 0;
+               }
+           } "-msse"
+       } else {
+           expr 1
+       }
+    }]
+}
+
+# Return 1 if the target supports executing SSE instructions, 0
+# otherwise.  Cache the result.
+
+proc check_sse_hw_available { } {
+    return [check_cached_effective_target sse_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 sse_hw_available {
+               #include "cpuid.h"
+               int main ()
+               {
+                 unsigned int eax, ebx, ecx, edx = 0;
+                 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
+                   return !(edx & bit_SSE);
+                 return 1;
+               }
+           } ""
+       }
+    }]
+}
+
 # Return 1 if the target supports executing SSE2 instructions, 0
 # otherwise.  Cache the result.
 
@@ -933,6 +980,26 @@ proc check_sse2_hw_available { } {
     }]
 }
 
+# Return 1 if the target supports running SSE executables, 0 otherwise.
+
+proc check_effective_target_sse_runtime { } {
+    if { [check_sse_hw_available] && [check_sse_os_support_available] } {
+       return 1
+    } else {
+       return 0
+    }
+}
+
+# Return 1 if the target supports running SSE2 executables, 0 otherwise.
+
+proc check_effective_target_sse2_runtime { } {
+    if { [check_sse2_hw_available] && [check_sse_os_support_available] } {
+       return 1
+    } else {
+       return 0
+    }
+}
+
 # Return 1 if the target supports executing VSX instructions, 0
 # otherwise.  Cache the result.