public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [s390] increase stack alignment
@ 2008-10-04 11:14 DJ Delorie
  2008-10-08 14:47 ` Andreas Krebbel
  0 siblings, 1 reply; 6+ messages in thread
From: DJ Delorie @ 2008-10-04 11:14 UTC (permalink / raw)
  To: gcc-patches


The CDSG opcode requires 16 byte alignment, not just 8.  Ok to apply?

2008-10-03  DJ Delorie  <dj@redhat.com>

	* config/s390/s390.h (STACK_BOUNDARY): Increase stack alignment to
	128 bits.

Index: config/s390/s390.h
===================================================================
--- config/s390/s390.h	(revision 140862)
+++ config/s390/s390.h	(working copy)
@@ -220,13 +220,13 @@ if (INTEGRAL_MODE_P (MODE) &&	        	 
 	  }
 
 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
 #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32)
 
 /* Boundary (in *bits*) on which stack pointer should be aligned.  */
-#define STACK_BOUNDARY 64
+#define STACK_BOUNDARY 128
 
 /* Allocation boundary (in *bits*) for the code of a function.  */
 #define FUNCTION_BOUNDARY 32
 
 /* There is no point aligning anything to a rounder boundary than this.  */
 #define BIGGEST_ALIGNMENT 64

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

* Re: [s390] increase stack alignment
  2008-10-04 11:14 [s390] increase stack alignment DJ Delorie
@ 2008-10-08 14:47 ` Andreas Krebbel
  2008-10-08 21:00   ` DJ Delorie
  0 siblings, 1 reply; 6+ messages in thread
From: Andreas Krebbel @ 2008-10-08 14:47 UTC (permalink / raw)
  To: DJ Delorie; +Cc: gcc-patches

On Fri, Oct 03, 2008 at 09:08:59PM -0400, DJ Delorie wrote:
> 
> The CDSG opcode requires 16 byte alignment, not just 8.  Ok to apply?

You are right regarding the cdsg instruction.  But I don't think this
is a correct fix. I think this would be an ABI change.  Linking code
with the old stack alignment together with new code would not sustain
the 16 byte alignment anymore. Also the packed stack layout would need
adjustment to apply the proper alignment when saving an odd number of
GPRS.

I also consider an atomic operation on an auto variable to be a
relatively rare case.  For other variables the required alignment can
easily be enforced with the respective attribute.  So could you please
elaborate why you think this is necessary.

Bye,

-Andreas-

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

* Re: [s390] increase stack alignment
  2008-10-08 21:00   ` DJ Delorie
@ 2008-10-08 21:00     ` Andrew Pinski
  2008-10-08 21:16       ` H.J. Lu
  2008-10-08 21:06     ` H.J. Lu
  1 sibling, 1 reply; 6+ messages in thread
From: Andrew Pinski @ 2008-10-08 21:00 UTC (permalink / raw)
  To: DJ Delorie; +Cc: Andreas Krebbel, gcc-patches

On Wed, Oct 8, 2008 at 1:55 PM, DJ Delorie <dj@redhat.com> wrote:
>
>> So could you please elaborate why you think this is necessary.
>
> The CDSG opcode needs 16 byte alignment when accessing stack
> variables, currently it doesn't get it, I'm not really picky about how
> it gets fixed ;-)
>
> In the test case I have (from a customer), the cdsg opcode is in an
> inline asm, so gcc can't know that that stack is "special".  However,
> the variables on stack are tagged for 32-byte alignment, and only get
> 8-byte alignment.  Perhaps something in gcc could note when stack
> variables need greater alignment than the stack normally provides, and
> adjust the stack at runtime accordingly?

See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660.  I had posted a
patch which realigned the stack variables if needed but it was not
commented on except by HJL.  Intel implemented something different for
x86 where they realign the whole stack.

Thanks,
Andrew Pinski

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

* Re: [s390] increase stack alignment
  2008-10-08 14:47 ` Andreas Krebbel
