public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Run tests only if the machine supports the instruction set.
@ 2016-12-19 14:32 Dominik Vogt
  2016-12-19 16:51 ` [PATCH v2] " Dominik Vogt
  0 siblings, 1 reply; 11+ messages in thread
From: Dominik Vogt @ 2016-12-19 14:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 311 bytes --]

The attached patch is specific to S/390 but contains a small
common code change in gcc-dg.exp.  It fixes the notorious problem
of md tests running on an S/390 machine that does not support the
z13 instruction set.

Bootstrapped and tested on s390x biarch.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-ChangeLog --]
[-- Type: text/plain, Size: 627 bytes --]

gcc/ChangeLog-archlevel

	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define
	__s390_arch_level__.
gcc/testsuite/ChangeLog-setmem

	* gcc.target/s390/md/setmem_long-1.c: Use "runnable".
	* gcc.target/s390/md/rXsbg_mode_sXl.c: Likewise.
	* gcc.target/s390/md/andc-splitter-1.c: Likewise.
	* gcc.target/s390/md/andc-splitter-2.c: Likewise.
	* lib/gcc-dg.exp (gcc-dg-runtest): Export torture_current_flags.
	* gcc.target/s390/s390.exp: Import torture_current_flags.
	(check_effective_target_runnable): New.
	(check_effective_target_z10_instructions): Removed.
	(MD_TEST_OPTS): Add optimization level without -march=.

[-- Attachment #3: 0001-S-390-Run-md-tests-only-if-the-machine-supports-the-.patch --]
[-- Type: text/plain, Size: 11467 bytes --]

From 21e99fb09c5e8350892d99e6c351515333594aae Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Tue, 13 Dec 2016 10:21:08 +0100
Subject: [PATCH] S/390: Run md tests only if the machine supports the
 instruction set.

---
 gcc/config/s390/s390-c.c                           | 15 ++++++
 gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c | 19 +++----
 gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c | 19 +++----
 gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c  |  4 +-
 gcc/testsuite/gcc.target/s390/md/setmem_long-1.c   |  7 +--
 gcc/testsuite/gcc.target/s390/s390.exp             | 60 ++++++++++++++++------
 gcc/testsuite/lib/gcc-dg.exp                       |  2 +
 7 files changed, 87 insertions(+), 39 deletions(-)

diff --git a/gcc/config/s390/s390-c.c b/gcc/config/s390/s390-c.c
index fcf7477..8a9ea79 100644
--- a/gcc/config/s390/s390-c.c
+++ b/gcc/config/s390/s390-c.c
@@ -328,6 +328,21 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
 			   "__bool=__attribute__((s390_vector_bool)) unsigned",
 			   "__bool");
+  {
+    char macro_def[64];
+    int arch_level;
+    gcc_assert (s390_arch != PROCESSOR_NATIVE);
+    arch_level = (int)s390_arch + 3;
+    if (s390_arch >= PROCESSOR_2094_Z9_EC)
+      /* Z9_EC has the same level as Z9_109.  */
+      arch_level--;
+    /* Review when a new arch is added and increase the value.  */
+    char dummy[23 - 2 * PROCESSOR_max] __attribute__((unused));
+    sprintf (macro_def, "__s390_arch_level__=%d", arch_level);
+    cpp_undef (pfile, "__s390_arch_level__");
+    cpp_define (pfile, macro_def);
+  }
+
   if (!flag_iso)
     {
       s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
index ed78921..9c41ac4 100644
--- a/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run { target { lp64 } } } */
+/* { dg-do compile { target { lp64 } } } */
 /* { dg-options "-mzarch -save-temps -dP" } */
+/* { dg-do run { target { lp64 && runnable } } } */
 /* Skip test if -O0 is present on the command line:
 
     { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
@@ -13,26 +14,26 @@
 __attribute__ ((noinline))
 unsigned long andc_vv(unsigned long a, unsigned long b)
 { return ~b & a; }
-/* { dg-final { scan-assembler ":15 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":15 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_pv(unsigned long *a, unsigned long b)
 { return ~b & *a; }
-/* { dg-final { scan-assembler ":21 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":21 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_vp(unsigned long a, unsigned long *b)
 { return ~*b & a; }
-/* { dg-final { scan-assembler ":27 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":27 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_pp(unsigned long *a, unsigned long *b)
 { return ~*b & *a; }
-/* { dg-final { scan-assembler ":33 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":33 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*xordi3\}" } } */
 
 /* { dg-final { scan-assembler-times "\tngr\?k\?\t" 4 } } */
 /* { dg-final { scan-assembler-times "\txgr\?\t" 4 } } */
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
index d88da4d..3d4170a 100644
--- a/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run } */
+/* { dg-do compile } */
 /* { dg-options "-save-temps -dP" } */
+/* { dg-do run { target { runnable } } } */
 /* Skip test if -O0 is present on the command line:
 
     { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
@@ -13,26 +14,26 @@
 __attribute__ ((noinline))
 unsigned int andc_vv(unsigned int a, unsigned int b)
 { return ~b & a; }
-/* { dg-final { scan-assembler ":15 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":15 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_pv(unsigned int *a, unsigned int b)
 { return ~b & *a; }
-/* { dg-final { scan-assembler ":21 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":21 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_vp(unsigned int a, unsigned int *b)
 { return ~*b & a; }
-/* { dg-final { scan-assembler ":27 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":27 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_pp(unsigned int *a, unsigned int *b)
 { return ~*b & *a; }
-/* { dg-final { scan-assembler ":33 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":33 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*xorsi3\}" } } */
 
 /* { dg-final { scan-assembler-times "\tnr\?k\?\t" 4 } } */
 /* { dg-final { scan-assembler-times "\txr\?k\?\t" 4 } } */
diff --git a/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c b/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
index ad442da..3a61e60 100644
--- a/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
+++ b/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
@@ -7,8 +7,8 @@
    always wins, even if the condition is false.  If this test is run on hardware
    older than z10 with a buggy dejagnu release, the execution part will fail.
 
-    { dg-do assemble { target { ! z10_instructions } } }
-    { dg-do run { target { z10_instructions } } }
+    { dg-do assemble }
+    { dg-do run { target { runnable } } }
 
    Skip test if -O0, -march=z900, -march=z9-109 or -march=z9-ec is present on
    the command line:
diff --git a/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c b/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
index bd0c594..ceb9244 100644
--- a/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
+++ b/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run } */
+/* { dg-do compile } */
 /* { dg-options "-mmvcle -dP -save-temps" } */
+/* { dg-do run { target { runnable } } } */
 
 __attribute__ ((noinline))
 void test(char *p, char c, int len)
@@ -16,8 +17,8 @@ void test2(char *p, int c, int len)
 }
 
 /* Check that the right patterns are used.  */
-/* { dg-final { scan-assembler-times {c"?:9 .*{[*]setmem_long_?3?1?z?}} 1 } } */
-/* { dg-final { scan-assembler-times {c"?:15 .*{[*]setmem_long_and_?3?1?z?}} 1 { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-times {c"?:10 .*{[*]setmem_long_?3?1?z?}} 1 } } */
+/* { dg-final { scan-assembler-times {c"?:16 .*{[*]setmem_long_and_?3?1?z?}} 1 { xfail *-*-* } } } */
 
 #define LEN 500
 char buf[LEN + 2];
diff --git a/gcc/testsuite/gcc.target/s390/s390.exp b/gcc/testsuite/gcc.target/s390/s390.exp
index 450dcaf..719dad6 100644
--- a/gcc/testsuite/gcc.target/s390/s390.exp
+++ b/gcc/testsuite/gcc.target/s390/s390.exp
@@ -16,6 +16,9 @@
 
 # GCC testsuite that uses the `dg.exp' driver.
 
+global torture_current_flags
+set torture_current_flags ""
+
 # Exit immediately if this isn't a s390 target.
 if ![istarget s390*-*-*] then {
   return
@@ -24,17 +27,6 @@ if ![istarget s390*-*-*] then {
 # Load support procs.
 load_lib gcc-dg.exp
 
-# Return 1 if z10 instructions work.
-proc check_effective_target_z10_instructions { } {
-    if { ![check_runtime s390_check_z10_instructions [subst {
-	int main (void)
-	{
-	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
-	    return 0;
-	}
-    }] "-march=z10 -mzarch" ] } { return 0 } else { return 1 }
-}
-
 # Return 1 if the the assembler understands .machine and .machinemode.  The
 # target attribute needs that feature to work.
 proc check_effective_target_target_attribute { } {
@@ -78,6 +70,42 @@ proc check_effective_target_vector { } {
     }] "-march=z13 -mzarch" ] } { return 0 } else { return 1 }
 }
 
