public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RS6000] Don't pass -many to the assembler
@ 2018-11-12 11:49 Alan Modra
  2018-11-12 13:28 ` Alan Modra
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Alan Modra @ 2018-11-12 11:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool

I'd like to remove -many from the options passed by default to the
assembler, on the grounds that a gcc bug in instruction selection (eg.
emitting a power9 insn for -mcpu=power8) is better found at assembly
time than run time.

This might annoy people for a while fixing user asm that we didn't
diagnose previously, but I believe this is the right direction to go.
Of course, -Wa,-many is available for anyone who just wants their
dodgy old code to work.

Bootstrapped etc. powerpc64le-linux.  OK?

	* config/rs6000/rs6000.h (ASM_CPU_SPEC): Remove -many.
	* config/rs6000/aix61.h (ASM_CPU_SPEC): Likewise.
	* config/rs6000/aix71.h (ASM_CPU_SPEC): Likewise.
	* testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c: Don't use
	power mnemonics.

diff --git a/gcc/config/rs6000/aix61.h b/gcc/config/rs6000/aix61.h
index 353e5d6cfeb..a7a8246bfe3 100644
--- a/gcc/config/rs6000/aix61.h
+++ b/gcc/config/rs6000/aix61.h
@@ -91,8 +91,7 @@ do {									\
 %{mcpu=630: -m620} \
 %{mcpu=970: -m970} \
 %{mcpu=G5: -m970} \
-%{mvsx: %{!mcpu*: -mpwr6}} \
--many"
+%{mvsx: %{!mcpu*: -mpwr6}}"
 
 #undef	ASM_DEFAULT_SPEC
 #define ASM_DEFAULT_SPEC "-mpwr4"
diff --git a/gcc/config/rs6000/aix71.h b/gcc/config/rs6000/aix71.h
index 2398ed64baa..d2ca8dc275d 100644
--- a/gcc/config/rs6000/aix71.h
+++ b/gcc/config/rs6000/aix71.h
@@ -89,8 +89,7 @@ do {									\
 	    maltivec: -m970; \
 	    maix64|mpowerpc64: -mppc64; \
 	    : %(asm_default)}; \
-  :%eMissing -mcpu option in ASM_SPEC_CPU?\n} \
--many"
+  :%eMissing -mcpu option in ASM_SPEC_CPU?\n}"
 
 #undef	ASM_DEFAULT_SPEC
 #define ASM_DEFAULT_SPEC "-mpwr4"
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index d75137cf8f5..9d78173a680 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -137,8 +137,7 @@
 	    mvsx: -mpower7; \
 	    mpowerpc64: -mppc64;: %(asm_default)}; \
   :%eMissing -mcpu option in ASM_SPEC_CPU?\n} \
-%{mvsx: -mvsx -maltivec; maltivec: -maltivec} \
--many"
+%{mvsx: -mvsx -maltivec; maltivec: -maltivec}"
 
 #define CPP_DEFAULT_SPEC ""
 
diff --git a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
index 14908dba690..eea7f6ffc2e 100644
--- a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
@@ -45,14 +45,14 @@ __asm__ ("\t.globl\t" #NAME "_asm\n\t"					\
 	 #NAME "_asm:\n\t"						\
 	 "lis 11,gparms@ha\n\t"						\
 	 "la 11,gparms@l(11)\n\t"					\
-	 "st 3,0(11)\n\t"						\
-	 "st 4,4(11)\n\t"						\
-	 "st 5,8(11)\n\t"						\
-	 "st 6,12(11)\n\t"						\
-	 "st 7,16(11)\n\t"						\
-	 "st 8,20(11)\n\t"						\
-	 "st 9,24(11)\n\t"						\
-	 "st 10,28(11)\n\t"						\
+	 "stw 3,0(11)\n\t"						\
+	 "stw 4,4(11)\n\t"						\
+	 "stw 5,8(11)\n\t"						\
+	 "stw 6,12(11)\n\t"						\
+	 "stw 7,16(11)\n\t"						\
+	 "stw 8,20(11)\n\t"						\
+	 "stw 9,24(11)\n\t"						\
+	 "stw 10,28(11)\n\t"						\
 	 "stfd 1,32(11)\n\t"						\
 	 "stfd 2,40(11)\n\t"						\
 	 "stfd 3,48(11)\n\t"						\

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-12 11:49 [RS6000] Don't pass -many to the assembler Alan Modra
@ 2018-11-12 13:28 ` Alan Modra
  2018-11-12 14:39 ` Michael Matz
  2018-11-12 17:51 ` Peter Bergner
  2 siblings, 0 replies; 25+ messages in thread
From: Alan Modra @ 2018-11-12 13:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool

On Mon, Nov 12, 2018 at 10:19:04PM +1030, Alan Modra wrote:
> I'd like to remove -many from the options passed by default to the
> assembler, on the grounds that a gcc bug in instruction selection (eg.
> emitting a power9 insn for -mcpu=power8) is better found at assembly
> time than run time.
> 
> This might annoy people for a while fixing user asm that we didn't
> diagnose previously, but I believe this is the right direction to go.
> Of course, -Wa,-many is available for anyone who just wants their
> dodgy old code to work.
> 
> Bootstrapped etc. powerpc64le-linux.  OK?

I forgot to mention something important.  This exposes a bug with our
target_clones support, in that we don't emit .machine directives when
changing cpu.  eg. gcc.target/powerpc/clone2.c fails with
"unrecognized opcode: `modsd'".

__attribute__((__target__("cpu=..."))) also doesn't emit a .machine
directive before the affected function code.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-12 11:49 [RS6000] Don't pass -many to the assembler Alan Modra
  2018-11-12 13:28 ` Alan Modra
@ 2018-11-12 14:39 ` Michael Matz
  2018-11-12 14:52   ` Andreas Schwab
  2018-11-12 17:51 ` Peter Bergner
  2 siblings, 1 reply; 25+ messages in thread
From: Michael Matz @ 2018-11-12 14:39 UTC (permalink / raw)
  To: Alan Modra; +Cc: gcc-patches, Segher Boessenkool

Hi,

On Mon, 12 Nov 2018, Alan Modra wrote:

> I'd like to remove -many from the options passed by default to the 
> assembler, on the grounds that a gcc bug in instruction selection (eg. 
> emitting a power9 insn for -mcpu=power8) is better found at assembly 
> time than run time.
> 
> This might annoy people for a while fixing user asm that we didn't 
> diagnose previously, but I believe this is the right direction to go. Of 
> course, -Wa,-many is available for anyone who just wants their dodgy old 
> code to work.

Wouldn't this also break compiling code that contains power9 instructions 
but guarded by runtime tests to only be executed on power9 machines?  That 
seems a valid usecase, and it'd be bad if the assembler fails to compile 
such.  (You can't use -mcpu=power9 as work around as the other 
unguarded code is not supposed to be using power9 insns).


Ciao,
Michael.