@ 2008-10-08 21:00   ` DJ Delorie
  2008-10-08 21:00     ` Andrew Pinski
  2008-10-08 21:06     ` H.J. Lu
  0 siblings, 2 replies; 6+ messages in thread
From: DJ Delorie @ 2008-10-08 21:00 UTC (permalink / raw)
  To: Andreas Krebbel; +Cc: gcc-patches


> So could you please elaborate why you think this is necessary.

The CDSG opcode needs 16 byte alignment when accessing stack
variables, currently it doesn't get it, I'm not really picky about how
it gets fixed ;-)

In the test case I have (from a customer), the cdsg opcode is in an
inline asm, so gcc can't know that that stack is "special".  However,
the variables on stack are tagged for 32-byte alignment, and only get
8-byte alignment.  Perhaps something in gcc could note when stack
variables need greater alignment than the stack normally provides, and
adjust the stack at runtime accordingly?

Other suggestions are also welcome :-)

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

* Re: [s390] increase stack alignment
  2008-10-08 21:00   ` DJ Delorie
  2008-10-08 21:00     ` Andrew Pinski
@ 2008-10-08 21:06     ` H.J. Lu
  1 sibling, 0 replies; 6+ messages in thread
From: H.J. Lu @ 2008-10-08 21:06 UTC (permalink / raw)
  To: DJ Delorie; +Cc: Andreas Krebbel, gcc-patches

On Wed, Oct 8, 2008 at 1:55 PM, DJ Delorie <dj@redhat.com> wrote:
>
>> So could you please elaborate why you think this is necessary.
>
> The CDSG opcode needs 16 byte alignment when accessing stack
> variables, currently it doesn't get it, I'm not really picky about how
> it gets fixed ;-)
>
> In the test case I have (from a customer), the cdsg opcode is in an
> inline asm, so gcc can't know that that stack is "special".  However,
> the variables on stack are tagged for 32-byte alignment, and only get
> 8-byte alignment.  Perhaps something in gcc could note when stack
> variables need greater alignment than the stack normally provides, and
> adjust the stack at runtime accordingly?
>

The middle end does collect all alignment requirements on stack. But
the backend has to use this info to align the stack properly. Right now
only x86 backend can align the stack dynamically.


-- 
H.J.

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

* Re: [s390] increase stack alignment
  2008-10-08 21:00     ` Andrew Pinski
@ 2008-10-08 21:16       ` H.J. Lu
  0 siblings, 0 replies; 6+ messages in thread
From: H.J. Lu @ 2008-10-08 21:16 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: DJ Delorie, Andreas Krebbel, gcc-patches

On Wed, Oct 8, 2008 at 1:59 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Wed, Oct 8, 2008 at 1:55 PM, DJ Delorie <dj@redhat.com> wrote:
>>
>>> So could you please elaborate why you think this is necessary.
>>
>> The CDSG opcode needs 16 byte alignment when accessing stack
>> variables, currently it doesn't get it, I'm not really picky about how
>> it gets fixed ;-)
>>
>> In the test case I have (from a customer), the cdsg opcode is in an
>> inline asm, so gcc can't know that that stack is "special".  However,
>> the variables on stack are tagged for 32-byte alignment, and only get
>> 8-byte alignment.  Perhaps something in gcc could note when stack
>> variables need greater alignment than the stack normally provides, and
>> adjust the stack at runtime accordingly?
>
> See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16660.  I had posted a
> patch which realigned the stack variables if needed but it was not
> commented on except by HJL.  Intel implemented something different for
> x86 where they realign the whole stack.

Andrew, maybe you can update your patch with SUPPORTS_STACK_ALIGNMENT.
If SUPPORTS_STACK_ALIGNMENT is true, stack variables can be
aligned properly.

-- 
H.J.

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

end of thread, other threads:[~2008-10-08 21:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-04 11:14 [s390] increase stack alignment DJ Delorie
2008-10-08 14:47 ` Andreas Krebbel
2008-10-08 21:00   ` DJ Delorie
2008-10-08 21:00     ` Andrew Pinski
2008-10-08 21:16       ` H.J. Lu
2008-10-08 21:06     ` H.J. Lu

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