+# Return 1 if a program using the full instruction set allowed by
+# the compiler option can be executed.
+proc check_effective_target_runnable { } {
+    global torture_current_flags
+    if { ![check_runtime_nocache s390_check_runnable [subst {
+	int main (void)
+	{
+	#if __s390_arch_level__ >= 11
+	    asm ("lcbb %%r2,0(%%r15),0" : : );
+	#elif __s390_arch_level__ >= 10
+	    asm ("risbgn %%r2,%%r2,0,0,0" : : );
+	#elif __s390_arch_level__ >= 9
+	    asm ("sgrk %%r2,%%r2,%%r2" : : );
+	#elif __s390_arch_level__ >= 8
+	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
+	#elif __s390_arch_level__ >= 7
+	    asm ("nilf %%r2,0" : : );
+	#elif __s390_arch_level__ >= 6
+	    asm ("lay %%r2,0(%%r15)" : : );
+	#elif __s390_arch_level__ >= 5
+	    asm ("tam" : : );
+	#endif
+	#ifdef __HTM__
+	  {
+	    unsigned int nd;
+	    asm ("etnd %0" : "=d" (nd));
+	  }
+	#endif
+	#ifdef __VEC__
+	    asm ("vzero %%v0" : : );
+	#endif
+	  return 0;
+	}
+    }] "$torture_current_flags -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CFLAGS
 if ![info exists DEFAULT_CFLAGS] then {
@@ -112,11 +140,11 @@ torture-finish
 # Additional md torture tests.
 torture-init
 set MD_TEST_OPTS [list \
-	{-Os -march=z900} {-Os -march=z13} \
-	{-O0 -march=z900} {-O0 -march=z13} \
-	{-O1 -march=z900} {-O1 -march=z13} \
-	{-O2 -march=z900} {-O2 -march=z13} \
-	{-O3 -march=z900} {-O3 -march=z13}]
+	{-Os -march=z900} {-Os -march=z13} {-Os} \
+	{-O0 -march=z900} {-O0 -march=z13} {-O0} \
+	{-O1 -march=z900} {-O1 -march=z13} {-O1} \
+	{-O2 -march=z900} {-O2 -march=z13} {-O2} \
+	{-O3 -march=z900} {-O3 -march=z13} {-O3}]
 set-torture-options $MD_TEST_OPTS
 gcc-dg-runtest [lsort [glob -nocomplain $md_tests]] "" $DEFAULT_CFLAGS
 torture-finish
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 6217272..d9681b1 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -533,6 +533,8 @@ proc gcc-dg-runtest { testcases flags default-extra-flags } {
 	set nshort [file tail [file dirname $test]]/[file tail $test]
 
 	foreach flags_t $option_list {
+	    global torture_current_flags
+	    set torture_current_flags "$flags_t"
 	    verbose "Testing $nshort, $flags $flags_t" 1
 	    dg-test $test "$flags $flags_t" ${default-extra-flags}
 	}
-- 
2.3.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] Run tests only if the machine supports the instruction set.
  2016-12-19 14:32 Run tests only if the machine supports the instruction set Dominik Vogt
@ 2016-12-19 16:51 ` Dominik Vogt
  2016-12-19 17:01   ` Jakub Jelinek
  0 siblings, 1 reply; 11+ messages in thread
From: Dominik Vogt @ 2016-12-19 16:51 UTC (permalink / raw)
  To: gcc-patches, Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 634 bytes --]

On Mon, Dec 19, 2016 at 03:28:06PM +0100, Dominik Vogt wrote:
> The attached patch is specific to S/390 but contains a small
> common code change in gcc-dg.exp.  It fixes the notorious problem
> of md tests running on an S/390 machine that does not support the
> z13 instruction set.
> 
> Bootstrapped and tested on s390x biarch.

Version 2 with results of internal discussion:

 * Renamed __s390_arh_level__ to upper case.
 * Replaced __VECTOR__ with new macro __S390_VX__.
 * Added individual (but currently unused) effective-target
   functions for the various architectures.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-v2-ChangeLog --]
[-- Type: text/plain, Size: 949 bytes --]

gcc/ChangeLog-archlevel

	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define
	__S390_ARCH_LEVEL__.
gcc/testsuite/ChangeLog-setmem

	* gcc.target/s390/md/setmem_long-1.c: Use "runnable".
	* gcc.target/s390/md/rXsbg_mode_sXl.c: Likewise.
	* gcc.target/s390/md/andc-splitter-1.c: Likewise.
	* gcc.target/s390/md/andc-splitter-2.c: Likewise.
	* lib/gcc-dg.exp (gcc-dg-runtest): Export torture_current_flags.
	* gcc.target/s390/s390.exp: Import torture_current_flags.
	(check_effective_target_runnable): New.
	(check_effective_target_z900_runnable): New.
	(check_effective_target_z990_runnable): New.
	(check_effective_target_z9_ec_runnable): New.
	(check_effective_target_z10_runnable): New.
	(check_effective_target_z196_runnable): New.
	(check_effective_target_zEC12_runnable): New.
	(check_effective_target_z13_runnable): New.
	(check_effective_target_z10_instructions): Removed.
	(MD_TEST_OPTS): Add optimization level without -march=.

[-- Attachment #3: 0001-v2-S-390-Run-md-tests-only-if-the-machine-supports-the-.patch --]
[-- Type: text/plain, Size: 13840 bytes --]

From 7c74ce8212fa85272e1928b2d2df44b74cba5d0a Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Tue, 13 Dec 2016 10:21:08 +0100
Subject: [PATCH] S/390: Run md tests only if the machine supports the
 instruction set.

---
 gcc/config/s390/s390-c.c                           |  17 +++
 gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c |  19 ++--
 gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c |  19 ++--
 gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c  |   4 +-
 gcc/testsuite/gcc.target/s390/md/setmem_long-1.c   |   7 +-
 gcc/testsuite/gcc.target/s390/s390.exp             | 126 ++++++++++++++++++---
 gcc/testsuite/lib/gcc-dg.exp                       |   2 +
 7 files changed, 155 insertions(+), 39 deletions(-)

diff --git a/gcc/config/s390/s390-c.c b/gcc/config/s390/s390-c.c
index fcf7477..e841365 100644
--- a/gcc/config/s390/s390-c.c
+++ b/gcc/config/s390/s390-c.c
@@ -320,6 +320,8 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
 {
   s390_def_or_undef_macro (pfile, MASK_OPT_HTM, old_opts, opts,
 			   "__HTM__", "__HTM__");
+  s390_def_or_undef_macro (pfile, MASK_OPT_VX, old_opts, opts,
+			   "__S390_VX__", "__S390_VX__");
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
 			   "__VEC__=10301", "__VEC__");
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
@@ -328,6 +330,21 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
 			   "__bool=__attribute__((s390_vector_bool)) unsigned",
 			   "__bool");
+  {
+    char macro_def[64];
+    int arch_level;
+    gcc_assert (s390_arch != PROCESSOR_NATIVE);
+    arch_level = (int)s390_arch + 3;
+    if (s390_arch >= PROCESSOR_2094_Z9_EC)
+      /* Z9_EC has the same level as Z9_109.  */
+      arch_level--;
+    /* Review when a new arch is added and increase the value.  */
+    char dummy[23 - 2 * PROCESSOR_max] __attribute__((unused));
+    sprintf (macro_def, "__S390_ARCH_LEVEL__=%d", arch_level);
+    cpp_undef (pfile, "__S390_ARCH_LEVEL__");
+    cpp_define (pfile, macro_def);
+  }
+
   if (!flag_iso)
     {
       s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
index ed78921..9c41ac4 100644
--- a/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run { target { lp64 } } } */
+/* { dg-do compile { target { lp64 } } } */
 /* { dg-options "-mzarch -save-temps -dP" } */
+/* { dg-do run { target { lp64 && runnable } } } */
 /* Skip test if -O0 is present on the command line:
 
     { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
@@ -13,26 +14,26 @@
 __attribute__ ((noinline))
 unsigned long andc_vv(unsigned long a, unsigned long b)
 { return ~b & a; }
-/* { dg-final { scan-assembler ":15 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":15 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_pv(unsigned long *a, unsigned long b)
 { return ~b & *a; }
-/* { dg-final { scan-assembler ":21 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":21 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_vp(unsigned long a, unsigned long *b)
 { return ~*b & a; }
-/* { dg-final { scan-assembler ":27 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":27 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_pp(unsigned long *a, unsigned long *b)
 { return ~*b & *a; }
-/* { dg-final { scan-assembler ":33 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":33 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*xordi3\}" } } */
 
 /* { dg-final { scan-assembler-times "\tngr\?k\?\t" 4 } } */
 /* { dg-final { scan-assembler-times "\txgr\?\t" 4 } } */
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
index d88da4d..3d4170a 100644
--- a/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run } */
+/* { dg-do compile } */
 /* { dg-options "-save-temps -dP" } */
+/* { dg-do run { target { runnable } } } */
 /* Skip test if -O0 is present on the command line:
 
     { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
@@ -13,26 +14,26 @@
 __attribute__ ((noinline))
 unsigned int andc_vv(unsigned int a, unsigned int b)
 { return ~b & a; }
-/* { dg-final { scan-assembler ":15 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":15 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_pv(unsigned int *a, unsigned int b)
 { return ~b & *a; }
-/* { dg-final { scan-assembler ":21 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":21 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_vp(unsigned int a, unsigned int *b)
 { return ~*b & a; }
-/* { dg-final { scan-assembler ":27 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":27 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_pp(unsigned int *a, unsigned int *b)
 { return ~*b & *a; }
-/* { dg-final { scan-assembler ":33 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":33 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*xorsi3\}" } } */
 
 /* { dg-final { scan-assembler-times "\tnr\?k\?\t" 4 } } */
 /* { dg-final { scan-assembler-times "\txr\?k\?\t" 4 } } */
diff --git a/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c b/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
index ad442da..3a61e60 100644
--- a/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
+++ b/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
@@ -7,8 +7,8 @@
    always wins, even if the condition is false.  If this test is run on hardware
    older than z10 with a buggy dejagnu release, the execution part will fail.
 
-    { dg-do assemble { target { ! z10_instructions } } }
-    { dg-do run { target { z10_instructions } } }
+    { dg-do assemble }
+    { dg-do run { target { runnable } } }
 
    Skip test if -O0, -march=z900, -march=z9-109 or -march=z9-ec is present on
    the command line:
diff --git a/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c b/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
index bd0c594..ceb9244 100644
--- a/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
+++ b/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run } */
+/* { dg-do compile } */
 /* { dg-options "-mmvcle -dP -save-temps" } */