> 
> Bootstrapped etc. powerpc64le-linux.  OK?
> 
> 	* config/rs6000/rs6000.h (ASM_CPU_SPEC): Remove -many.
> 	* config/rs6000/aix61.h (ASM_CPU_SPEC): Likewise.
> 	* config/rs6000/aix71.h (ASM_CPU_SPEC): Likewise.
> 	* testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c: Don't use
> 	power mnemonics.
> 
> diff --git a/gcc/config/rs6000/aix61.h b/gcc/config/rs6000/aix61.h
> index 353e5d6cfeb..a7a8246bfe3 100644
> --- a/gcc/config/rs6000/aix61.h
> +++ b/gcc/config/rs6000/aix61.h
> @@ -91,8 +91,7 @@ do {									\
>  %{mcpu=630: -m620} \
>  %{mcpu=970: -m970} \
>  %{mcpu=G5: -m970} \
> -%{mvsx: %{!mcpu*: -mpwr6}} \
> --many"
> +%{mvsx: %{!mcpu*: -mpwr6}}"
>  
>  #undef	ASM_DEFAULT_SPEC
>  #define ASM_DEFAULT_SPEC "-mpwr4"
> diff --git a/gcc/config/rs6000/aix71.h b/gcc/config/rs6000/aix71.h
> index 2398ed64baa..d2ca8dc275d 100644
> --- a/gcc/config/rs6000/aix71.h
> +++ b/gcc/config/rs6000/aix71.h
> @@ -89,8 +89,7 @@ do {									\
>  	    maltivec: -m970; \
>  	    maix64|mpowerpc64: -mppc64; \
>  	    : %(asm_default)}; \
> -  :%eMissing -mcpu option in ASM_SPEC_CPU?\n} \
> --many"
> +  :%eMissing -mcpu option in ASM_SPEC_CPU?\n}"
>  
>  #undef	ASM_DEFAULT_SPEC
>  #define ASM_DEFAULT_SPEC "-mpwr4"
> diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
> index d75137cf8f5..9d78173a680 100644
> --- a/gcc/config/rs6000/rs6000.h
> +++ b/gcc/config/rs6000/rs6000.h
> @@ -137,8 +137,7 @@
>  	    mvsx: -mpower7; \
>  	    mpowerpc64: -mppc64;: %(asm_default)}; \
>    :%eMissing -mcpu option in ASM_SPEC_CPU?\n} \
> -%{mvsx: -mvsx -maltivec; maltivec: -maltivec} \
> --many"
> +%{mvsx: -mvsx -maltivec; maltivec: -maltivec}"
>  
>  #define CPP_DEFAULT_SPEC ""
>  
> diff --git a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
> index 14908dba690..eea7f6ffc2e 100644
> --- a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
> +++ b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
> @@ -45,14 +45,14 @@ __asm__ ("\t.globl\t" #NAME "_asm\n\t"					\
>  	 #NAME "_asm:\n\t"						\
>  	 "lis 11,gparms@ha\n\t"						\
>  	 "la 11,gparms@l(11)\n\t"					\
> -	 "st 3,0(11)\n\t"						\
> -	 "st 4,4(11)\n\t"						\
> -	 "st 5,8(11)\n\t"						\
> -	 "st 6,12(11)\n\t"						\
> -	 "st 7,16(11)\n\t"						\
> -	 "st 8,20(11)\n\t"						\
> -	 "st 9,24(11)\n\t"						\
> -	 "st 10,28(11)\n\t"						\
> +	 "stw 3,0(11)\n\t"						\
> +	 "stw 4,4(11)\n\t"						\
> +	 "stw 5,8(11)\n\t"						\
> +	 "stw 6,12(11)\n\t"						\
> +	 "stw 7,16(11)\n\t"						\
> +	 "stw 8,20(11)\n\t"						\
> +	 "stw 9,24(11)\n\t"						\
> +	 "stw 10,28(11)\n\t"						\
>  	 "stfd 1,32(11)\n\t"						\
>  	 "stfd 2,40(11)\n\t"						\
>  	 "stfd 3,48(11)\n\t"						\
> 
> 

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-12 14:39 ` Michael Matz
@ 2018-11-12 14:52   ` Andreas Schwab
  2018-11-12 15:43     ` Segher Boessenkool
  0 siblings, 1 reply; 25+ messages in thread
From: Andreas Schwab @ 2018-11-12 14:52 UTC (permalink / raw)
  To: Michael Matz; +Cc: Alan Modra, gcc-patches, Segher Boessenkool

On Nov 12 2018, Michael Matz <matz@suse.de> wrote:

> Wouldn't this also break compiling code that contains power9 instructions 
> but guarded by runtime tests to only be executed on power9 machines?  That 
> seems a valid usecase, and it'd be bad if the assembler fails to compile 
> such.  (You can't use -mcpu=power9 as work around as the other 
> unguarded code is not supposed to be using power9 insns).

You'll need to put .machine directives around them.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-12 14:52   ` Andreas Schwab
@ 2018-11-12 15:43     ` Segher Boessenkool
  2018-11-12 16:17       ` Michael Matz
  0 siblings, 1 reply; 25+ messages in thread
From: Segher Boessenkool @ 2018-11-12 15:43 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Michael Matz, Alan Modra, gcc-patches

On Mon, Nov 12, 2018 at 03:52:29PM +0100, Andreas Schwab wrote:
> On Nov 12 2018, Michael Matz <matz@suse.de> wrote:
> 
> > Wouldn't this also break compiling code that contains power9 instructions 
> > but guarded by runtime tests to only be executed on power9 machines?  That 
> > seems a valid usecase, and it'd be bad if the assembler fails to compile 
> > such.  (You can't use -mcpu=power9 as work around as the other 
> > unguarded code is not supposed to be using power9 insns).
> 
> You'll need to put .machine directives around them.

My worry with that is there may be too much legacy code that does not
do this :-(


Segher

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-12 15:43     ` Segher Boessenkool
@ 2018-11-12 16:17       ` Michael Matz
  2018-11-12 23:13         ` Alan Modra
  0 siblings, 1 reply; 25+ messages in thread
From: Michael Matz @ 2018-11-12 16:17 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Andreas Schwab, Alan Modra, gcc-patches

Hi,

On Mon, 12 Nov 2018, Segher Boessenkool wrote:

> > > Wouldn't this also break compiling code that contains power9 
> > > instructions but guarded by runtime tests to only be executed on 
> > > power9 machines?  That seems a valid usecase, and it'd be bad if the 
> > > assembler fails to compile such.  (You can't use -mcpu=power9 as 
> > > work around as the other unguarded code is not supposed to be using 
> > > power9 insns).
> > 
> > You'll need to put .machine directives around them.
> 
> My worry with that is there may be too much legacy code that does not do 
> this :-(

We'll see once we put gcc9 through a distro build.  My worry really only 
was that the change would result in compile breakage without a sensible 
solution.  (I'll just give all packages whose build failures prevent gcc9 
from being the new system compiler to Alan for fixing ;-) ).


Ciao,
Michael.

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-12 11:49 [RS6000] Don't pass -many to the assembler Alan Modra
  2018-11-12 13:28 ` Alan Modra
  2018-11-12 14:39 ` Michael Matz
@ 2018-11-12 17:51 ` Peter Bergner
  2 siblings, 0 replies; 25+ messages in thread
From: Peter Bergner @ 2018-11-12 17:51 UTC (permalink / raw)
  To: Alan Modra; +Cc: gcc-patches, Segher Boessenkool

On 11/12/18 5:49 AM, Alan Modra wrote:
> I'd like to remove -many from the options passed by default to the
> assembler, on the grounds that a gcc bug in instruction selection (eg.
> emitting a power9 insn for -mcpu=power8) is better found at assembly
> time than run time.
> 
> This might annoy people for a while fixing user asm that we didn't
> diagnose previously, but I believe this is the right direction to go.
> Of course, -Wa,-many is available for anyone who just wants their
> dodgy old code to work.

+1

Peter

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-12 16:17       ` Michael Matz
@ 2018-11-12 23:13         ` Alan Modra
  2018-11-13  0:34           ` Mike Stump
  0 siblings, 1 reply; 25+ messages in thread
From: Alan Modra @ 2018-11-12 23:13 UTC (permalink / raw)
  To: Michael Matz; +Cc: Segher Boessenkool, Andreas Schwab, gcc-patches

On Mon, Nov 12, 2018 at 04:17:51PM +0000, Michael Matz wrote:
> Hi,
> 
> On Mon, 12 Nov 2018, Segher Boessenkool wrote:
> 
> > > > Wouldn't this also break compiling code that contains power9 
> > > > instructions but guarded by runtime tests to only be executed on 
> > > > power9 machines?  That seems a valid usecase, and it'd be bad if the 
> > > > assembler fails to compile such.  (You can't use -mcpu=power9 as 
> > > > work around as the other unguarded code is not supposed to be using 
> > > > power9 insns).
> > > 
> > > You'll need to put .machine directives around them.
> > 
> > My worry with that is there may be too much legacy code that does not do 
> > this :-(
> 
> We'll see once we put gcc9 through a distro build.  My worry really only 
> was that the change would result in compile breakage without a sensible 
> solution.  (I'll just give all packages whose build failures prevent gcc9 
> from being the new system compiler to Alan for fixing ;-) ).

Heh.  I've been using the patch (or one like it) myself for over 2
years, but of course I don't tend to compile whole distros.  The
length of time I've had it baking in my tree says something about my
hesitation to post the patch more than anything else.  Note that you
can easily "fix" package build failures by adding -Wa,-many to
CFLAGS.

For people developing new code, it's the right way to go, and
especially so for people working on gcc itself.  For people just
wanting stuff to compile, not so much.  I fully expect a chorus of
*MORON* or worse to come from the likes of the linux kernel rabble.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-12 23:13         ` Alan Modra
@ 2018-11-13  0:34           ` Mike Stump
  2018-11-13  0:41             ` Iain Sandoe
  2018-11-13  1:33             ` Alan Modra
  0 siblings, 2 replies; 25+ messages in thread
From: Mike Stump @ 2018-11-13  0:34 UTC (permalink / raw)
  To: Alan Modra; +Cc: Michael Matz, Segher Boessenkool, Andreas Schwab, gcc-patches

On Nov 12, 2018, at 3:13 PM, Alan Modra <amodra@gmail.com> wrote:
> 
> For people developing new code, it's the right way to go, and
> especially so for people working on gcc itself.  For people just
> wanting stuff to compile, not so much.  I fully expect a chorus of
> *MORON* or worse to come from the likes of the linux kernel rabble.

So, if you just want to hear people whine...

On darwin, we (darwin, as a platform decision) like all instructions available from the assembler.  The assembler and the linker have specialized code to track all instructions used (from which CPU types those instructions come from), and mark the object file according to what is actually used.  We also have FAT binaries as a standard feature and other things to make everything play nicely.  People that use inline assembly are expected to know how to code, because it is an advanced feature, and not need hand holding on how to write the condition that guards the code.  I don't recall seeing any reports of anyone needing any extra help in this matter.  On darwin, there wasn't a .machine for a while, it came later.

Anyway, I thought about saying that it would be nice if all platforms behaved the same, and ask, what do people thing the recommended behavior of all platforms should be?

Personally I don't have a dog in this, as darwin cannot be changed, it's a platform feature, and personally, I don't write a ton of this type of code.  I just provide an alternate POV.  Darwin has api's to query the architecture and code in the assembler/linker to help manage it's decision.  Normal ELF systems, I want to say, usually lack such things.  So, choices it makes aren't necessarily right for others.

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-13  0:34           ` Mike Stump
@ 2018-11-13  0:41             ` Iain Sandoe
  2018-11-13  1:33             ` Alan Modra
  1 sibling, 0 replies; 25+ messages in thread
From: Iain Sandoe @ 2018-11-13  0:41 UTC (permalink / raw)
  To: Mike Stump
  Cc: Alan Modra, Michael Matz, Segher Boessenkool, Andreas Schwab,
	gcc-patches


> On 13 Nov 2018, at 00:34, Mike Stump <mikestump@comcast.net> wrote:
> 
> On Nov 12, 2018, at 3:13 PM, Alan Modra <amodra@gmail.com> wrote:
>> 
>> For people developing new code, it's the right way to go, and
>> especially so for people working on gcc itself.  For people just
>> wanting stuff to compile, not so much.  I fully expect a chorus of
>> *MORON* or worse to come from the likes of the linux kernel rabble.
> 
> So, if you just want to hear people whine...
> 
> On darwin, we (darwin, as a platform decision) like all instructions available from the assembler.  The assembler and the linker have specialized code to track all instructions used (from which CPU types those instructions come from), and mark the object file according to what is actually used.  We also have FAT binaries as a standard feature and other things to make everything play nicely.  People that use inline assembly are expected to know how to code, because it is an advanced feature, and not need hand holding on how to write the condition that guards the code.  I don't recall seeing any reports of anyone needing any extra help in this matter.  On darwin, there wasn't a .machine for a while, it came later.
> 
> Anyway, I thought about saying that it would be nice if all platforms behaved the same, and ask, what do people thing the recommended behavior of all platforms should be?
> 
> Personally I don't have a dog in this, as darwin cannot be changed, it's a platform feature, and personally, I don't write a ton of this type of code.  I just provide an alternate POV.  Darwin has api's to query the architecture and code in the assembler/linker to help manage it's decision.  Normal ELF systems, I want to say, usually lack such things.  So, choices it makes aren't necessarily right for others.

Given that we have our own assembler and platform equivalent of -many (-force_cpusubtype_ALL) .. I was just watching the thread go by ;) 

Having said that, it would be interesting to know what the recommendation is with .machine.

Iain

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-13  0:34           ` Mike Stump
  2018-11-13  0:41             ` Iain Sandoe
@ 2018-11-13  1:33             ` Alan Modra
  2018-11-13 11:39               ` Segher Boessenkool
  1 sibling, 1 reply; 25+ messages in thread
From: Alan Modra @ 2018-11-13  1:33 UTC (permalink / raw)
  To: Mike Stump; +Cc: Michael Matz, Segher Boessenkool, Andreas Schwab, gcc-patches

On Mon, Nov 12, 2018 at 04:34:34PM -0800, Mike Stump wrote:
> On Nov 12, 2018, at 3:13 PM, Alan Modra <amodra@gmail.com> wrote:
> > 
> > For people developing new code, it's the right way to go, and
> > especially so for people working on gcc itself.  For people just
> > wanting stuff to compile, not so much.  I fully expect a chorus of
> > *MORON* or worse to come from the likes of the linux kernel rabble.
> 
> So, if you just want to hear people whine...

I'm happy to hear other points of view.  Ignore my hyperbole.

> On darwin, we (darwin, as a platform decision) like all instructions available from the assembler.

OK, fair enough.  Another option is to just disable -many when gcc is
in development, like we enable checking.

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-13  1:33             ` Alan Modra
@ 2018-11-13 11:39               ` Segher Boessenkool
  2018-11-13 17:49                 ` Peter Bergner
  2018-11-14  3:14                 ` Alan Modra
  0 siblings, 2 replies; 25+ messages in thread
From: Segher Boessenkool @ 2018-11-13 11:39 UTC (permalink / raw)
  To: Alan Modra; +Cc: Mike Stump, Michael Matz, Andreas Schwab, gcc-patches

On Tue, Nov 13, 2018 at 12:02:55PM +1030, Alan Modra wrote:
> On Mon, Nov 12, 2018 at 04:34:34PM -0800, Mike Stump wrote:
> > On Nov 12, 2018, at 3:13 PM, Alan Modra <amodra@gmail.com> wrote:
> > > 
> > > For people developing new code, it's the right way to go, and
> > > especially so for people working on gcc itself.  For people just
> > > wanting stuff to compile, not so much.  I fully expect a chorus of
> > > *MORON* or worse to come from the likes of the linux kernel rabble.
> > 
> > So, if you just want to hear people whine...
> 
> I'm happy to hear other points of view.  Ignore my hyperbole.
> 
> > On darwin, we (darwin, as a platform decision) like all instructions available from the assembler.
> 
> OK, fair enough.  Another option is to just disable -many when gcc is
> in development, like we enable checking.

That is a good plan for GCC 9 at least.


Segher

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-13 11:39               ` Segher Boessenkool
@ 2018-11-13 17:49                 ` Peter Bergner
  2018-11-13 18:07                   ` Iain Sandoe
  2018-11-14  3:14                 ` Alan Modra
  1 sibling, 1 reply; 25+ messages in thread
From: Peter Bergner @ 2018-11-13 17:49 UTC (permalink / raw)
  To: Segher Boessenkool, Alan Modra
  Cc: Mike Stump, Michael Matz, Andreas Schwab, gcc-patches

On 11/13/18 5:17 AM, Segher Boessenkool wrote:
> On Tue, Nov 13, 2018 at 12:02:55PM +1030, Alan Modra wrote:
>> On Mon, Nov 12, 2018 at 04:34:34PM -0800, Mike Stump wrote:
>>> On Nov 12, 2018, at 3:13 PM, Alan Modra <amodra@gmail.com> wrote:
>>> On darwin, we (darwin, as a platform decision) like all instructions available from the assembler.
>>
>> OK, fair enough.  Another option is to just disable -many when gcc is
>> in development, like we enable checking.
> 
> That is a good plan for GCC 9 at least.

I like the plan too.  We can also continue to pass -many just for darwin
if they really really think they need it.

Peter

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-13 17:49                 ` Peter Bergner
@ 2018-11-13 18:07                   ` Iain Sandoe
  2018-11-13 18:39                     ` Peter Bergner
  0 siblings, 1 reply; 25+ messages in thread
From: Iain Sandoe @ 2018-11-13 18:07 UTC (permalink / raw)
  To: Peter Bergner
  Cc: Segher Boessenkool, Alan Modra, Mike Stump, Michael Matz,
	Andreas Schwab, gcc-patches

Hi Folks,

> On 13 Nov 2018, at 17:48, Peter Bergner <bergner@linux.ibm.com> wrote:
> 
> On 11/13/18 5:17 AM, Segher Boessenkool wrote:
>> On Tue, Nov 13, 2018 at 12:02:55PM +1030, Alan Modra wrote:
>>> On Mon, Nov 12, 2018 at 04:34:34PM -0800, Mike Stump wrote:
>>>> On Nov 12, 2018, at 3:13 PM, Alan Modra <amodra@gmail.com> wrote:
>>>> On darwin, we (darwin, as a platform decision) like all instructions available from the assembler.
>>> 
>>> OK, fair enough.  Another option is to just disable -many when gcc is
>>> in development, like we enable checking.
>> 
>> That is a good plan for GCC 9 at least.
> 
> I like the plan too.  We can also continue to pass -many just for darwin
> if they really really think they need it.

As far as I expect, Darwin should be untouched by this - we have a separate assembler (which doesn’t even respond to -many), so unless there’s some higher level translation done (it’s not mentioned in any Darwin specs), we should just carry on as before.

When I do expect things to change is when multiple .machine directives are included in asm sources.
(probably) the old cctools assembler won’t deal with them properly
(the 4.0.1 era) LLVM-backend based version I have doesn’t deal with them either (this could be a general consideration for the other parts of the PPC toolchain).  Having said that, I didn’t experiment with .machine on later LLVM backend versions yet.

Thus, my current expectation is that this will be a NOP unless/until incompatible asm source changes are made.

Iain

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-13 18:07                   ` Iain Sandoe
@ 2018-11-13 18:39                     ` Peter Bergner
  2018-11-26 23:03                       ` Mike Stump
  0 siblings, 1 reply; 25+ messages in thread
From: Peter Bergner @ 2018-11-13 18:39 UTC (permalink / raw)
  To: Iain Sandoe
  Cc: Segher Boessenkool, Alan Modra, Mike Stump, Michael Matz,
	Andreas Schwab, gcc-patches

On 11/13/18 12:06 PM, Iain Sandoe wrote:
> As far as I expect, Darwin should be untouched by this - we have a separate assembler (which doesn’t even respond to -many), so unless there’s some higher level translation done (it’s not mentioned in any Darwin specs), we should just carry on as before.

Ah, good then.

> When I do expect things to change is when multiple .machine directives are included in asm sources.
> (probably) the old cctools assembler won’t deal with them properly

Usually when there are multiple .machine's being used, they should be used
with the ".machine push" and ".machine pop" directives so the temporary
.machine value doesn't corrupt the .machine value being used for the rest
of the file.  Like so.

	.machine "power8"

	...

	.machine push
	.machine "power9"
	<power9 insns>
	.machine pop

	...

Hopefully the cctools supports that.

Peter

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-13 11:39               ` Segher Boessenkool
  2018-11-13 17:49                 ` Peter Bergner
@ 2018-11-14  3:14                 ` Alan Modra
  2018-12-13 10:26                   ` Alan Modra
  1 sibling, 1 reply; 25+ messages in thread
From: Alan Modra @ 2018-11-14  3:14 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-patches, David Edelsohn

On Tue, Nov 13, 2018 at 05:17:41AM -0600, Segher Boessenkool wrote:
> On Tue, Nov 13, 2018 at 12:02:55PM +1030, Alan Modra wrote:
> > OK, fair enough.  Another option is to just disable -many when gcc is
> > in development, like we enable checking.
> 
> That is a good plan for GCC 9 at least.

Here's the patch.  Bootstrapped etc. powerpc64le-linux with resultant
fail of clone2 test as already noted.  On top of
https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00924.html so needs
to be hand edited if applying without that patch.  I'm going to be
away for a few days without email access, which means I probably won't
be seeing any replies until Monday.

	* config/rs6000/rs6000.h (ASM_OPT_ANY): Define.
	(ASM_CPU_SPEC): Conditionally add -many.
	* config/rs6000/aix61.h (ASM_CPU_SPEC): Likewise.
	* config/rs6000/aix71.h (ASM_CPU_SPEC): Likewise.
	* testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c: Don't use
	power mnemonics.

diff --git a/gcc/config/rs6000/aix61.h b/gcc/config/rs6000/aix61.h
index 353e5d6cfeb..809c5d8d599 100644
--- a/gcc/config/rs6000/aix61.h
+++ b/gcc/config/rs6000/aix61.h
@@ -91,8 +91,8 @@ do {									\
 %{mcpu=630: -m620} \
 %{mcpu=970: -m970} \
 %{mcpu=G5: -m970} \
-%{mvsx: %{!mcpu*: -mpwr6}} \
--many"
+%{mvsx: %{!mcpu*: -mpwr6}}" \
+ASM_OPT_ANY
 
 #undef	ASM_DEFAULT_SPEC
 #define ASM_DEFAULT_SPEC "-mpwr4"
diff --git a/gcc/config/rs6000/aix71.h b/gcc/config/rs6000/aix71.h
index 2398ed64baa..319bd2dc013 100644
--- a/gcc/config/rs6000/aix71.h
+++ b/gcc/config/rs6000/aix71.h
@@ -89,8 +89,8 @@ do {									\
 	    maltivec: -m970; \
 	    maix64|mpowerpc64: -mppc64; \
 	    : %(asm_default)}; \
-  :%eMissing -mcpu option in ASM_SPEC_CPU?\n} \
--many"
+  :%eMissing -mcpu option in ASM_SPEC_CPU?\n}" \
+ASM_OPT_ANY
 
 #undef	ASM_DEFAULT_SPEC
 #define ASM_DEFAULT_SPEC "-mpwr4"
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index d75137cf8f5..613d16add69 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -72,6 +72,12 @@
 #define PPC405_ERRATUM77 0
 #endif
 
