s390: Fix --with-arch=... --with-tune=... [PR26877]

Message ID 20200225092028.GK2155@tucnak
State New
Headers show
Series
  • s390: Fix --with-arch=... --with-tune=... [PR26877]
Related show

Commit Message

Jakub Jelinek Feb. 25, 2020, 9:20 a.m.
Hi!

In Fedora we configure GCC with --with-arch=zEC12 --with-tune=z13 right now
and furthermore redhat-rpm-config adds to rpm packages -march=zEC12 -mtune=z13
options (among others).  While looking at the git compilation, I've been
surprised that -O2 actually behaves differently from -O2 -mtune=z13 in this
configuration, and indeed, seems --with-tune= is completely ignored on s390
if --with-arch= is specified.

i386 had the same problem, but got that fixed in 2006, see PR26877.
The thing is that for tune, we add -mtune=%(VALUE) only if neither -mtune=
nor -march= is present, but as arch is processed first, it adds
-march=%(VALUE) first and then -march= is always present and so -mtune= is
never added.
By reordering it in OPTION_DEFAULT_SPECS, we process tune first, add the
default -mtune=%(VALUE) if -mtune= or -march= isn't seen, and then
add -march=%(VALUE) if -march= isn't seen.  It is true that cc1 etc.
will be then invoked with -mtune=z13 -march=zEC12, but like if the user
specifies it in that order, it should still use z13 tuning and zEC12
ISA set.

Bootstrapped/regtested on s390x-linux, ok for trunk?

2020-02-25  Jakub Jelinek  <jakub@redhat.com>

	PR target/26877
	* config/s390/s390.h (OPTION_DEFAULT_SPECS): Reorder.


	Jakub

Comments

Andreas Krebbel March 3, 2020, 7:37 a.m. | #1
On 2/25/20 10:20 AM, Jakub Jelinek wrote:
> Hi!

> 

> In Fedora we configure GCC with --with-arch=zEC12 --with-tune=z13 right now

> and furthermore redhat-rpm-config adds to rpm packages -march=zEC12 -mtune=z13

> options (among others).  While looking at the git compilation, I've been

> surprised that -O2 actually behaves differently from -O2 -mtune=z13 in this

> configuration, and indeed, seems --with-tune= is completely ignored on s390

> if --with-arch= is specified.

> 

> i386 had the same problem, but got that fixed in 2006, see PR26877.

> The thing is that for tune, we add -mtune=%(VALUE) only if neither -mtune=

> nor -march= is present, but as arch is processed first, it adds

> -march=%(VALUE) first and then -march= is always present and so -mtune= is

> never added.

> By reordering it in OPTION_DEFAULT_SPECS, we process tune first, add the

> default -mtune=%(VALUE) if -mtune= or -march= isn't seen, and then

> add -march=%(VALUE) if -march= isn't seen.  It is true that cc1 etc.

> will be then invoked with -mtune=z13 -march=zEC12, but like if the user

> specifies it in that order, it should still use z13 tuning and zEC12

> ISA set.

> 

> Bootstrapped/regtested on s390x-linux, ok for trunk?

> 

> 2020-02-25  Jakub Jelinek  <jakub@redhat.com>

> 

> 	PR target/26877

> 	* config/s390/s390.h (OPTION_DEFAULT_SPECS): Reorder.


Ok. Thanks for fixing this.

Andreas

> 

> --- gcc/config/s390/s390.h.jj	2020-01-12 11:54:36.412413424 +0100

> +++ gcc/config/s390/s390.h	2020-02-24 19:04:14.104259482 +0100

> @@ -227,11 +227,13 @@ enum processor_flags

>  #define TARGET_DEFAULT             0

>  #endif

>  

> -/* Support for configure-time defaults.  */

> +/* Support for configure-time defaults.

> +   The order here is important so that -march doesn't squash the

> +   tune values.  */

>  #define OPTION_DEFAULT_SPECS					\

>    { "mode", "%{!mesa:%{!mzarch:-m%(VALUE)}}" },			\

> -  { "arch", "%{!march=*:-march=%(VALUE)}" },			\

> -  { "tune", "%{!mtune=*:%{!march=*:-mtune=%(VALUE)}}" }

> +  { "tune", "%{!mtune=*:%{!march=*:-mtune=%(VALUE)}}" },	\

> +  { "arch", "%{!march=*:-march=%(VALUE)}" }

>  

>  #ifdef __s390__

>  extern const char *s390_host_detect_local_cpu (int argc, const char **argv);

> 

> 	Jakub

>

Patch

--- gcc/config/s390/s390.h.jj	2020-01-12 11:54:36.412413424 +0100
+++ gcc/config/s390/s390.h	2020-02-24 19:04:14.104259482 +0100
@@ -227,11 +227,13 @@  enum processor_flags
 #define TARGET_DEFAULT             0
 #endif
 
-/* Support for configure-time defaults.  */
+/* Support for configure-time defaults.
+   The order here is important so that -march doesn't squash the
+   tune values.  */
 #define OPTION_DEFAULT_SPECS					\
   { "mode", "%{!mesa:%{!mzarch:-m%(VALUE)}}" },			\
-  { "arch", "%{!march=*:-march=%(VALUE)}" },			\
-  { "tune", "%{!mtune=*:%{!march=*:-mtune=%(VALUE)}}" }
+  { "tune", "%{!mtune=*:%{!march=*:-mtune=%(VALUE)}}" },	\
+  { "arch", "%{!march=*:-march=%(VALUE)}" }
 
 #ifdef __s390__
 extern const char *s390_host_detect_local_cpu (int argc, const char **argv);