+/* { dg-do run { target { runnable } } } */
 
 __attribute__ ((noinline))
 void test(char *p, char c, int len)
@@ -16,8 +17,8 @@ void test2(char *p, int c, int len)
 }
 
 /* Check that the right patterns are used.  */
-/* { dg-final { scan-assembler-times {c"?:9 .*{[*]setmem_long_?3?1?z?}} 1 } } */
-/* { dg-final { scan-assembler-times {c"?:15 .*{[*]setmem_long_and_?3?1?z?}} 1 { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-times {c"?:10 .*{[*]setmem_long_?3?1?z?}} 1 } } */
+/* { dg-final { scan-assembler-times {c"?:16 .*{[*]setmem_long_and_?3?1?z?}} 1 { xfail *-*-* } } } */
 
 #define LEN 500
 char buf[LEN + 2];
diff --git a/gcc/testsuite/gcc.target/s390/s390.exp b/gcc/testsuite/gcc.target/s390/s390.exp
index 450dcaf..f9213f5 100644
--- a/gcc/testsuite/gcc.target/s390/s390.exp
+++ b/gcc/testsuite/gcc.target/s390/s390.exp
@@ -16,6 +16,9 @@
 
 # GCC testsuite that uses the `dg.exp' driver.
 
+global torture_current_flags
+set torture_current_flags ""
+
 # Exit immediately if this isn't a s390 target.
 if ![istarget s390*-*-*] then {
   return
@@ -24,17 +27,6 @@ if ![istarget s390*-*-*] then {
 # Load support procs.
 load_lib gcc-dg.exp
 
-# Return 1 if z10 instructions work.
-proc check_effective_target_z10_instructions { } {
-    if { ![check_runtime s390_check_z10_instructions [subst {
-	int main (void)
-	{
-	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
-	    return 0;
-	}
-    }] "-march=z10 -mzarch" ] } { return 0 } else { return 1 }
-}
-
 # Return 1 if the the assembler understands .machine and .machinemode.  The
 # target attribute needs that feature to work.
 proc check_effective_target_target_attribute { } {
@@ -78,6 +70,108 @@ proc check_effective_target_vector { } {
     }] "-march=z13 -mzarch" ] } { return 0 } else { return 1 }
 }
 