+#if CHECKING_P
+#define ASM_OPT_ANY ""
+#else
+#define ASM_OPT_ANY " -many"
+#endif
+
 /* Common ASM definitions used by ASM_SPEC among the various targets for
    handling -mcpu=xxx switches.  There is a parallel list in driver-rs6000.c to
    provide the default assembler options if the user uses -mcpu=native, so if
@@ -137,8 +143,8 @@
 	    mvsx: -mpower7; \
 	    mpowerpc64: -mppc64;: %(asm_default)}; \
   :%eMissing -mcpu option in ASM_SPEC_CPU?\n} \
-%{mvsx: -mvsx -maltivec; maltivec: -maltivec} \
--many"
+%{mvsx: -mvsx -maltivec; maltivec: -maltivec}" \
+ASM_OPT_ANY
 
 #define CPP_DEFAULT_SPEC ""
 
diff --git a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
index 14908dba690..eea7f6ffc2e 100644
--- a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
@@ -45,14 +45,14 @@ __asm__ ("\t.globl\t" #NAME "_asm\n\t"					\
 	 #NAME "_asm:\n\t"						\
 	 "lis 11,gparms@ha\n\t"						\
 	 "la 11,gparms@l(11)\n\t"					\
-	 "st 3,0(11)\n\t"						\
-	 "st 4,4(11)\n\t"						\
-	 "st 5,8(11)\n\t"						\
-	 "st 6,12(11)\n\t"						\
-	 "st 7,16(11)\n\t"						\
-	 "st 8,20(11)\n\t"						\
-	 "st 9,24(11)\n\t"						\
-	 "st 10,28(11)\n\t"						\
+	 "stw 3,0(11)\n\t"						\
+	 "stw 4,4(11)\n\t"						\
+	 "stw 5,8(11)\n\t"						\
+	 "stw 6,12(11)\n\t"						\
+	 "stw 7,16(11)\n\t"						\
+	 "stw 8,20(11)\n\t"						\
+	 "stw 9,24(11)\n\t"						\
+	 "stw 10,28(11)\n\t"						\
 	 "stfd 1,32(11)\n\t"						\
 	 "stfd 2,40(11)\n\t"						\
 	 "stfd 3,48(11)\n\t"						\

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-13 18:39                     ` Peter Bergner
@ 2018-11-26 23:03                       ` Mike Stump
  0 siblings, 0 replies; 25+ messages in thread
From: Mike Stump @ 2018-11-26 23:03 UTC (permalink / raw)
  To: Peter Bergner
  Cc: Iain Sandoe, Segher Boessenkool, Alan Modra, Michael Matz,
	Andreas Schwab, gcc-patches

On Nov 13, 2018, at 10:39 AM, Peter Bergner <bergner@linux.ibm.com> wrote:
> 
> On 11/13/18 12:06 PM, Iain Sandoe wrote:
>> As far as I expect, Darwin should be untouched by this - we have a separate assembler (which doesn’t even respond to -many), so unless there’s some higher level translation done (it’s not mentioned in any Darwin specs), we should just carry on as before.
> 
> Ah, good then.
> 
>> When I do expect things to change is when multiple .machine directives are included in asm sources.
>> (probably) the old cctools assembler won’t deal with them properly
> 
> Usually when there are multiple .machine's being used, they should be used
> with the ".machine push" and ".machine pop" directives so the temporary
> .machine value doesn't corrupt the .machine value being used for the rest
> of the file.

> Hopefully the cctools supports that.

Likely not.  The modern tools don't for x86_64.

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-11-14  3:14                 ` Alan Modra
@ 2018-12-13 10:26                   ` Alan Modra
  2018-12-13 15:02                     ` David Edelsohn
  0 siblings, 1 reply; 25+ messages in thread
From: Alan Modra @ 2018-12-13 10:26 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-patches, David Edelsohn

On Wed, Nov 14, 2018 at 01:43:57PM +1030, Alan Modra wrote:
> On Tue, Nov 13, 2018 at 05:17:41AM -0600, Segher Boessenkool wrote:
> > On Tue, Nov 13, 2018 at 12:02:55PM +1030, Alan Modra wrote:
> > > OK, fair enough.  Another option is to just disable -many when gcc is
> > > in development, like we enable checking.
> > 
> > That is a good plan for GCC 9 at least.
> 
> Here's the patch.  Bootstrapped etc. powerpc64le-linux with resultant
> fail of clone2 test as already noted.

Revised again, with a bunch of related issues solved.  Bootstrapped
etc. powerpc64le-linux with no regressions.  OK to apply mainline?

---
I'd like to remove -many from the options passed by default to the
assembler, on the grounds that a gcc bug in instruction selection (eg.
emitting a power9 insn for -mcpu=power8) is better found at assembly
time than run time.

For now, just do this when --enable-checking or gcc is not a release.

In contrast to the previous patch, I haven't changed any of the AIX
header files in this patch.  So AIX gcc will continue to pass -many to
their assembler until someone else (David?) makes that change.  This
patch also emits .machine assembler directives for ELF targets when
functions are compiled for different cpus via attributes or pragmas.
That's necessary when the initial -m<cpu> option passed to the
assembler doesn't enable the superset of all opcodes emitted, as seen
by the earlier failure of gcc.target/powerpc/clone2.c (without
.machine) when building gcc for power8.

O3-pr70130.c also failed on an earlier version of this patch (when
only testing one ISA bit to determine .machine).  This is a test for a
power7 vector bug, but on power8 hw check_vect_support_and_set_flags
passes -mpower8-vector which means the test isn't exercising the
original bug exactly.  I reckon that is wrong, and similary for other
vector testcases that ask for a specific cpu.  I've fixed it here by
explicitly passing -mno-power8-vector and similar vector options.

	* config/rs6000/rs6000.h (ASM_OPT_ANY): Define.
	(ASM_CPU_SPEC): Conditionally add -many.
	* config/rs6000/rs6000.c (rs6000_machine): New static var.
	(rs6000_machine_from_flags, emit_asm_machine): New functions..
	(rs6000_file_start): ..extracted from here, and modified to
	test all ISA bits.
	(rs6000_output_function_prologue): Emit .machine as necessary.
	* testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c: Don't use
	power mnemonics.
	* testsuite/gcc.dg/vect/O3-pr70130.c: Disable default options
	added by check_vect_support_and_set_flags.
	* testsuite/gcc.dg/vect/pr48765.c: Likewise.
	* testsuite/gfortran.dg/vect/pr45714-b.f: Likewise.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index f774e2d0bf7..4ca68d0a1d1 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -5715,6 +5715,36 @@ rs6000_builtin_md_vectorized_function (tree fndecl, tree type_out,
 /* Default CPU string for rs6000*_file_start functions.  */
 static const char *rs6000_default_cpu;
 
