public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, S390] Avoid LA with base and index on z13
@ 2018-07-05 11:09 Robin Dapp
  2018-07-05 11:51 ` Ulrich Weigand
  0 siblings, 1 reply; 4+ messages in thread
From: Robin Dapp @ 2018-07-05 11:09 UTC (permalink / raw)
  To: GCC Patches; +Cc: Andreas Krebbel

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

Hi,

this patch avoids emitting LA on z13 and later when the address has both
an index and a base since a regular add is faster in that case.

Regtested on s390x.

Regards
 Robin

--

gcc/ChangeLog:

2018-07-05  Robin Dapp  <rdapp@linux.ibm.com>

        * config/s390/s390.c (preferred_la_operand_p): Do not use
	LA with base and index on z13 or later.

[-- Attachment #2: gcc-no-la-z13.diff --]
[-- Type: text/x-patch, Size: 558 bytes --]

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 5add5985866..df9357fa9e5 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -4630,6 +4630,11 @@ preferred_la_operand_p (rtx op1, rtx op2)
   if (addr.indx && s390_tune == PROCESSOR_2817_Z196)
     return false;
 
+  /* Avoid LA when the address has index as well as base registers,
+     a regular add is still faster then. */
+  if (addr.base && addr.indx && s390_tune >= PROCESSOR_2964_Z13)
+    return false;
+
   if (!TARGET_64BIT && !addr.pointer)
     return false;
 

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

* Re: [PATCH, S390] Avoid LA with base and index on z13
  2018-07-05 11:09 [PATCH, S390] Avoid LA with base and index on z13 Robin Dapp
@ 2018-07-05 11:51 ` Ulrich Weigand
  2018-07-16 11:02   ` Robin Dapp
  0 siblings, 1 reply; 4+ messages in thread
From: Ulrich Weigand @ 2018-07-05 11:51 UTC (permalink / raw)
  To: Robin Dapp; +Cc: GCC Patches, Andreas Krebbel

Robin Dapp wrote:

>         * config/s390/s390.c (preferred_la_operand_p): Do not use
> 	LA with base and index on z13 or later.

The code just before your change reads:

  /* Avoid LA instructions with index register on z196; it is
     preferable to use regular add instructions when possible.
     Starting with zEC12 the la with index register is "uncracked"
     again.  */
  if (addr.indx && s390_tune == PROCESSOR_2817_Z196)
    return false;

But on zEC12 LA works pretty much the same as on z13/z14, it is
indeed not cracked, but still a 2-cycle instruction when using
an index register.  So I guess the change really should apply
to zEC12 as well, and this could be as simple as changing the
above line to:

  if (addr.indx && s390_tune >= PROCESSOR_2817_Z196)

(Note that "addr.base && addr.indx" is the same as just checking
for addr.indx, since s390_decompose_address will never fill in
*just* an index.)

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

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

* [PATCH, S390] Avoid LA with base and index on z13
  2018-07-05 11:51 ` Ulrich Weigand
@ 2018-07-16 11:02   ` Robin Dapp
  2018-07-16 13:34     ` Andreas Krebbel
  0 siblings, 1 reply; 4+ messages in thread
From: Robin Dapp @ 2018-07-16 11:02 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: GCC Patches, Andreas Krebbel

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

> But on zEC12 LA works pretty much the same as on z13/z14, it is
> indeed not cracked, but still a 2-cycle instruction when using
> an index register.  So I guess the change really should apply
> to zEC12 as well, and this could be as simple as changing the
> above line to:
> 
>   if (addr.indx && s390_tune >= PROCESSOR_2817_Z196)
> 
> (Note that "addr.base && addr.indx" is the same as just checking
> for addr.indx, since s390_decompose_address will never fill in
> *just* an index.)

Good point, I adapted the patch and changed the comment.

Regards
 Robin

--

gcc/ChangeLog:

2018-07-16  Robin Dapp  <rdapp@linux.ibm.com>

	* config/s390/s390.c (preferred_la_operand_p): Do not use
	LA with index register on z196 or later.


[-- Attachment #2: gcc-no-la-z196.diff --]
[-- Type: text/x-patch, Size: 956 bytes --]

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 23c3f3db621..d8b47c6fe67 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -4623,11 +4623,11 @@ preferred_la_operand_p (rtx op1, rtx op2)
   if (addr.indx && !REGNO_OK_FOR_INDEX_P (REGNO (addr.indx)))
     return false;
 
-  /* Avoid LA instructions with index register on z196; it is
-     preferable to use regular add instructions when possible.
-     Starting with zEC12 the la with index register is "uncracked"
-     again.  */
-  if (addr.indx && s390_tune == PROCESSOR_2817_Z196)
+  /* Avoid LA instructions with index (and base) register on z196 or
+     later; it is preferable to use regular add instructions when
+     possible.  Starting with zEC12 the la with index register is
+     "uncracked" again but still slower than a regular add.  */
+  if (addr.indx && s390_tune >= PROCESSOR_2817_Z196)
     return false;
 
   if (!TARGET_64BIT && !addr.pointer)

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

* Re: [PATCH, S390] Avoid LA with base and index on z13
  2018-07-16 11:02   ` Robin Dapp
@ 2018-07-16 13:34     ` Andreas Krebbel
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Krebbel @ 2018-07-16 13:34 UTC (permalink / raw)
  To: Robin Dapp, Ulrich Weigand; +Cc: GCC Patches

On 07/16/2018 01:02 PM, Robin Dapp wrote:
>> But on zEC12 LA works pretty much the same as on z13/z14, it is
>> indeed not cracked, but still a 2-cycle instruction when using
>> an index register.  So I guess the change really should apply
>> to zEC12 as well, and this could be as simple as changing the
>> above line to:
>>
>>   if (addr.indx && s390_tune >= PROCESSOR_2817_Z196)
>>
>> (Note that "addr.base && addr.indx" is the same as just checking
>> for addr.indx, since s390_decompose_address will never fill in
>> *just* an index.)
> 
> Good point, I adapted the patch and changed the comment.
> 
> Regards
>  Robin
> 
> --
> 
> gcc/ChangeLog:
> 
> 2018-07-16  Robin Dapp  <rdapp@linux.ibm.com>
> 
> 	* config/s390/s390.c (preferred_la_operand_p): Do not use
> 	LA with index register on z196 or later.
> 

Ok to apply. Thanks!

Andreas

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

end of thread, other threads:[~2018-07-16 13:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-05 11:09 [PATCH, S390] Avoid LA with base and index on z13 Robin Dapp
2018-07-05 11:51 ` Ulrich Weigand
2018-07-16 11:02   ` Robin Dapp
2018-07-16 13:34     ` 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).