+# Return 1 if a program using the full instruction set allowed by
+# the compiler option can be executed.
+proc check_effective_target_runnable { } {
+    global torture_current_flags
+    if { ![check_runtime_nocache s390_check_runnable [subst {
+	int main (void)
+	{
+	#if __S390_ARCH_LEVEL__ >= 11
+	    asm ("lcbb %%r2,0(%%r15),0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 10
+	    asm ("risbgn %%r2,%%r2,0,0,0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 9
+	    asm ("sgrk %%r2,%%r2,%%r2" : : );
+	#elif __S390_ARCH_LEVEL__ >= 8
+	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 7
+	    asm ("nilf %%r2,0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 6
+	    asm ("lay %%r2,0(%%r15)" : : );
+	#elif __S390_ARCH_LEVEL__ >= 5
+	    asm ("tam" : : );
+	#endif
+	#ifdef __HTM__
+	  {
+	    unsigned int nd;
+	    asm ("etnd %0" : "=d" (nd));
+	  }
+	#endif
+	#ifdef __S390_VX__
+	    asm ("vzero %%v0" : : );
+	#endif
+	  return 0;
+	}
+    }] "$torture_current_flags -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+
+# Return 1 if -march=... specific instructions are understood by
+# the assembler and can be executed.
+proc check_effective_target_z900_runnable { } {
+    if { ![check_runtime s390_check_z900_runnable [subst {
+	int main (void)
+	{
+	    asm ("tam" : : );
+	    return 0;
+	}
+    }] "-march=z900 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z990_runnable { } {
+    if { ![check_runtime s390_check_z990_runnable [subst {
+	int main (void)
+	{
+	    asm ("lay %%r2,0(%%r15)" : : );
+	    return 0;
+	}
+    }] "-march=z990 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z9_ec_runnable { } {
+    if { ![check_runtime s390_check_z9_ec_runnable [subst {
+	int main (void)
+	{
+	    asm ("nilf %%r2,0" : : );
+	    return 0;
+	}
+    }] "-march=z9-ec -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z10_runnable { } {
+    if { ![check_runtime s390_check_z10_runnable [subst {
+	int main (void)
+	{
+	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
+	    return 0;
+	}
+    }] "-march=z10 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z196_runnable { } {
+    if { ![check_runtime s390_check_z196_runnable [subst {
+	int main (void)
+	{
+	    asm ("sgrk %%r2,%%r2,%%r2" : : );
+	    return 0;
+	}
+    }] "-march=z196 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_zEC12_runnable { } {
+    if { ![check_runtime s390_check_zEC12_runnable [subst {
+	int main (void)
+	{
+	    asm ("risbgn %%r2,%%r2,0,0,0" : : );
+	    return 0;
+	}
+    }] "-march=zEC12 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z13_runnable { } {
+    if { ![check_runtime s390_check_z13_runnable [subst {
+	int main (void)
+	{
+	    asm ("lcbb %%r2,0(%%r15),0" : : );
+	    return 0;
+	}
+    }] "-march=z13 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CFLAGS
 if ![info exists DEFAULT_CFLAGS] then {
@@ -112,11 +206,11 @@ torture-finish
 # Additional md torture tests.
 torture-init
 set MD_TEST_OPTS [list \
-	{-Os -march=z900} {-Os -march=z13} \
-	{-O0 -march=z900} {-O0 -march=z13} \
-	{-O1 -march=z900} {-O1 -march=z13} \
-	{-O2 -march=z900} {-O2 -march=z13} \
-	{-O3 -march=z900} {-O3 -march=z13}]
+	{-Os -march=z900} {-Os -march=z13} {-Os} \
+	{-O0 -march=z900} {-O0 -march=z13} {-O0} \
+	{-O1 -march=z900} {-O1 -march=z13} {-O1} \
+	{-O2 -march=z900} {-O2 -march=z13} {-O2} \
+	{-O3 -march=z900} {-O3 -march=z13} {-O3}]
 set-torture-options $MD_TEST_OPTS
 gcc-dg-runtest [lsort [glob -nocomplain $md_tests]] "" $DEFAULT_CFLAGS
 torture-finish
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 6217272..d9681b1 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -533,6 +533,8 @@ proc gcc-dg-runtest { testcases flags default-extra-flags } {
 	set nshort [file tail [file dirname $test]]/[file tail $test]
 
 	foreach flags_t $option_list {
+	    global torture_current_flags
+	    set torture_current_flags "$flags_t"
 	    verbose "Testing $nshort, $flags $flags_t" 1
 	    dg-test $test "$flags $flags_t" ${default-extra-flags}
 	}
-- 
2.3.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] Run tests only if the machine supports the instruction set.
  2016-12-19 16:51 ` [PATCH v2] " Dominik Vogt
@ 2016-12-19 17:01   ` Jakub Jelinek
  2016-12-20 10:33     ` Dominik Vogt
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Jelinek @ 2016-12-19 17:01 UTC (permalink / raw)
  To: vogt, gcc-patches, Andreas Krebbel

On Mon, Dec 19, 2016 at 05:50:40PM +0100, Dominik Vogt wrote:
> 	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define
> 	__S390_ARCH_LEVEL__.
> gcc/testsuite/ChangeLog-setmem
> 
> 	* gcc.target/s390/md/setmem_long-1.c: Use "runnable".
> 	* gcc.target/s390/md/rXsbg_mode_sXl.c: Likewise.
> 	* gcc.target/s390/md/andc-splitter-1.c: Likewise.
> 	* gcc.target/s390/md/andc-splitter-2.c: Likewise.
> 	* lib/gcc-dg.exp (gcc-dg-runtest): Export torture_current_flags.
> 	* gcc.target/s390/s390.exp: Import torture_current_flags.
> 	(check_effective_target_runnable): New.

Unless you want to add support for all targets in the runnable
effective target, I think it would be better to call it less generically,
s390_runnable or similar.

	Jakub

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] Run tests only if the machine supports the instruction set.
  2016-12-19 17:01   ` Jakub Jelinek
@ 2016-12-20 10:33     ` Dominik Vogt
  2016-12-20 10:38       ` Jakub Jelinek
  0 siblings, 1 reply; 11+ messages in thread
From: Dominik Vogt @ 2016-12-20 10:33 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Andreas Krebbel

On Mon, Dec 19, 2016 at 06:00:21PM +0100, Jakub Jelinek wrote:
> On Mon, Dec 19, 2016 at 05:50:40PM +0100, Dominik Vogt wrote:
> > 	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define
> > 	__S390_ARCH_LEVEL__.
> > gcc/testsuite/ChangeLog-setmem
> > 
> > 	* gcc.target/s390/md/setmem_long-1.c: Use "runnable".
> > 	* gcc.target/s390/md/rXsbg_mode_sXl.c: Likewise.
> > 	* gcc.target/s390/md/andc-splitter-1.c: Likewise.
> > 	* gcc.target/s390/md/andc-splitter-2.c: Likewise.
> > 	* lib/gcc-dg.exp (gcc-dg-runtest): Export torture_current_flags.
> > 	* gcc.target/s390/s390.exp: Import torture_current_flags.
> > 	(check_effective_target_runnable): New.
> 
> Unless you want to add support for all targets in the runnable
> effective target, I think it would be better to call it less generically,
> s390_runnable or similar.

Fair enough.

What do you think about the change in gcc-dg.exp?

We couldn't
decide whether it's a valid way of retrieving the flags needed for
compiling s390_check_runnable or not.  It would be nice to get all
options that are relevant for the test case, including the ones
from "dg-options" (etc.), but that probably requires larger
changes to lib/*.exp.  (The target specific check functions could
be removed then.)

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2] Run tests only if the machine supports the instruction set.
  2016-12-20 10:33     ` Dominik Vogt
@ 2016-12-20 10:38       ` Jakub Jelinek
  2016-12-20 14:16         ` [PATCH v3] " Dominik Vogt
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Jelinek @ 2016-12-20 10:38 UTC (permalink / raw)
  To: vogt, gcc-patches, Andreas Krebbel

On Tue, Dec 20, 2016 at 11:22:47AM +0100, Dominik Vogt wrote:
> On Mon, Dec 19, 2016 at 06:00:21PM +0100, Jakub Jelinek wrote:
> > On Mon, Dec 19, 2016 at 05:50:40PM +0100, Dominik Vogt wrote:
> > > 	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define
> > > 	__S390_ARCH_LEVEL__.
> > > gcc/testsuite/ChangeLog-setmem
> > > 
> > > 	* gcc.target/s390/md/setmem_long-1.c: Use "runnable".
> > > 	* gcc.target/s390/md/rXsbg_mode_sXl.c: Likewise.
> > > 	* gcc.target/s390/md/andc-splitter-1.c: Likewise.
> > > 	* gcc.target/s390/md/andc-splitter-2.c: Likewise.
> > > 	* lib/gcc-dg.exp (gcc-dg-runtest): Export torture_current_flags.
> > > 	* gcc.target/s390/s390.exp: Import torture_current_flags.
> > > 	(check_effective_target_runnable): New.
> > 
> > Unless you want to add support for all targets in the runnable
> > effective target, I think it would be better to call it less generically,
> > s390_runnable or similar.
> 
> Fair enough.
> 
> What do you think about the change in gcc-dg.exp?
> 
> We couldn't
> decide whether it's a valid way of retrieving the flags needed for
> compiling s390_check_runnable or not.  It would be nice to get all
> options that are relevant for the test case, including the ones
> from "dg-options" (etc.), but that probably requires larger
> changes to lib/*.exp.  (The target specific check functions could
> be removed then.)

I'm not a testsuite maintainer nor very good in tcl, so I think you want a
testsuite maintainer to ack it in any case.
But, I'd say you want something that will not be terribly expensive.
If you have an effective target that happens to get flags from the
current test, then that is necessarily non-cacheable, which would mean
in addition to compiling every test you also compile another proglet for it.
I think your current patch does that too, there is no caching, so it would
be desirable to cache the results; you should invalidate those caches when
torture_current_flags change.  See e.g. et_cache uses in
target-supports.exp.  You want to remember torture_current_flags for which
you've computed the s390_runnable et and if it changes, reset the cache.
The other *_runnable flags can be probably just normally cached (and you do,
by using check_runtime rather than check_runtime_nocache).

	Jakub

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] Run tests only if the machine supports the instruction set.
  2016-12-20 10:38       ` Jakub Jelinek
@ 2016-12-20 14:16         ` Dominik Vogt
  2016-12-20 20:14           ` Mike Stump
  0 siblings, 1 reply; 11+ messages in thread
From: Dominik Vogt @ 2016-12-20 14:16 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 3028 bytes --]

On Tue, Dec 20, 2016 at 11:32:58AM +0100, Jakub Jelinek wrote:
> On Tue, Dec 20, 2016 at 11:22:47AM +0100, Dominik Vogt wrote:
> > On Mon, Dec 19, 2016 at 06:00:21PM +0100, Jakub Jelinek wrote:
> > > On Mon, Dec 19, 2016 at 05:50:40PM +0100, Dominik Vogt wrote:
> > > > 	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define
> > > > 	__S390_ARCH_LEVEL__.
> > > > gcc/testsuite/ChangeLog-setmem
> > > > 
> > > > 	* gcc.target/s390/md/setmem_long-1.c: Use "runnable".
> > > > 	* gcc.target/s390/md/rXsbg_mode_sXl.c: Likewise.
> > > > 	* gcc.target/s390/md/andc-splitter-1.c: Likewise.
> > > > 	* gcc.target/s390/md/andc-splitter-2.c: Likewise.
> > > > 	* lib/gcc-dg.exp (gcc-dg-runtest): Export torture_current_flags.
> > > > 	* gcc.target/s390/s390.exp: Import torture_current_flags.
> > > > 	(check_effective_target_runnable): New.
> > > 
> > > Unless you want to add support for all targets in the runnable
> > > effective target, I think it would be better to call it less generically,
> > > s390_runnable or similar.

Done.

> > What do you think about the change in gcc-dg.exp?
> > 
> > We couldn't
> > decide whether it's a valid way of retrieving the flags needed for
> > compiling s390_check_runnable or not.  It would be nice to get all
> > options that are relevant for the test case, including the ones
> > from "dg-options" (etc.), but that probably requires larger
> > changes to lib/*.exp.  (The target specific check functions could
> > be removed then.)
> 
> I'm not a testsuite maintainer nor very good in tcl, so I think you want a
> testsuite maintainer to ack it in any case.
> But, I'd say you want something that will not be terribly expensive.
> If you have an effective target that happens to get flags from the
> current test, then that is necessarily non-cacheable, which would mean
> in addition to compiling every test you also compile another proglet for it.
> I think your current patch does that too, there is no caching, so it would
> be desirable to cache the results; you should invalidate those caches when
> torture_current_flags change.  See e.g. et_cache uses in
> target-supports.exp.  You want to remember torture_current_flags for which
> you've computed the s390_runnable et and if it changes, reset the cache.
> The other *_runnable flags can be probably just normally cached (and you do,
> by using check_runtime rather than check_runtime_nocache).

Right, it gets called even more often than one would think, and
even with empty torture_current_options.  The attached new patch
(v3) removes -Ox options and superflous whitespace and caches that
between calls if it's not empty.  There's another, permanent cache
for calls without any flags.  With proper ordering of the torture
options, the test program is built only a couple of times.

v3:

  * Cache test results.
  * Reorder torture tests for better caching.
  * Add ".machinemode zarch" to assembly file because the $flags
    are overridden by the board options.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-v3-ChangeLog --]
[-- Type: text/plain, Size: 959 bytes --]

gcc/ChangeLog-archlevel

	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define
	__S390_ARCH_LEVEL__.
gcc/testsuite/ChangeLog-setmem

	* gcc.target/s390/md/setmem_long-1.c: Use "s390_runnable".
	* gcc.target/s390/md/rXsbg_mode_sXl.c: Likewise.
	* gcc.target/s390/md/andc-splitter-1.c: Likewise.
	* gcc.target/s390/md/andc-splitter-2.c: Likewise.
	* lib/gcc-dg.exp (gcc-dg-runtest): Export torture_current_flags.
	* gcc.target/s390/s390.exp: Import torture_current_flags.
	(check_effective_target_s390_runnable): New.
	(check_effective_target_z900_runnable): New.
	(check_effective_target_z990_runnable): New.
	(check_effective_target_z9_ec_runnable): New.
	(check_effective_target_z10_runnable): New.
	(check_effective_target_z196_runnable): New.
	(check_effective_target_zEC12_runnable): New.
	(check_effective_target_z13_runnable): New.
	(check_effective_target_z10_instructions): Removed.
	(MD_TEST_OPTS): Add optimization level without -march=.

[-- Attachment #3: 0001-v3-S-390-Run-md-tests-only-if-the-machine-supports-the-.patch --]
[-- Type: text/plain, Size: 15329 bytes --]

From 4bd55b91b0487590bc9c9bde60664e5d94d2dc08 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Tue, 13 Dec 2016 10:21:08 +0100
Subject: [PATCH] S/390: Run md tests only if the machine supports the
 instruction set.

---
 gcc/config/s390/s390-c.c                           |  17 +++
 gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c |  19 +--
 gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c |  19 +--
 gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c  |   4 +-
 gcc/testsuite/gcc.target/s390/md/setmem_long-1.c   |   7 +-
 gcc/testsuite/gcc.target/s390/s390.exp             | 170 ++++++++++++++++++---
 gcc/testsuite/lib/gcc-dg.exp                       |   2 +
 7 files changed, 198 insertions(+), 40 deletions(-)

diff --git a/gcc/config/s390/s390-c.c b/gcc/config/s390/s390-c.c
index fcf7477..e841365 100644
--- a/gcc/config/s390/s390-c.c
+++ b/gcc/config/s390/s390-c.c
@@ -320,6 +320,8 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
 {
   s390_def_or_undef_macro (pfile, MASK_OPT_HTM, old_opts, opts,
 			   "__HTM__", "__HTM__");
+  s390_def_or_undef_macro (pfile, MASK_OPT_VX, old_opts, opts,
+			   "__S390_VX__", "__S390_VX__");
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
 			   "__VEC__=10301", "__VEC__");
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
@@ -328,6 +330,21 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
 			   "__bool=__attribute__((s390_vector_bool)) unsigned",
 			   "__bool");
+  {
+    char macro_def[64];
+    int arch_level;
+    gcc_assert (s390_arch != PROCESSOR_NATIVE);
+    arch_level = (int)s390_arch + 3;
+    if (s390_arch >= PROCESSOR_2094_Z9_EC)
+      /* Z9_EC has the same level as Z9_109.  */
+      arch_level--;
+    /* Review when a new arch is added and increase the value.  */
+    char dummy[23 - 2 * PROCESSOR_max] __attribute__((unused));
+    sprintf (macro_def, "__S390_ARCH_LEVEL__=%d", arch_level);
+    cpp_undef (pfile, "__S390_ARCH_LEVEL__");
+    cpp_define (pfile, macro_def);
+  }
+
   if (!flag_iso)
     {
       s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
index ed78921..c7a67d6 100644
--- a/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run { target { lp64 } } } */
+/* { dg-do compile { target { lp64 } } } */
 /* { dg-options "-mzarch -save-temps -dP" } */
+/* { dg-do run { target { lp64 && s390_runnable } } } */
 /* Skip test if -O0 is present on the command line:
 
     { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
@@ -13,26 +14,26 @@
 __attribute__ ((noinline))
 unsigned long andc_vv(unsigned long a, unsigned long b)
 { return ~b & a; }
-/* { dg-final { scan-assembler ":15 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":15 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_pv(unsigned long *a, unsigned long b)
 { return ~b & *a; }
-/* { dg-final { scan-assembler ":21 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":21 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_vp(unsigned long a, unsigned long *b)
 { return ~*b & a; }
-/* { dg-final { scan-assembler ":27 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":27 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_pp(unsigned long *a, unsigned long *b)
 { return ~*b & *a; }
-/* { dg-final { scan-assembler ":33 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":33 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*xordi3\}" } } */
 
 /* { dg-final { scan-assembler-times "\tngr\?k\?\t" 4 } } */
 /* { dg-final { scan-assembler-times "\txgr\?\t" 4 } } */
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
index d88da4d..fd98b93 100644
--- a/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run } */
+/* { dg-do compile } */
 /* { dg-options "-save-temps -dP" } */
+/* { dg-do run { target { s390_runnable } } } */
 /* Skip test if -O0 is present on the command line:
 
     { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
@@ -13,26 +14,26 @@
 __attribute__ ((noinline))
 unsigned int andc_vv(unsigned int a, unsigned int b)
 { return ~b & a; }
-/* { dg-final { scan-assembler ":15 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":15 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_pv(unsigned int *a, unsigned int b)
 { return ~b & *a; }
-/* { dg-final { scan-assembler ":21 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":21 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_vp(unsigned int a, unsigned int *b)
 { return ~*b & a; }
-/* { dg-final { scan-assembler ":27 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":27 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_pp(unsigned int *a, unsigned int *b)
 { return ~*b & *a; }
-/* { dg-final { scan-assembler ":33 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":33 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*xorsi3\}" } } */
 
 /* { dg-final { scan-assembler-times "\tnr\?k\?\t" 4 } } */
 /* { dg-final { scan-assembler-times "\txr\?k\?\t" 4 } } */
diff --git a/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c b/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
index ad442da..f6d5842 100644
--- a/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
+++ b/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
@@ -7,8 +7,8 @@
    always wins, even if the condition is false.  If this test is run on hardware
    older than z10 with a buggy dejagnu release, the execution part will fail.
 
-    { dg-do assemble { target { ! z10_instructions } } }
-    { dg-do run { target { z10_instructions } } }
+    { dg-do assemble }
+    { dg-do run { target { s390_runnable } } }
 
    Skip test if -O0, -march=z900, -march=z9-109 or -march=z9-ec is present on
    the command line:
diff --git a/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c b/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
index bd0c594..c081352 100644
--- a/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
+++ b/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run } */
+/* { dg-do compile } */
 /* { dg-options "-mmvcle -dP -save-temps" } */
+/* { dg-do run { target { s390_runnable } } } */
 
 __attribute__ ((noinline))
 void test(char *p, char c, int len)
@@ -16,8 +17,8 @@ void test2(char *p, int c, int len)
 }
 
 /* Check that the right patterns are used.  */
-/* { dg-final { scan-assembler-times {c"?:9 .*{[*]setmem_long_?3?1?z?}} 1 } } */
-/* { dg-final { scan-assembler-times {c"?:15 .*{[*]setmem_long_and_?3?1?z?}} 1 { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-times {c"?:10 .*{[*]setmem_long_?3?1?z?}} 1 } } */
+/* { dg-final { scan-assembler-times {c"?:16 .*{[*]setmem_long_and_?3?1?z?}} 1 { xfail *-*-* } } } */
 
 #define LEN 500
 char buf[LEN + 2];
diff --git a/gcc/testsuite/gcc.target/s390/s390.exp b/gcc/testsuite/gcc.target/s390/s390.exp
index 450dcaf..229e717 100644
--- a/gcc/testsuite/gcc.target/s390/s390.exp
+++ b/gcc/testsuite/gcc.target/s390/s390.exp
@@ -16,6 +16,9 @@
 
 # GCC testsuite that uses the `dg.exp' driver.
 
+global torture_current_flags
+set torture_current_flags ""
+
 # Exit immediately if this isn't a s390 target.
 if ![istarget s390*-*-*] then {
   return
@@ -24,17 +27,6 @@ if ![istarget s390*-*-*] then {
 # Load support procs.
 load_lib gcc-dg.exp
 
-# Return 1 if z10 instructions work.
-proc check_effective_target_z10_instructions { } {
-    if { ![check_runtime s390_check_z10_instructions [subst {
-	int main (void)
-	{
-	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
-	    return 0;
-	}
-    }] "-march=z10 -mzarch" ] } { return 0 } else { return 1 }
-}
-
 # Return 1 if the the assembler understands .machine and .machinemode.  The
 # target attribute needs that feature to work.
 proc check_effective_target_target_attribute { } {
@@ -78,6 +70,138 @@ proc check_effective_target_vector { } {
     }] "-march=z13 -mzarch" ] } { return 0 } else { return 1 }
 }
 
+global s390_cached_flags
+set s390_cached_flags ""
+global s390_cached_value
+set s390_cached_value ""
+global s390_cached_value_noflags
+set s390_cached_value_noflags ""
+
+# Return 1 if a program using the full instruction set allowed by
+# the compiler option can be executed.
+proc check_effective_target_s390_runnable { } {
+    global torture_current_flags
+    global s390_cached_flags
+    global s390_cached_value
+    global s390_cached_value_noflags
+
+    # Remove -Ox options and whitespace.
+    set flags [regsub -all {[-]O[0-9s]} "$torture_current_flags" ""]
+    set flags [regsub -all {[ \\t\\n]+} "$flags" " "]
+    set flags [regsub -all {(^ )|( $)} "$flags" ""]
+    if { "$s390_cached_flags" != "" && "$flags" == "$s390_cached_flags" } {
+      return $s390_cached_value
+    }
+    # Extra cache for (frequent) calls with empty torture_current_flags.
+    if { "$flags" == "" && $s390_cached_value_noflags != "" } {
+      return $s390_cached_value_noflags
+    }
+    if { ![check_runtime_nocache s390_check_runnable [subst {
+	int main (void)
+	{
+	    asm (".machinemode zarch" : : );
+	#if __S390_ARCH_LEVEL__ >= 11
+	    asm ("lcbb %%r2,0(%%r15),0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 10
+	    asm ("risbgn %%r2,%%r2,0,0,0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 9
+	    asm ("sgrk %%r2,%%r2,%%r2" : : );
+	#elif __S390_ARCH_LEVEL__ >= 8
+	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 7
+	    asm ("nilf %%r2,0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 6
+	    asm ("lay %%r2,0(%%r15)" : : );
+	#elif __S390_ARCH_LEVEL__ >= 5
+	    asm ("tam" : : );
+	#endif
+	#ifdef __HTM__
+	  {
+	    unsigned int nd;
+	    asm ("etnd %0" : "=d" (nd));
+	  }
+	#endif
+	#ifdef __S390_VX__
+	    asm ("vzero %%v0" : : );
+	#endif
+	  return 0;
+	}
+    }] "$flags" ] } { set result 0 } else { set result 1 }
+    if { "$flags" == "" } {
+      set s390_cached_value_noflags "$result"
+    } else {
+      set s390_cached_flags "$flags"
+      set s390_cached_value "$result"
+    }
+    return $result
+}
+
+# Return 1 if -march=... specific instructions are understood by
+# the assembler and can be executed.
+proc check_effective_target_z900_runnable { } {
+    if { ![check_runtime s390_check_z900_runnable [subst {
+	int main (void)
+	{
+	    asm ("tam" : : );
+	    return 0;
+	}
+    }] "-march=z900 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z990_runnable { } {
+    if { ![check_runtime s390_check_z990_runnable [subst {
+	int main (void)
+	{
+	    asm ("lay %%r2,0(%%r15)" : : );
+	    return 0;
+	}
+    }] "-march=z990 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z9_ec_runnable { } {
+    if { ![check_runtime s390_check_z9_ec_runnable [subst {
+	int main (void)
+	{
+	    asm ("nilf %%r2,0" : : );
+	    return 0;
+	}
+    }] "-march=z9-ec -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z10_runnable { } {
+    if { ![check_runtime s390_check_z10_runnable [subst {
+	int main (void)
+	{
+	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
+	    return 0;
+	}
+    }] "-march=z10 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z196_runnable { } {
+    if { ![check_runtime s390_check_z196_runnable [subst {
+	int main (void)
+	{
+	    asm ("sgrk %%r2,%%r2,%%r2" : : );
+	    return 0;
+	}
+    }] "-march=z196 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_zEC12_runnable { } {
+    if { ![check_runtime s390_check_zEC12_runnable [subst {
+	int main (void)
+	{
+	    asm ("risbgn %%r2,%%r2,0,0,0" : : );
+	    return 0;
+	}
+    }] "-march=zEC12 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_z13_runnable { } {
+    if { ![check_runtime s390_check_z13_runnable [subst {
+	int main (void)
+	{
+	    asm ("lcbb %%r2,0(%%r15),0" : : );
+	    return 0;
+	}
+    }] "-march=z13 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CFLAGS
 if ![info exists DEFAULT_CFLAGS] then {
@@ -110,15 +234,27 @@ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/hotpatch-\[0-9\]*.c]] \
 torture-finish
 
 # Additional md torture tests.
+# (Note: Split into a separate torture test for each -march= option to improve
+# cacheability.)
+torture-init
+set MD_TEST_OPTS [list \
+	{-Os} {-Os -march=z900} \
+	{-O0} {-O0 -march=z900} \
+	{-O1} {-O1 -march=z900} \
+	{-O2} {-O2 -march=z900} \
+	{-O3} {-O3 -march=z900} ]
+set-torture-options $MD_TEST_OPTS
+gcc-dg-runtest [lsort [glob -nocomplain $md_tests]] "" "$DEFAULT_CFLAGS"
+torture-finish
 torture-init
 set MD_TEST_OPTS [list \
-	{-Os -march=z900} {-Os -march=z13} \
-	{-O0 -march=z900} {-O0 -march=z13} \
-	{-O1 -march=z900} {-O1 -march=z13} \
-	{-O2 -march=z900} {-O2 -march=z13} \
-	{-O3 -march=z900} {-O3 -march=z13}]
+	{-Os -march=z13} \
+	{-O0 -march=z13} \
+	{-O1 -march=z13} \
+	{-O2 -march=z13} \
+	{-O3 -march=z13} ]
 set-torture-options $MD_TEST_OPTS
-gcc-dg-runtest [lsort [glob -nocomplain $md_tests]] "" $DEFAULT_CFLAGS
+gcc-dg-runtest [lsort [glob -nocomplain $md_tests]] "" "$DEFAULT_CFLAGS"
 torture-finish
 
 # All done.
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 6217272..d9681b1 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -533,6 +533,8 @@ proc gcc-dg-runtest { testcases flags default-extra-flags } {
 	set nshort [file tail [file dirname $test]]/[file tail $test]
 
 	foreach flags_t $option_list {
+	    global torture_current_flags
+	    set torture_current_flags "$flags_t"
 	    verbose "Testing $nshort, $flags $flags_t" 1
 	    dg-test $test "$flags $flags_t" ${default-extra-flags}
 	}
-- 
2.3.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] Run tests only if the machine supports the instruction set.
  2016-12-20 14:16         ` [PATCH v3] " Dominik Vogt
@ 2016-12-20 20:14           ` Mike Stump
  2016-12-20 21:29             ` [PATCH v4] " Dominik Vogt
  0 siblings, 1 reply; 11+ messages in thread
From: Mike Stump @ 2016-12-20 20:14 UTC (permalink / raw)
  To: vogt; +Cc: Jakub Jelinek, gcc-patches, Andreas Krebbel

On Dec 20, 2016, at 6:10 AM, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> Right, it gets called even more often than one would think, and
> even with empty torture_current_options.  The attached new patch
> (v3) removes -Ox options and superflous whitespace and caches that
> between calls if it's not empty.  There's another, permanent cache
> for calls without any flags.  With proper ordering of the torture
> options, the test program is built only a couple of times.

Seems fine to me, but most other cases use the postfix _hw.  Any reason not use use _hw (and not _runable) on these?  If not, could you please use _hw instead.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4] Run tests only if the machine supports the instruction set.
  2016-12-20 20:14           ` Mike Stump
@ 2016-12-20 21:29             ` Dominik Vogt
  2016-12-20 23:59               ` Jakub Jelinek
  2016-12-22 15:18               ` Andreas Krebbel
  0 siblings, 2 replies; 11+ messages in thread
From: Dominik Vogt @ 2016-12-20 21:29 UTC (permalink / raw)
  To: Mike Stump; +Cc: Jakub Jelinek, gcc-patches, Andreas Krebbel

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

On Tue, Dec 20, 2016 at 11:57:52AM -0800, Mike Stump wrote:
> On Dec 20, 2016, at 6:10 AM, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> > Right, it gets called even more often than one would think, and
> > even with empty torture_current_options.  The attached new patch
> > (v3) removes -Ox options and superflous whitespace and caches that
> > between calls if it's not empty.  There's another, permanent cache
> > for calls without any flags.  With proper ordering of the torture
> > options, the test program is built only a couple of times.
> 
> Seems fine to me, but most other cases use the postfix _hw.  Any
> reason not use use _hw (and not _runable) on these?  If not,
> could you please use _hw instead.

No specific reason other than lack of imagination.  "s390_hw" is a
bit too generic in my eyes -> the new names are:

v4:

  * Renamed "s390_runnable" to "s390_useable_hw".
  * Renamed "z900_runnable" to "s390_z900_hw",
    Renamed "z10_runnable" to "s390_z10_hw",
    etc.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0001-v4-ChangeLog --]
[-- Type: text/plain, Size: 1002 bytes --]

gcc/ChangeLog-archlevel

	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define
	__S390_ARCH_LEVEL__.
gcc/testsuite/ChangeLog-setmem

	* gcc.target/s390/md/setmem_long-1.c: Use "s390_useable_hw".
	* gcc.target/s390/md/rXsbg_mode_sXl.c: Likewise.
	* gcc.target/s390/md/andc-splitter-1.c: Likewise.
	* gcc.target/s390/md/andc-splitter-2.c: Likewise.
	* lib/gcc-dg.exp (gcc-dg-runtest): Export torture_current_flags.
	* gcc.target/s390/s390.exp: Import torture_current_flags.
	(check_effective_target_s390_useable_hw): New.
	(check_effective_target_s390_z900_hw): New.
	(check_effective_target_s390_z990_hw): New.
	(check_effective_target_s390_z9_ec_hw): New.
	(check_effective_target_s390_z10_hw): New.
	(check_effective_target_s390_z196_hw): New.
	(check_effective_target_s390_zEC12_hw): New.
	(check_effective_target_s390_z13_hw): New.
	(check_effective_target_z10_instructions): Removed.
	(torture tests): Add optimization level without -march=.
	Reorder torture tests for good cache usage.

[-- Attachment #3: 0001-v4-S-390-Run-md-tests-only-if-the-machine-supports-the-.patch --]
[-- Type: text/plain, Size: 15327 bytes --]

From 8ae8d6f48fbede4188a7e02c835fcf9d0b535da7 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Tue, 13 Dec 2016 10:21:08 +0100
Subject: [PATCH] S/390: Run md tests only if the machine supports the
 instruction set.

---
 gcc/config/s390/s390-c.c                           |  17 +++
 gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c |  19 +--
 gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c |  19 +--
 gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c  |   4 +-
 gcc/testsuite/gcc.target/s390/md/setmem_long-1.c   |   7 +-
 gcc/testsuite/gcc.target/s390/s390.exp             | 170 ++++++++++++++++++---
 gcc/testsuite/lib/gcc-dg.exp                       |   2 +
 7 files changed, 198 insertions(+), 40 deletions(-)

diff --git a/gcc/config/s390/s390-c.c b/gcc/config/s390/s390-c.c
index fcf7477..e841365 100644
--- a/gcc/config/s390/s390-c.c
+++ b/gcc/config/s390/s390-c.c
@@ -320,6 +320,8 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
 {
   s390_def_or_undef_macro (pfile, MASK_OPT_HTM, old_opts, opts,
 			   "__HTM__", "__HTM__");
+  s390_def_or_undef_macro (pfile, MASK_OPT_VX, old_opts, opts,
+			   "__S390_VX__", "__S390_VX__");
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
 			   "__VEC__=10301", "__VEC__");
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
@@ -328,6 +330,21 @@ s390_cpu_cpp_builtins_internal (cpp_reader *pfile,
   s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
 			   "__bool=__attribute__((s390_vector_bool)) unsigned",
 			   "__bool");
+  {
+    char macro_def[64];
+    int arch_level;
+    gcc_assert (s390_arch != PROCESSOR_NATIVE);
+    arch_level = (int)s390_arch + 3;
+    if (s390_arch >= PROCESSOR_2094_Z9_EC)
+      /* Z9_EC has the same level as Z9_109.  */
+      arch_level--;
+    /* Review when a new arch is added and increase the value.  */
+    char dummy[23 - 2 * PROCESSOR_max] __attribute__((unused));
+    sprintf (macro_def, "__S390_ARCH_LEVEL__=%d", arch_level);
+    cpp_undef (pfile, "__S390_ARCH_LEVEL__");
+    cpp_define (pfile, macro_def);
+  }
+
   if (!flag_iso)
     {
       s390_def_or_undef_macro (pfile, MASK_ZVECTOR, old_opts, opts,
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
index ed78921..3f0677c 100644
--- a/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-1.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run { target { lp64 } } } */
+/* { dg-do compile { target { lp64 } } } */
 /* { dg-options "-mzarch -save-temps -dP" } */
+/* { dg-do run { target { lp64 && s390_useable_hw } } } */
 /* Skip test if -O0 is present on the command line:
 
     { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
@@ -13,26 +14,26 @@
 __attribute__ ((noinline))
 unsigned long andc_vv(unsigned long a, unsigned long b)
 { return ~b & a; }
-/* { dg-final { scan-assembler ":15 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":15 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_pv(unsigned long *a, unsigned long b)
 { return ~b & *a; }
-/* { dg-final { scan-assembler ":21 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":21 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_vp(unsigned long a, unsigned long *b)
 { return ~*b & a; }
-/* { dg-final { scan-assembler ":27 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":27 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*xordi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned long andc_pp(unsigned long *a, unsigned long *b)
 { return ~*b & *a; }
-/* { dg-final { scan-assembler ":33 .\* \{\\*anddi3\}" } } */
-/* { dg-final { scan-assembler ":33 .\* \{\\*xordi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*anddi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*xordi3\}" } } */
 
 /* { dg-final { scan-assembler-times "\tngr\?k\?\t" 4 } } */
 /* { dg-final { scan-assembler-times "\txgr\?\t" 4 } } */
diff --git a/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
index d88da4d..89c8ea2 100644
--- a/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
+++ b/gcc/testsuite/gcc.target/s390/md/andc-splitter-2.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run } */
+/* { dg-do compile } */
 /* { dg-options "-save-temps -dP" } */
+/* { dg-do run { target { s390_useable_hw } } } */
 /* Skip test if -O0 is present on the command line:
 
     { dg-skip-if "" { *-*-* } { "-O0" } { "" } }
@@ -13,26 +14,26 @@
 __attribute__ ((noinline))
 unsigned int andc_vv(unsigned int a, unsigned int b)
 { return ~b & a; }
-/* { dg-final { scan-assembler ":15 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":15 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":16 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_pv(unsigned int *a, unsigned int b)
 { return ~b & *a; }
-/* { dg-final { scan-assembler ":21 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":21 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":22 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_vp(unsigned int a, unsigned int *b)
 { return ~*b & a; }
-/* { dg-final { scan-assembler ":27 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":27 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":28 .\* \{\\*xorsi3\}" } } */
 
 __attribute__ ((noinline))
 unsigned int andc_pp(unsigned int *a, unsigned int *b)
 { return ~*b & *a; }
-/* { dg-final { scan-assembler ":33 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
-/* { dg-final { scan-assembler ":33 .\* \{\\*xorsi3\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*andsi3_\(esa\|zarch\)\}" } } */
+/* { dg-final { scan-assembler ":34 .\* \{\\*xorsi3\}" } } */
 
 /* { dg-final { scan-assembler-times "\tnr\?k\?\t" 4 } } */
 /* { dg-final { scan-assembler-times "\txr\?k\?\t" 4 } } */
diff --git a/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c b/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
index ad442da..824ce39 100644
--- a/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
+++ b/gcc/testsuite/gcc.target/s390/md/rXsbg_mode_sXl.c
@@ -7,8 +7,8 @@
    always wins, even if the condition is false.  If this test is run on hardware
    older than z10 with a buggy dejagnu release, the execution part will fail.
 
-    { dg-do assemble { target { ! z10_instructions } } }
-    { dg-do run { target { z10_instructions } } }
+    { dg-do assemble }
+    { dg-do run { target { s390_useable_hw } } }
 
    Skip test if -O0, -march=z900, -march=z9-109 or -march=z9-ec is present on
    the command line:
diff --git a/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c b/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
index bd0c594..5fc54e2 100644
--- a/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
+++ b/gcc/testsuite/gcc.target/s390/md/setmem_long-1.c
@@ -1,7 +1,8 @@
 /* Machine description pattern tests.  */
 
-/* { dg-do run } */
+/* { dg-do compile } */
 /* { dg-options "-mmvcle -dP -save-temps" } */
+/* { dg-do run { target { s390_useable_hw } } } */
 
 __attribute__ ((noinline))
 void test(char *p, char c, int len)
@@ -16,8 +17,8 @@ void test2(char *p, int c, int len)
 }
 
 /* Check that the right patterns are used.  */
-/* { dg-final { scan-assembler-times {c"?:9 .*{[*]setmem_long_?3?1?z?}} 1 } } */
-/* { dg-final { scan-assembler-times {c"?:15 .*{[*]setmem_long_and_?3?1?z?}} 1 { xfail *-*-* } } } */
+/* { dg-final { scan-assembler-times {c"?:10 .*{[*]setmem_long_?3?1?z?}} 1 } } */
+/* { dg-final { scan-assembler-times {c"?:16 .*{[*]setmem_long_and_?3?1?z?}} 1 { xfail *-*-* } } } */
 
 #define LEN 500
 char buf[LEN + 2];
diff --git a/gcc/testsuite/gcc.target/s390/s390.exp b/gcc/testsuite/gcc.target/s390/s390.exp
index 450dcaf..d826dba 100644
--- a/gcc/testsuite/gcc.target/s390/s390.exp
+++ b/gcc/testsuite/gcc.target/s390/s390.exp
@@ -16,6 +16,9 @@
 
 # GCC testsuite that uses the `dg.exp' driver.
 
+global torture_current_flags
+set torture_current_flags ""
+
 # Exit immediately if this isn't a s390 target.
 if ![istarget s390*-*-*] then {
   return
@@ -24,17 +27,6 @@ if ![istarget s390*-*-*] then {
 # Load support procs.
 load_lib gcc-dg.exp
 
-# Return 1 if z10 instructions work.
-proc check_effective_target_z10_instructions { } {
-    if { ![check_runtime s390_check_z10_instructions [subst {
-	int main (void)
-	{
-	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
-	    return 0;
-	}
-    }] "-march=z10 -mzarch" ] } { return 0 } else { return 1 }
-}
-
 # Return 1 if the the assembler understands .machine and .machinemode.  The
 # target attribute needs that feature to work.
 proc check_effective_target_target_attribute { } {
@@ -78,6 +70,138 @@ proc check_effective_target_vector { } {
     }] "-march=z13 -mzarch" ] } { return 0 } else { return 1 }
 }
 
+global s390_cached_flags
+set s390_cached_flags ""
+global s390_cached_value
+set s390_cached_value ""
+global s390_cached_value_noflags
+set s390_cached_value_noflags ""
+
+# Return 1 if a program using the full instruction set allowed by
+# the compiler option can be executed.
+proc check_effective_target_s390_useable_hw { } {
+    global torture_current_flags
+    global s390_cached_flags
+    global s390_cached_value
+    global s390_cached_value_noflags
+
+    # Remove -Ox options and whitespace.
+    set flags [regsub -all {[-]O[0-9s]} "$torture_current_flags" ""]
+    set flags [regsub -all {[ \\t\\n]+} "$flags" " "]
+    set flags [regsub -all {(^ )|( $)} "$flags" ""]
+    if { "$s390_cached_flags" != "" && "$flags" == "$s390_cached_flags" } {
+      return $s390_cached_value
+    }
+    # Extra cache for (frequent) calls with empty torture_current_flags.
+    if { "$flags" == "" && $s390_cached_value_noflags != "" } {
+      return $s390_cached_value_noflags
+    }
+    if { ![check_runtime_nocache s390_check_useable_hw [subst {
+	int main (void)
+	{
+	    asm (".machinemode zarch" : : );
+	#if __S390_ARCH_LEVEL__ >= 11
+	    asm ("lcbb %%r2,0(%%r15),0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 10
+	    asm ("risbgn %%r2,%%r2,0,0,0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 9
+	    asm ("sgrk %%r2,%%r2,%%r2" : : );
+	#elif __S390_ARCH_LEVEL__ >= 8
+	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 7
+	    asm ("nilf %%r2,0" : : );
+	#elif __S390_ARCH_LEVEL__ >= 6
+	    asm ("lay %%r2,0(%%r15)" : : );
+	#elif __S390_ARCH_LEVEL__ >= 5
+	    asm ("tam" : : );
+	#endif
+	#ifdef __HTM__
+	  {
+	    unsigned int nd;
+	    asm ("etnd %0" : "=d" (nd));
+	  }
+	#endif
+	#ifdef __S390_VX__
+	    asm ("vzero %%v0" : : );
+	#endif
+	  return 0;
+	}
+    }] "$flags" ] } { set result 0 } else { set result 1 }
+    if { "$flags" == "" } {
+      set s390_cached_value_noflags "$result"
+    } else {
+      set s390_cached_flags "$flags"
+      set s390_cached_value "$result"
+    }
+    return $result
+}
+
+# Return 1 if -march=... specific instructions are understood by
+# the assembler and can be executed.
+proc check_effective_target_s390_z900_hw { } {
+    if { ![check_runtime s390_check_s390_z900_hw [subst {
+	int main (void)
+	{
+	    asm ("tam" : : );
+	    return 0;
+	}
+    }] "-march=z900 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_s390_z990_hw { } {
+    if { ![check_runtime s390_check_s390_z990_hw [subst {
+	int main (void)
+	{
+	    asm ("lay %%r2,0(%%r15)" : : );
+	    return 0;
+	}
+    }] "-march=z990 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_s390_z9_ec_hw { } {
+    if { ![check_runtime s390_check_s390_z9_ec_hw [subst {
+	int main (void)
+	{
+	    asm ("nilf %%r2,0" : : );
+	    return 0;
+	}
+    }] "-march=z9-ec -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_s390_z10_hw { } {
+    if { ![check_runtime s390_check_s390_z10_hw [subst {
+	int main (void)
+	{
+	    asm ("rosbg %%r2,%%r2,0,0,0" : : );
+	    return 0;
+	}
+    }] "-march=z10 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_s390_z196_hw { } {
+    if { ![check_runtime s390_check_s390_z196_hw [subst {
+	int main (void)
+	{
+	    asm ("sgrk %%r2,%%r2,%%r2" : : );
+	    return 0;
+	}
+    }] "-march=z196 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_s390_zEC12_hw { } {
+    if { ![check_runtime s390_check_s390_zEC12_hw [subst {
+	int main (void)
+	{
+	    asm ("risbgn %%r2,%%r2,0,0,0" : : );
+	    return 0;
+	}
+    }] "-march=zEC12 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+proc check_effective_target_s390_z13_hw { } {
+    if { ![check_runtime s390_check_s390_z13_hw [subst {
+	int main (void)
+	{
+	    asm ("lcbb %%r2,0(%%r15),0" : : );
+	    return 0;
+	}
+    }] "-march=z13 -m64 -mzarch" ] } { return 0 } else { return 1 }
+}
+
 # If a testcase doesn't have special options, use these.
 global DEFAULT_CFLAGS
 if ![info exists DEFAULT_CFLAGS] then {
@@ -110,15 +234,27 @@ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/hotpatch-\[0-9\]*.c]] \
 torture-finish
 
 # Additional md torture tests.
+# (Note: Split into a separate torture test for each -march= option to improve
+# cacheability.)
+torture-init
+set MD_TEST_OPTS [list \
+	{-Os} {-Os -march=z900} \
+	{-O0} {-O0 -march=z900} \
+	{-O1} {-O1 -march=z900} \
+	{-O2} {-O2 -march=z900} \
+	{-O3} {-O3 -march=z900} ]
+set-torture-options $MD_TEST_OPTS
+gcc-dg-runtest [lsort [glob -nocomplain $md_tests]] "" "$DEFAULT_CFLAGS"
+torture-finish
 torture-init
 set MD_TEST_OPTS [list \
-	{-Os -march=z900} {-Os -march=z13} \
-	{-O0 -march=z900} {-O0 -march=z13} \
-	{-O1 -march=z900} {-O1 -march=z13} \
-	{-O2 -march=z900} {-O2 -march=z13} \
-	{-O3 -march=z900} {-O3 -march=z13}]
+	{-Os -march=z13} \
+	{-O0 -march=z13} \
+	{-O1 -march=z13} \
+	{-O2 -march=z13} \
+	{-O3 -march=z13} ]
 set-torture-options $MD_TEST_OPTS
-gcc-dg-runtest [lsort [glob -nocomplain $md_tests]] "" $DEFAULT_CFLAGS
+gcc-dg-runtest [lsort [glob -nocomplain $md_tests]] "" "$DEFAULT_CFLAGS"
 torture-finish
 
 # All done.
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 6217272..d9681b1 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -533,6 +533,8 @@ proc gcc-dg-runtest { testcases flags default-extra-flags } {
 	set nshort [file tail [file dirname $test]]/[file tail $test]
 
 	foreach flags_t $option_list {
+	    global torture_current_flags
+	    set torture_current_flags "$flags_t"
 	    verbose "Testing $nshort, $flags $flags_t" 1
 	    dg-test $test "$flags $flags_t" ${default-extra-flags}
 	}
-- 
2.3.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4] Run tests only if the machine supports the instruction set.
  2016-12-20 21:29             ` [PATCH v4] " Dominik Vogt
@ 2016-12-20 23:59               ` Jakub Jelinek
  2016-12-21 10:00                 ` Dominik Vogt
  2016-12-22 15:18               ` Andreas Krebbel
  1 sibling, 1 reply; 11+ messages in thread
From: Jakub Jelinek @ 2016-12-20 23:59 UTC (permalink / raw)
  To: vogt, Mike Stump, gcc-patches, Andreas Krebbel

On Tue, Dec 20, 2016 at 10:26:13PM +0100, Dominik Vogt wrote:
> On Tue, Dec 20, 2016 at 11:57:52AM -0800, Mike Stump wrote:
> > On Dec 20, 2016, at 6:10 AM, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> > > Right, it gets called even more often than one would think, and
> > > even with empty torture_current_options.  The attached new patch
> > > (v3) removes -Ox options and superflous whitespace and caches that
> > > between calls if it's not empty.  There's another, permanent cache
> > > for calls without any flags.  With proper ordering of the torture
> > > options, the test program is built only a couple of times.
> > 
> > Seems fine to me, but most other cases use the postfix _hw.  Any
> > reason not use use _hw (and not _runable) on these?  If not,
> > could you please use _hw instead.
> 
> No specific reason other than lack of imagination.  "s390_hw" is a
> bit too generic in my eyes -> the new names are:
> 
> v4:
> 
>   * Renamed "s390_runnable" to "s390_useable_hw".
>   * Renamed "z900_runnable" to "s390_z900_hw",
>     Renamed "z10_runnable" to "s390_z10_hw",
>     etc.

Grepping for _hw in target-supports.exp reveals that usually the
effective target predicates are called <isa>_hw or <isa>_hw_available,
<target>_<isa>_hw only if it is too ambiguous (e.g. alpha_max_hw or
ppc_float128_hw_available).  So I think z900_hw, z10_hw etc. is good
enough (as long as it does not clash with some other target isa name),
s390_usable_hw or s390_hw_available is fine.

	Jakub

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4] Run tests only if the machine supports the instruction set.
  2016-12-20 23:59               ` Jakub Jelinek
@ 2016-12-21 10:00                 ` Dominik Vogt
  0 siblings, 0 replies; 11+ messages in thread
From: Dominik Vogt @ 2016-12-21 10:00 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Mike Stump, gcc-patches, Andreas Krebbel

On Tue, Dec 20, 2016 at 10:32:26PM +0100, Jakub Jelinek wrote:
> On Tue, Dec 20, 2016 at 10:26:13PM +0100, Dominik Vogt wrote:
> > On Tue, Dec 20, 2016 at 11:57:52AM -0800, Mike Stump wrote:
> > > On Dec 20, 2016, at 6:10 AM, Dominik Vogt <vogt@linux.vnet.ibm.com> wrote:
> > > > Right, it gets called even more often than one would think, and
> > > > even with empty torture_current_options.  The attached new patch
> > > > (v3) removes -Ox options and superflous whitespace and caches that
> > > > between calls if it's not empty.  There's another, permanent cache
> > > > for calls without any flags.  With proper ordering of the torture
> > > > options, the test program is built only a couple of times.
> > > 
> > > Seems fine to me, but most other cases use the postfix _hw.  Any
> > > reason not use use _hw (and not _runable) on these?  If not,
> > > could you please use _hw instead.
> > 
> > No specific reason other than lack of imagination.  "s390_hw" is a
> > bit too generic in my eyes -> the new names are:
> > 
> > v4:
> > 
> >   * Renamed "s390_runnable" to "s390_useable_hw".
> >   * Renamed "z900_runnable" to "s390_z900_hw",
> >     Renamed "z10_runnable" to "s390_z10_hw",
> >     etc.
> 
> Grepping for _hw in target-supports.exp reveals that usually the
> effective target predicates are called <isa>_hw or <isa>_hw_available,
> <target>_<isa>_hw only if it is too ambiguous (e.g. alpha_max_hw or
> ppc_float128_hw_available).  So I think z900_hw, z10_hw etc. is good
> enough (as long as it does not clash with some other target isa name),
> s390_usable_hw or s390_hw_available is fine.

Okay.  We usually prefix everyting with "s390_" on S/390, so I'd
say we don't make an exception here - even if there are no
potential naming collisions.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v4] Run tests only if the machine supports the instruction set.
  2016-12-20 21:29             ` [PATCH v4] " Dominik Vogt
  2016-12-20 23:59               ` Jakub Jelinek
@ 2016-12-22 15:18               ` Andreas Krebbel
  1 sibling, 0 replies; 11+ messages in thread
From: Andreas Krebbel @ 2016-12-22 15:18 UTC (permalink / raw)
  To: Dominik Vogt; +Cc: gcc-patches

> gcc/ChangeLog-archlevel
> 
> 	* config/s390/s390-c.c (s390_cpu_cpp_builtins_internal): Define
> 	__S390_ARCH_LEVEL__.
> gcc/testsuite/ChangeLog-setmem
> 
> 	* gcc.target/s390/md/setmem_long-1.c: Use "s390_useable_hw".
> 	* gcc.target/s390/md/rXsbg_mode_sXl.c: Likewise.
> 	* gcc.target/s390/md/andc-splitter-1.c: Likewise.
> 	* gcc.target/s390/md/andc-splitter-2.c: Likewise.
> 	* lib/gcc-dg.exp (gcc-dg-runtest): Export torture_current_flags.
> 	* gcc.target/s390/s390.exp: Import torture_current_flags.
> 	(check_effective_target_s390_useable_hw): New.
> 	(check_effective_target_s390_z900_hw): New.
> 	(check_effective_target_s390_z990_hw): New.
> 	(check_effective_target_s390_z9_ec_hw): New.
> 	(check_effective_target_s390_z10_hw): New.
> 	(check_effective_target_s390_z196_hw): New.
> 	(check_effective_target_s390_zEC12_hw): New.
> 	(check_effective_target_s390_z13_hw): New.
> 	(check_effective_target_z10_instructions): Removed.
> 	(torture tests): Add optimization level without -march=.
> 	Reorder torture tests for good cache usage.

Applied. Thanks!

-Andreas-

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-12-22 14:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-19 14:32 Run tests only if the machine supports the instruction set Dominik Vogt
2016-12-19 16:51 ` [PATCH v2] " Dominik Vogt
2016-12-19 17:01   ` Jakub Jelinek
2016-12-20 10:33     ` Dominik Vogt
2016-12-20 10:38       ` Jakub Jelinek
2016-12-20 14:16         ` [PATCH v3] " Dominik Vogt
2016-12-20 20:14           ` Mike Stump
2016-12-20 21:29             ` [PATCH v4] " Dominik Vogt
2016-12-20 23:59               ` Jakub Jelinek
2016-12-21 10:00                 ` Dominik Vogt
2016-12-22 15:18               ` Andreas Krebbel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).