+#ifdef USING_ELFOS_H
+static const char *rs6000_machine;
+
+static const char *
+rs6000_machine_from_flags (void)
+{
+  if ((rs6000_isa_flags & (ISA_3_0_MASKS_SERVER ^ ISA_2_7_MASKS_SERVER)) != 0)
+    return "power9";
+  if ((rs6000_isa_flags & (ISA_2_7_MASKS_SERVER ^ ISA_2_6_MASKS_SERVER)) != 0)
+    return "power8";
+  if ((rs6000_isa_flags & (ISA_2_6_MASKS_SERVER ^ ISA_2_5_MASKS_SERVER)) != 0)
+    return "power7";
+  if ((rs6000_isa_flags & (ISA_2_5_MASKS_SERVER ^ ISA_2_4_MASKS)) != 0)
+    return "power6";
+  if ((rs6000_isa_flags & (ISA_2_4_MASKS ^ ISA_2_1_MASKS)) != 0)
+    return "power5";
+  if ((rs6000_isa_flags & ISA_2_1_MASKS) != 0)
+    return "power4";
+  if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) != 0)
+    return "ppc64";
+  return "ppc";
+}
+
+static void
+emit_asm_machine (void)
+{
+  fprintf (asm_out_file, "\t.machine %s\n", rs6000_machine);
+}
+#endif
+
 /* Do anything needed at the start of the asm file.  */
 
 static void
@@ -5780,27 +5810,10 @@ rs6000_file_start (void)
     }
 
 #ifdef USING_ELFOS_H
+  rs6000_machine = rs6000_machine_from_flags ();
   if (!(rs6000_default_cpu && rs6000_default_cpu[0])
       && !global_options_set.x_rs6000_cpu_index)
-    {
-      fputs ("\t.machine ", asm_out_file);
-      if ((rs6000_isa_flags & OPTION_MASK_MODULO) != 0)
-	fputs ("power9\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_DIRECT_MOVE) != 0)
-	fputs ("power8\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_POPCNTD) != 0)
-	fputs ("power7\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_CMPB) != 0)
-	fputs ("power6\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_POPCNTB) != 0)
-	fputs ("power5\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_MFCRF) != 0)
-	fputs ("power4\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) != 0)
-	fputs ("ppc64\n", asm_out_file);
-      else
-	fputs ("ppc\n", asm_out_file);
-    }
+    emit_asm_machine ();
 #endif
 
   if (DEFAULT_ABI == ABI_ELFv2)
@@ -27757,7 +27770,17 @@ static void
 rs6000_output_function_prologue (FILE *file)
 {
   if (!cfun->is_thunk)
-    rs6000_output_savres_externs (file);
+    {
+      rs6000_output_savres_externs (file);
+#ifdef USING_ELFOS_H
+      const char *curr_machine = rs6000_machine_from_flags ();
+      if (rs6000_machine != curr_machine)
+	{
+	  rs6000_machine = curr_machine;
+	  emit_asm_machine ();
+	}
+#endif
+    }
 
   /* ELFv2 ABI r2 setup code and local entry point.  This must follow
      immediately after the global entry point label.  */
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index e7e998d1492..2e2d253705b 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -70,6 +70,12 @@
 #define PPC405_ERRATUM77 0
 #endif
 
+#if CHECKING_P
+#define ASM_OPT_ANY ""
+#else
+#define ASM_OPT_ANY " -many"
+#endif
+
 /* Common ASM definitions used by ASM_SPEC among the various targets for
    handling -mcpu=xxx switches.  There is a parallel list in driver-rs6000.c to
    provide the default assembler options if the user uses -mcpu=native, so if
@@ -137,8 +143,8 @@
 	    mvsx: -mpower7; \
 	    mpowerpc64: -mppc64;: %(asm_default)}; \
   :%eMissing -mcpu option in ASM_CPU_SPEC?\n} \
-%{mvsx: -mvsx -maltivec; maltivec: -maltivec} \
--many"
+%{mvsx: -mvsx -maltivec; maltivec: -maltivec}" \
+ASM_OPT_ANY
 
 #define CPP_DEFAULT_SPEC ""
 
diff --git a/gcc/testsuite/gcc.dg/vect/O3-pr70130.c b/gcc/testsuite/gcc.dg/vect/O3-pr70130.c
index 18a295c83f0..f8b84405140 100644
--- a/gcc/testsuite/gcc.dg/vect/O3-pr70130.c
+++ b/gcc/testsuite/gcc.dg/vect/O3-pr70130.c
@@ -1,5 +1,5 @@
 /* { dg-require-effective-target vsx_hw { target powerpc*-*-* } } */
-/* { dg-additional-options "-mcpu=power7" { target powerpc*-*-* } } */
+/* { dg-additional-options "-mcpu=power7 -mno-power9-vector -mno-power8-vector" { target powerpc*-*-* } } */
 
 #include "tree-vect.h"
 
diff --git a/gcc/testsuite/gcc.dg/vect/pr48765.c b/gcc/testsuite/gcc.dg/vect/pr48765.c
index ae364379d07..b091a145d0f 100644
--- a/gcc/testsuite/gcc.dg/vect/pr48765.c
+++ b/gcc/testsuite/gcc.dg/vect/pr48765.c
@@ -1,6 +1,6 @@
 /* { dg-do compile { target { powerpc*-*-* } } } */
 /* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */
-/* { dg-additional-options "-O3 -mcpu=power6" } */
+/* { dg-additional-options "-O3 -mcpu=power6 -mno-power9-vector -mno-power8-vector -mno-vsx" } */
 
 enum reg_class
 {
diff --git a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
index 14908dba690..eea7f6ffc2e 100644
--- a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
@@ -45,14 +45,14 @@ __asm__ ("\t.globl\t" #NAME "_asm\n\t"					\
 	 #NAME "_asm:\n\t"						\
 	 "lis 11,gparms@ha\n\t"						\
 	 "la 11,gparms@l(11)\n\t"					\
-	 "st 3,0(11)\n\t"						\
-	 "st 4,4(11)\n\t"						\
-	 "st 5,8(11)\n\t"						\
-	 "st 6,12(11)\n\t"						\
-	 "st 7,16(11)\n\t"						\
-	 "st 8,20(11)\n\t"						\
-	 "st 9,24(11)\n\t"						\
-	 "st 10,28(11)\n\t"						\
+	 "stw 3,0(11)\n\t"						\
+	 "stw 4,4(11)\n\t"						\
+	 "stw 5,8(11)\n\t"						\
+	 "stw 6,12(11)\n\t"						\
+	 "stw 7,16(11)\n\t"						\
+	 "stw 8,20(11)\n\t"						\
+	 "stw 9,24(11)\n\t"						\
+	 "stw 10,28(11)\n\t"						\
 	 "stfd 1,32(11)\n\t"						\
 	 "stfd 2,40(11)\n\t"						\
 	 "stfd 3,48(11)\n\t"						\
diff --git a/gcc/testsuite/gfortran.dg/vect/pr45714-b.f b/gcc/testsuite/gfortran.dg/vect/pr45714-b.f
index 0d00c6fd666..abf33cd25b8 100644
--- a/gcc/testsuite/gfortran.dg/vect/pr45714-b.f
+++ b/gcc/testsuite/gfortran.dg/vect/pr45714-b.f
@@ -1,5 +1,5 @@
 ! { dg-do compile { target powerpc*-*-* } }
-! { dg-additional-options "-O3 -mcpu=power7 -ffast-math -mveclibabi=mass" }
+! { dg-additional-options "-O3 -mcpu=power7 -mno-power9-vector -mno-power8-vector -ffast-math -mveclibabi=mass" }
 
       integer index(18),i,j,k,l,ipiv(18),info,ichange,neq,lda,ldb,
      &  nrhs,iplas

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [RS6000] Don't pass -many to the assembler
  2018-12-13 10:26                   ` Alan Modra
@ 2018-12-13 15:02                     ` David Edelsohn
  0 siblings, 0 replies; 25+ messages in thread
From: David Edelsohn @ 2018-12-13 15:02 UTC (permalink / raw)
  To: Alan Modra; +Cc: Segher Boessenkool, GCC Patches

On Thu, Dec 13, 2018 at 5:26 AM Alan Modra <amodra@gmail.com> wrote:
>
> On Wed, Nov 14, 2018 at 01:43:57PM +1030, Alan Modra wrote:
> > On Tue, Nov 13, 2018 at 05:17:41AM -0600, Segher Boessenkool wrote:
> > > On Tue, Nov 13, 2018 at 12:02:55PM +1030, Alan Modra wrote:
> > > > OK, fair enough.  Another option is to just disable -many when gcc is
> > > > in development, like we enable checking.
> > >
> > > That is a good plan for GCC 9 at least.
> >
> > Here's the patch.  Bootstrapped etc. powerpc64le-linux with resultant
> > fail of clone2 test as already noted.
>
> Revised again, with a bunch of related issues solved.  Bootstrapped
> etc. powerpc64le-linux with no regressions.  OK to apply mainline?
>
> ---
> I'd like to remove -many from the options passed by default to the
> assembler, on the grounds that a gcc bug in instruction selection (eg.
> emitting a power9 insn for -mcpu=power8) is better found at assembly
> time than run time.
>
> For now, just do this when --enable-checking or gcc is not a release.
>
> In contrast to the previous patch, I haven't changed any of the AIX
> header files in this patch.  So AIX gcc will continue to pass -many to
> their assembler until someone else (David?) makes that change.  This
> patch also emits .machine assembler directives for ELF targets when
> functions are compiled for different cpus via attributes or pragmas.
> That's necessary when the initial -m<cpu> option passed to the
> assembler doesn't enable the superset of all opcodes emitted, as seen
> by the earlier failure of gcc.target/powerpc/clone2.c (without
> .machine) when building gcc for power8.

The AIX release schedule and numbering of releases to support new
processors is making it impossible to reliably predict which
directives (processor names) will be supported on a system on which
GCC is installed.  It's safer to hide the problem on AIX with the use
of -many.

Thanks, David

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

* Re: [RS6000] Don't pass -many to the assembler
  2020-04-06 20:35 ` Sebastian Huber
@ 2020-04-06 22:32   ` Segher Boessenkool
  0 siblings, 0 replies; 25+ messages in thread
From: Segher Boessenkool @ 2020-04-06 22:32 UTC (permalink / raw)
  To: Sebastian Huber; +Cc: Alan Modra, gcc-patches

Hi!

On Mon, Apr 06, 2020 at 10:35:34PM +0200, Sebastian Huber wrote:
> What do you think about the attached patch?

(Please use a correct MIME type for attachments (x-* never is correct on
mailing lists.  Just text/plain will do fine.)

> libgcc/
> 
> 	* config/rs6000/crtresfpr.S: Disable all functions if
> 	_SOFT_DOUBLE is defined.

Can't you just use an appropriate .machine?  I'd prefer that, that's how
AltiVec stuff is done, for example.

>         * config/rs6000/crtresxfpr.S: Likewise.
>         * config/rs6000/crtsavfpr.S: Likewise.

(Broken indentation).

> +/* On PowerPC64 Linux, these functions are provided by the linker.  Soft-double
> + * configurations do not need these functions. */
> +#if !defined(__powerpc64__) && !defined(_SOFT_DOUBLE)

We use __NO_FPRS__ more often.  All of these are the same now, but this
name makes more sense as well ;-)


Segher

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

* Re: [RS6000] Don't pass -many to the assembler
  2019-05-21 12:52 Alan Modra
  2019-05-21 14:48 ` Segher Boessenkool
@ 2020-04-06 20:35 ` Sebastian Huber
  2020-04-06 22:32   ` Segher Boessenkool
  1 sibling, 1 reply; 25+ messages in thread
From: Sebastian Huber @ 2020-04-06 20:35 UTC (permalink / raw)
  To: Alan Modra, gcc-patches; +Cc: Segher Boessenkool

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

Hello,

I am sorry to come back to this thread after such a long time. I 
recently noticed that one of RTEMS multilibs is broken (for whatever 
reason it didn't show up in my regular build):

/build/git-build/b-gcc-git-powerpc-rtems5/powerpc-rtems5/m8540/nof/libgcc 
(master) > make
# If this is the top-level multilib, build all the other
# multilibs.
/build/git-build/b-gcc-git-powerpc-rtems5/./gcc/xgcc 
-B/build/git-build/b-gcc-git-powerpc-rtems5/./gcc/ -nostdinc 
-B/build/git-build/b-gcc-git-powerpc-rtems5/powerpc-rtems5/m8540/nof/newlib/ 
-isystem 
/build/git-build/b-gcc-git-powerpc-rtems5/powerpc-rtems5/m8540/nof/newlib/targ-include 
-isystem /home/EB/sebastian_h/archive/gcc-git/newlib/libc/include 
-B/opt/rtems/5/powerpc-rtems5/bin/ -B/opt/rtems/5/powerpc-rtems5/lib/ 
-isystem /opt/rtems/5/powerpc-rtems5/include -isystem 
/opt/rtems/5/powerpc-rtems5/sys-include  -mcpu=8540 -msoft-float -g -O2 
-O2 
-I/home/EB/sebastian_h/archive/gcc-git/libgcc/../newlib/libc/sys/rtems/include 
-g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing 
-Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes 
-Wold-style-definition  -isystem ./include -g -DIN_LIBGCC2 
-fbuilding-libgcc -fno-stack-protector -Dinhibit_libc  -I. -I. 
-I../../../.././gcc -I/home/EB/sebastian_h/archive/gcc-git/libgcc 
-I/home/EB/sebastian_h/archive/gcc-git/libgcc/. 
-I/home/EB/sebastian_h/archive/gcc-git/libgcc/../gcc 
-I/home/EB/sebastian_h/archive/gcc-git/libgcc/../include -DHAVE_CC_TLS  
-o crtsavfpr_s.o -MT crtsavfpr_s.o -MD -MP -MF crtsavfpr_s.dep -DSHARED 
-c -xassembler-with-cpp 
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S: 
Assembler messages:
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:41: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:42: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:43: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:44: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:45: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:46: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:47: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:48: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:49: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:50: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:51: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:52: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:53: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:54: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:55: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:56: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:57: 
Error: unrecognized opcode: `stfd'
/home/EB/sebastian_h/archive/gcc-git/libgcc/config/rs6000/crtsavfpr.S:58: 
Error: unrecognized opcode: `stfd'

The assembler is called via:

/build/git-build/b-gcc-git-powerpc-rtems5/./gcc/as --gdwarf2 -I 
/home/EB/sebastian_h/archive/gcc-git/libgcc/../newlib/libc/sys/rtems/include 
-I . -I . -I ../../../.././gcc -I 
/home/EB/sebastian_h/archive/gcc-git/libgcc -I 
/home/EB/sebastian_h/archive/gcc-git/libgcc/. -I 
/home/EB/sebastian_h/archive/gcc-git/libgcc/../gcc -I 
/home/EB/sebastian_h/archive/gcc-git/libgcc/../include -a32 -me500 -mbig 
-o crtsavfpr_s.o /tmp/cc6Fy8nn.s

The e500 has no standard FPU. For this reason the multilib flags are: 
-mcpu=8540 -msoft-float

What do you think about the attached patch?


[-- Attachment #2: 0001-RS6000-Disable-some-CRT-functions.patch --]
[-- Type: text/x-patch, Size: 2714 bytes --]

From 7329c85c0e7bcda52ab0a55092747512731e38cd Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date: Mon, 6 Apr 2020 22:30:21 +0200
Subject: [PATCH] RS6000: Disable some CRT functions

libgcc/

	* config/rs6000/crtresfpr.S: Disable all functions if
	_SOFT_DOUBLE is defined.
        * config/rs6000/crtresxfpr.S: Likewise.
        * config/rs6000/crtsavfpr.S: Likewise.
---
 libgcc/config/rs6000/crtresfpr.S  | 5 +++--
 libgcc/config/rs6000/crtresxfpr.S | 5 +++--
 libgcc/config/rs6000/crtsavfpr.S  | 5 +++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/libgcc/config/rs6000/crtresfpr.S b/libgcc/config/rs6000/crtresfpr.S
index 6c0d01bf9c1..ffcd30182cd 100644
--- a/libgcc/config/rs6000/crtresfpr.S
+++ b/libgcc/config/rs6000/crtresfpr.S
@@ -30,8 +30,9 @@
 	.section ".text"
 	#include "ppc-asm.h"
 
-/* On PowerPC64 Linux, these functions are provided by the linker.  */
-#ifndef __powerpc64__
+/* On PowerPC64 Linux, these functions are provided by the linker.  Soft-double
+ * configurations do not need these functions. */
+#if !defined(__powerpc64__) && !defined(_SOFT_DOUBLE)
 
 /* Routines for restoring floating point registers, called by the compiler.  */
 /* Called with r11 pointing to the stack header word of the caller of the */
diff --git a/libgcc/config/rs6000/crtresxfpr.S b/libgcc/config/rs6000/crtresxfpr.S
index 9f01fa5094b..2e1ac2bc017 100644
--- a/libgcc/config/rs6000/crtresxfpr.S
+++ b/libgcc/config/rs6000/crtresxfpr.S
@@ -30,8 +30,9 @@
 	.section ".text"
 	#include "ppc-asm.h"
 
-/* On PowerPC64 Linux, these functions are provided by the linker.  */
-#ifndef __powerpc64__
+/* On PowerPC64 Linux, these functions are provided by the linker.  Soft-double
+ * configurations do not need these functions. */
+#if !defined(__powerpc64__) && !defined(_SOFT_DOUBLE)
 
 /* Routines for restoring floating point registers, called by the compiler.  */
 /* Called with r11 pointing to the stack header word of the caller of the */
diff --git a/libgcc/config/rs6000/crtsavfpr.S b/libgcc/config/rs6000/crtsavfpr.S
index fa043ddd078..4f93f9c4892 100644
--- a/libgcc/config/rs6000/crtsavfpr.S
+++ b/libgcc/config/rs6000/crtsavfpr.S
@@ -30,8 +30,9 @@
 	.section ".text"
 	#include "ppc-asm.h"
 
-/* On PowerPC64 Linux, these functions are provided by the linker.  */
-#ifndef __powerpc64__
+/* On PowerPC64 Linux, these functions are provided by the linker.  Soft-double
+ * configurations do not need these functions. */
+#if !defined(__powerpc64__) && !defined(_SOFT_DOUBLE)
 
 /* Routines for saving floating point registers, called by the compiler.  */
 /* Called with r11 pointing to the stack header word of the caller of the */
-- 
2.16.4


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

* Re: [RS6000] Don't pass -many to the assembler
  2019-05-22  3:26   ` Alan Modra
@ 2019-05-22 20:29     ` Segher Boessenkool
  0 siblings, 0 replies; 25+ messages in thread
From: Segher Boessenkool @ 2019-05-22 20:29 UTC (permalink / raw)
  To: Alan Modra; +Cc: gcc-patches

On Wed, May 22, 2019 at 12:56:15PM +0930, Alan Modra wrote:
> On Tue, May 21, 2019 at 09:48:10AM -0500, Segher Boessenkool wrote:
> > (Is Power5 2.4?  Not 2.2?)
> 
> Yes, I think power5 was 2.02, but I haven't looked at cpu and arch
> books to verify exactly what power5 and power5+ was.

My notes say p5 is 2.02 and p5+ is 2.04.

> Note that gas
> lumps power5 and power5+ in one category so "power5" from
> rs6000_machine_from_flags means power5+ too.

Gotcha, good to know.

GCC can unfortunately not lump the two together, or code compiled for
Power5 will not necessarily work on a Power5 anymore.  For the few
people who care, but hey.

> This change was based on the fact that "friz" and other similar
> instructions enabled by gcc with TARGET_FPRND are enabled in gas by
> "-mpower5", "-mpwr5", or "-mpwr5x".  ("-mpower5+" isn't a valid gas
> option.)  rs6000-cpus.def puts OPTION_MASK_FPRND in ISA_2_4_MASKS, so
> ISA_2_4_MASKS is the one to use in deciding to pass "-mpower5" to
> gas.

FPRND is power5+, 2.04.

> > -mdejagnu-cpu=power7 should make the -mno-* things unnecessary I think?
> 
> No, it doesn't.  The -mno- options are to counter options added by
> check_vect_support_and_set_flags based on hardware detection.

Yeah, I realised that later...  Some later email I think.

It seems that check_vect_support_and_set_flags will need some work (or
the tests using it).


Segher

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

* Re: [RS6000] Don't pass -many to the assembler
  2019-05-21 14:48 ` Segher Boessenkool
@ 2019-05-22  3:26   ` Alan Modra
  2019-05-22 20:29     ` Segher Boessenkool
  0 siblings, 1 reply; 25+ messages in thread
From: Alan Modra @ 2019-05-22  3:26 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-patches

On Tue, May 21, 2019 at 09:48:10AM -0500, Segher Boessenkool wrote:
> > +static const char *
> > +rs6000_machine_from_flags (void)
> > +{
> > +  if ((rs6000_isa_flags & (ISA_3_0_MASKS_SERVER & ~ISA_2_7_MASKS_SERVER)) != 0)
> > +    return "power9";
> > +  if ((rs6000_isa_flags & (ISA_2_7_MASKS_SERVER & ~ISA_2_6_MASKS_SERVER)) != 0)
> > +    return "power8";
> > +  if ((rs6000_isa_flags & (ISA_2_6_MASKS_SERVER & ~ISA_2_5_MASKS_SERVER)) != 0)
> > +    return "power7";
> > +  if ((rs6000_isa_flags & (ISA_2_5_MASKS_SERVER & ~ISA_2_4_MASKS)) != 0)
> > +    return "power6";
> > +  if ((rs6000_isa_flags & (ISA_2_4_MASKS & ~ISA_2_1_MASKS)) != 0)
> > +    return "power5";
> > +  if ((rs6000_isa_flags & ISA_2_1_MASKS) != 0)
> > +    return "power4";
> > +  if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) != 0)
> > +    return "ppc64";
> > +  return "ppc";
> > +}
> 
> As you know I'm trying to get rid of most of the separate user-selectable
> features we have currently.  I think I'll steal this code :-)
> 
> (Is Power5 2.4?  Not 2.2?)

Yes, I think power5 was 2.02, but I haven't looked at cpu and arch
books to verify exactly what power5 and power5+ was.  Note that gas
lumps power5 and power5+ in one category so "power5" from
rs6000_machine_from_flags means power5+ too.

This change was based on the fact that "friz" and other similar
instructions enabled by gcc with TARGET_FPRND are enabled in gas by
"-mpower5", "-mpwr5", or "-mpwr5x".  ("-mpower5+" isn't a valid gas
option.)  rs6000-cpus.def puts OPTION_MASK_FPRND in ISA_2_4_MASKS, so
ISA_2_4_MASKS is the one to use in deciding to pass "-mpower5" to
gas.

> -mdejagnu-cpu=power7 should make the -mno-* things unnecessary I think?

No, it doesn't.  The -mno- options are to counter options added by
check_vect_support_and_set_flags based on hardware detection.  On
power8 hardware just switching to -mdejagnu-cpu results in, for
example:
...xgcc -B.../ ...gcc.dg/vect/pr4875.c -fno-diagnostics-show-caret \
-fno-diagnostics-show-line-numbers -fdiagnostics-color=never -flto \
-ffat-lto-objects -maltivec -mpower8-vector -ftree-vectorize \
-fno-vect-cost-model -fno-common -O2 -fdump-tree-vect-details \
-O3 -mdejagnu-cpu=power6 -S -o pr48765.s

-- 
Alan Modra
Australia Development Lab, IBM

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

* Re: [RS6000] Don't pass -many to the assembler
  2019-05-21 12:52 Alan Modra
@ 2019-05-21 14:48 ` Segher Boessenkool
  2019-05-22  3:26   ` Alan Modra
  2020-04-06 20:35 ` Sebastian Huber
  1 sibling, 1 reply; 25+ messages in thread
From: Segher Boessenkool @ 2019-05-21 14:48 UTC (permalink / raw)
  To: Alan Modra; +Cc: gcc-patches

Hi!

On Tue, May 21, 2019 at 10:22:26PM +0930, Alan Modra wrote:
> This is a repost of
> https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00911.html with a small
> tweak to rs6000_machine_from_flags (&~ instead of ^).
> 
> Bootstrapped and regression tested powerpc64le-linux power8 and
> power9.  OK to apply now that we're in stage1?
> 
> 	* config/rs6000/rs6000.h (ASM_OPT_ANY): Define.
> 	(ASM_CPU_SPEC): Conditionally add -many.
> 	* config/rs6000/rs6000.c (rs6000_machine): New static var.
> 	(rs6000_machine_from_flags, emit_asm_machine): New functions..
> 	(rs6000_file_start): ..extracted from here, and modified to
> 	test all ISA bits.
> 	(rs6000_output_function_prologue): Emit .machine as necessary.
> 	* testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c: Don't use
> 	power mnemonics.
> 	* testsuite/gcc.dg/vect/O3-pr70130.c: Disable default options
> 	added by check_vect_support_and_set_flags.
> 	* testsuite/gcc.dg/vect/pr48765.c: Likewise.
> 	* testsuite/gfortran.dg/vect/pr45714-b.f: Likewise.


> +static const char *
> +rs6000_machine_from_flags (void)
> +{
> +  if ((rs6000_isa_flags & (ISA_3_0_MASKS_SERVER & ~ISA_2_7_MASKS_SERVER)) != 0)
> +    return "power9";
> +  if ((rs6000_isa_flags & (ISA_2_7_MASKS_SERVER & ~ISA_2_6_MASKS_SERVER)) != 0)
> +    return "power8";
> +  if ((rs6000_isa_flags & (ISA_2_6_MASKS_SERVER & ~ISA_2_5_MASKS_SERVER)) != 0)
> +    return "power7";
> +  if ((rs6000_isa_flags & (ISA_2_5_MASKS_SERVER & ~ISA_2_4_MASKS)) != 0)
> +    return "power6";
> +  if ((rs6000_isa_flags & (ISA_2_4_MASKS & ~ISA_2_1_MASKS)) != 0)
> +    return "power5";
> +  if ((rs6000_isa_flags & ISA_2_1_MASKS) != 0)
> +    return "power4";
> +  if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) != 0)
> +    return "ppc64";
> +  return "ppc";
> +}

As you know I'm trying to get rid of most of the separate user-selectable
features we have currently.  I think I'll steal this code :-)

(Is Power5 2.4?  Not 2.2?)

> +    {
> +      rs6000_output_savres_externs (file);
> +#ifdef USING_ELFOS_H
> +      const char *curr_machine = rs6000_machine_from_flags ();
> +      if (rs6000_machine != curr_machine)
> +	{
> +	  rs6000_machine = curr_machine;
> +	  emit_asm_machine ();
> +	}
> +#endif
> +    }

Comparing fixed strings using ==...  Not great.  I'll change things to use
an enum soon, so it's okay for now.

> diff --git a/gcc/testsuite/gcc.dg/vect/O3-pr70130.c b/gcc/testsuite/gcc.dg/vect/O3-pr70130.c
> index 18a295c83f0..f8b84405140 100644
> --- a/gcc/testsuite/gcc.dg/vect/O3-pr70130.c
> +++ b/gcc/testsuite/gcc.dg/vect/O3-pr70130.c
> @@ -1,5 +1,5 @@
>  /* { dg-require-effective-target vsx_hw { target powerpc*-*-* } } */
> -/* { dg-additional-options "-mcpu=power7" { target powerpc*-*-* } } */
> +/* { dg-additional-options "-mcpu=power7 -mno-power9-vector -mno-power8-vector" { target powerpc*-*-* } } */

-mdejagnu-cpu=power7 should make the -mno-* things unnecessary I think?
Hrm, I missed the few testcases outside gcc.target/powerpc/ when I did
that.

Please try that?  Okay for trunk with that.  Thanks!


Segher

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

* [RS6000] Don't pass -many to the assembler
@ 2019-05-21 12:52 Alan Modra
  2019-05-21 14:48 ` Segher Boessenkool
  2020-04-06 20:35 ` Sebastian Huber
  0 siblings, 2 replies; 25+ messages in thread
From: Alan Modra @ 2019-05-21 12:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool

This is a repost of
https://gcc.gnu.org/ml/gcc-patches/2018-12/msg00911.html with a small
tweak to rs6000_machine_from_flags (&~ instead of ^).

Bootstrapped and regression tested powerpc64le-linux power8 and
power9.  OK to apply now that we're in stage1?

	* config/rs6000/rs6000.h (ASM_OPT_ANY): Define.
	(ASM_CPU_SPEC): Conditionally add -many.
	* config/rs6000/rs6000.c (rs6000_machine): New static var.
	(rs6000_machine_from_flags, emit_asm_machine): New functions..
	(rs6000_file_start): ..extracted from here, and modified to
	test all ISA bits.
	(rs6000_output_function_prologue): Emit .machine as necessary.
	* testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c: Don't use
	power mnemonics.
	* testsuite/gcc.dg/vect/O3-pr70130.c: Disable default options
	added by check_vect_support_and_set_flags.
	* testsuite/gcc.dg/vect/pr48765.c: Likewise.
	* testsuite/gfortran.dg/vect/pr45714-b.f: Likewise.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index b5dc5f30f88..d27871ab907 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -5664,6 +5664,36 @@ rs6000_builtin_md_vectorized_function (tree fndecl, tree type_out,
 /* Default CPU string for rs6000*_file_start functions.  */
 static const char *rs6000_default_cpu;
 
+#ifdef USING_ELFOS_H
+static const char *rs6000_machine;
+
+static const char *
+rs6000_machine_from_flags (void)
+{
+  if ((rs6000_isa_flags & (ISA_3_0_MASKS_SERVER & ~ISA_2_7_MASKS_SERVER)) != 0)
+    return "power9";
+  if ((rs6000_isa_flags & (ISA_2_7_MASKS_SERVER & ~ISA_2_6_MASKS_SERVER)) != 0)
+    return "power8";
+  if ((rs6000_isa_flags & (ISA_2_6_MASKS_SERVER & ~ISA_2_5_MASKS_SERVER)) != 0)
+    return "power7";
+  if ((rs6000_isa_flags & (ISA_2_5_MASKS_SERVER & ~ISA_2_4_MASKS)) != 0)
+    return "power6";
+  if ((rs6000_isa_flags & (ISA_2_4_MASKS & ~ISA_2_1_MASKS)) != 0)
+    return "power5";
+  if ((rs6000_isa_flags & ISA_2_1_MASKS) != 0)
+    return "power4";
+  if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) != 0)
+    return "ppc64";
+  return "ppc";
+}
+
+static void
+emit_asm_machine (void)
+{
+  fprintf (asm_out_file, "\t.machine %s\n", rs6000_machine);
+}
+#endif
+
 /* Do anything needed at the start of the asm file.  */
 
 static void
@@ -5729,27 +5759,10 @@ rs6000_file_start (void)
     }
 
 #ifdef USING_ELFOS_H
+  rs6000_machine = rs6000_machine_from_flags ();
   if (!(rs6000_default_cpu && rs6000_default_cpu[0])
       && !global_options_set.x_rs6000_cpu_index)
-    {
-      fputs ("\t.machine ", asm_out_file);
-      if ((rs6000_isa_flags & OPTION_MASK_MODULO) != 0)
-	fputs ("power9\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_DIRECT_MOVE) != 0)
-	fputs ("power8\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_POPCNTD) != 0)
-	fputs ("power7\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_CMPB) != 0)
-	fputs ("power6\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_POPCNTB) != 0)
-	fputs ("power5\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_MFCRF) != 0)
-	fputs ("power4\n", asm_out_file);
-      else if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) != 0)
-	fputs ("ppc64\n", asm_out_file);
-      else
-	fputs ("ppc\n", asm_out_file);
-    }
+    emit_asm_machine ();
 #endif
 
   if (DEFAULT_ABI == ABI_ELFv2)
@@ -27536,7 +27549,17 @@ static void
 rs6000_output_function_prologue (FILE *file)
 {
   if (!cfun->is_thunk)
-    rs6000_output_savres_externs (file);
+    {
+      rs6000_output_savres_externs (file);
+#ifdef USING_ELFOS_H
+      const char *curr_machine = rs6000_machine_from_flags ();
+      if (rs6000_machine != curr_machine)
+	{
+	  rs6000_machine = curr_machine;
+	  emit_asm_machine ();
+	}
+#endif
+    }
 
   /* ELFv2 ABI r2 setup code and local entry point.  This must follow
      immediately after the global entry point label.  */
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index eaf309b45b7..f435d8bf1db 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -70,6 +70,12 @@
 #define PPC405_ERRATUM77 0
 #endif
 
+#if CHECKING_P
+#define ASM_OPT_ANY ""
+#else
+#define ASM_OPT_ANY " -many"
+#endif
+
 /* Common ASM definitions used by ASM_SPEC among the various targets for
    handling -mcpu=xxx switches.  There is a parallel list in driver-rs6000.c to
    provide the default assembler options if the user uses -mcpu=native, so if
@@ -137,8 +143,8 @@
 	    mvsx: -mpower7; \
 	    mpowerpc64: -mppc64;: %(asm_default)}; \
   :%eMissing -mcpu option in ASM_CPU_SPEC?\n} \
-%{mvsx: -mvsx -maltivec; maltivec: -maltivec} \
--many"
+%{mvsx: -mvsx -maltivec; maltivec: -maltivec}" \
+ASM_OPT_ANY
 
 #define CPP_DEFAULT_SPEC ""
 
diff --git a/gcc/testsuite/gcc.dg/vect/O3-pr70130.c b/gcc/testsuite/gcc.dg/vect/O3-pr70130.c
index 18a295c83f0..f8b84405140 100644
--- a/gcc/testsuite/gcc.dg/vect/O3-pr70130.c
+++ b/gcc/testsuite/gcc.dg/vect/O3-pr70130.c
@@ -1,5 +1,5 @@
 /* { dg-require-effective-target vsx_hw { target powerpc*-*-* } } */
-/* { dg-additional-options "-mcpu=power7" { target powerpc*-*-* } } */
+/* { dg-additional-options "-mcpu=power7 -mno-power9-vector -mno-power8-vector" { target powerpc*-*-* } } */
 
 #include "tree-vect.h"
 
diff --git a/gcc/testsuite/gcc.dg/vect/pr48765.c b/gcc/testsuite/gcc.dg/vect/pr48765.c
index ae364379d07..b091a145d0f 100644
--- a/gcc/testsuite/gcc.dg/vect/pr48765.c
+++ b/gcc/testsuite/gcc.dg/vect/pr48765.c
@@ -1,6 +1,6 @@
 /* { dg-do compile { target { powerpc*-*-* } } } */
 /* { dg-skip-if "do not override -mcpu" { *-*-* } { "-mcpu=*" } { "-mcpu=power6" } } */
-/* { dg-additional-options "-O3 -mcpu=power6" } */
+/* { dg-additional-options "-O3 -mcpu=power6 -mno-power9-vector -mno-power8-vector -mno-vsx" } */
 
 enum reg_class
 {
diff --git a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
index 14908dba690..eea7f6ffc2e 100644
--- a/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/ppc32-abi-dfp-1.c
@@ -45,14 +45,14 @@ __asm__ ("\t.globl\t" #NAME "_asm\n\t"					\
 	 #NAME "_asm:\n\t"						\
 	 "lis 11,gparms@ha\n\t"						\
 	 "la 11,gparms@l(11)\n\t"					\
-	 "st 3,0(11)\n\t"						\
-	 "st 4,4(11)\n\t"						\
-	 "st 5,8(11)\n\t"						\
-	 "st 6,12(11)\n\t"						\
-	 "st 7,16(11)\n\t"						\
-	 "st 8,20(11)\n\t"						\
-	 "st 9,24(11)\n\t"						\
-	 "st 10,28(11)\n\t"						\
+	 "stw 3,0(11)\n\t"						\
+	 "stw 4,4(11)\n\t"						\
+	 "stw 5,8(11)\n\t"						\
+	 "stw 6,12(11)\n\t"						\
+	 "stw 7,16(11)\n\t"						\
+	 "stw 8,20(11)\n\t"						\
+	 "stw 9,24(11)\n\t"						\
+	 "stw 10,28(11)\n\t"						\
 	 "stfd 1,32(11)\n\t"						\
 	 "stfd 2,40(11)\n\t"						\
 	 "stfd 3,48(11)\n\t"						\
diff --git a/gcc/testsuite/gfortran.dg/vect/pr45714-b.f b/gcc/testsuite/gfortran.dg/vect/pr45714-b.f
index 0d00c6fd666..abf33cd25b8 100644
--- a/gcc/testsuite/gfortran.dg/vect/pr45714-b.f
+++ b/gcc/testsuite/gfortran.dg/vect/pr45714-b.f
@@ -1,5 +1,5 @@
 ! { dg-do compile { target powerpc*-*-* } }
-! { dg-additional-options "-O3 -mcpu=power7 -ffast-math -mveclibabi=mass" }
+! { dg-additional-options "-O3 -mcpu=power7 -mno-power9-vector -mno-power8-vector -ffast-math -mveclibabi=mass" }
 
       integer index(18),i,j,k,l,ipiv(18),info,ichange,neq,lda,ldb,
      &  nrhs,iplas

-- 
Alan Modra
Australia Development Lab, IBM

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

end of thread, other threads:[~2020-04-06 22:35 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-12 11:49 [RS6000] Don't pass -many to the assembler Alan Modra
2018-11-12 13:28 ` Alan Modra
2018-11-12 14:39 ` Michael Matz
2018-11-12 14:52   ` Andreas Schwab
2018-11-12 15:43     ` Segher Boessenkool
2018-11-12 16:17       ` Michael Matz
2018-11-12 23:13         ` Alan Modra
2018-11-13  0:34           ` Mike Stump
2018-11-13  0:41             ` Iain Sandoe
2018-11-13  1:33             ` Alan Modra
2018-11-13 11:39               ` Segher Boessenkool
2018-11-13 17:49                 ` Peter Bergner
2018-11-13 18:07                   ` Iain Sandoe
2018-11-13 18:39                     ` Peter Bergner
2018-11-26 23:03                       ` Mike Stump
2018-11-14  3:14                 ` Alan Modra
2018-12-13 10:26                   ` Alan Modra
2018-12-13 15:02                     ` David Edelsohn
2018-11-12 17:51 ` Peter Bergner
2019-05-21 12:52 Alan Modra
2019-05-21 14:48 ` Segher Boessenkool
2019-05-22  3:26   ` Alan Modra
2019-05-22 20:29     ` Segher Boessenkool
2020-04-06 20:35 ` Sebastian Huber
2020-04-06 22:32   ` Segher Boessenkool

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).