public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: ix86 `double' alignment (was Re: egcs-1.1 release schedule)
@ 1998-06-23 10:23 John Wehle
  1998-06-23 14:56 ` Craig Burley
  1998-06-23 22:55 ` Jeffrey A Law
  0 siblings, 2 replies; 23+ messages in thread
From: John Wehle @ 1998-06-23 10:23 UTC (permalink / raw)
  To: law; +Cc: d.love, egcs, burley

> Instead we must make sure that we always allocate stacks in 8 byte
> hunks in the prologue *and* that we push an extra dummy word on the stack
> when performing function calls where the arg list + return pointer
> are not a multiple of 8 bytes in size.

I'm seeing a lot of references to double and aligning on 8 byte boundaries.
As long as we are looking at this we may want to view it as a more general
problem.  I.e. Intel recommends that

  doubles be aligned on 8 byte boundarys

  long doubles be aligned on 16 byte boundarys

  objects >= 32 bytes in size be aligned on 32 byte boundarys

I believe that they all have similar issues with regards to encouraging
gcc to align them for optimal performance on the stack so it's possible
that they may all be "solved" with the same solution in the back end.

Just something to think about. :-)

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: ix86 double alignment (was Re: egcs-1.1 release schedule)
@ 1998-06-24 17:12 John Wehle
  1998-06-24 21:23 ` Jeffrey A Law
  0 siblings, 1 reply; 23+ messages in thread
From: John Wehle @ 1998-06-24 17:12 UTC (permalink / raw)
  To: law; +Cc: burley, d.love, egcs, davem

> It's an interesting question to think about.  HP recommends a 64byte
> alignment for the stack on PAs.  It has some *really* nice benefits
> as far as the dcache is concerned.  And until about a year ago we
> actually followed that guideline -- by setting STACK_BOUNDARY appropriately :-)
> 
> That's how I know about the problems that combine will cause if you
> end up with a mis-aligned stack pointer relative to STACK_BOUNDARY.
> It turned out the crt0 code on hpux10 only provided 8 byte alignment
> for the stack pointer.  Opps.

What about defining PREFERRED_STACK_BOUNDARY to mean the optimal stack
alignment and having it default to STACK_BOUNDARY?  Then change the
places which align the stack based on STACK_BOUNDARY to use
PREFERRED_STACK_BOUNDARY.  Leave code which implements optimizations
(and records the stack alignment) based on STACK_BOUNDARY alone.  This
way gcc will attempt to align the stack based on PREFERRED_STACK_BOUNDARY
and assume STACK_BOUNDARY when implementing optimizations which should
be safe (assuming that PREFERRED_STACK_BOUNDARY >= STACK_BOUNDARY is
enforced).

I known ... I've probably oversimplified the issue. :-)

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: ix86 double alignment (was Re: egcs-1.1 release schedule)
@ 1998-06-23  3:32 John Wehle
  1998-06-23 15:06 ` Craig Burley
  0 siblings, 1 reply; 23+ messages in thread
From: John Wehle @ 1998-06-23  3:32 UTC (permalink / raw)
  To: burley; +Cc: law, d.love, egcs, davem

> [...]
> The latter uses automatic arrays (which gcc and g77 support), it'd
> be great to get those 64-bit aligned as well.  The former is the
> most important thing we *aren't* aligning, currently, even with
> `-malign-double'.  (It should be aligned especially if `a' is an
> array, of course.)
> [...]
> Note that I suggested the gcc architecture (machine descriptions,
> etc.) be modified to include a more fine-grained expression of
> alignment requirements.  E.g. distinguishing hardware requirements
> (even instruction requirements, such as `ld' vs. `ldd' on SPARCv8)
> from ABI requirements from ideal performance settings.  But this
> suggestion was turned down at the time -- some seven years ago!

Though it's not as fine-grain as what's mentioned above it may be
worth while to consider using the DATA_ALIGNMENT macro when laying
out variables for the stack.  On the i386 it currently returns the
Intel recommended alignment for doubles, long doubles, arrays, etc.
(the recommended alignment for long doubles is different from doubles).

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: egcs-1.1 release schedule
  1998-06-21 23:07 egcs-1.1 release schedule Jeffrey A Law
@ 1998-06-22  5:19 David S. Miller
  1998-06-22 18:20 ` ix86 double alignment (was Re: egcs-1.1 release schedule) Craig Burley
  0 siblings, 1 reply; 23+ messages in thread
From: David S. Miller @ 1998-06-22  5:19 UTC (permalink / raw)
  To: law; +Cc: d.love, egcs

   Date: Sun, 21 Jun 1998 22:31:31 -0600
   From: Jeffrey A Law <law@cygnus.com>

	   * The ABI is still going to mandate that some doubles in
	     argument lists are going to be mis-aligned.  We'd have
	     to arrange to copy them from the arglist into a suitable
	     stack slot.  This may be more trouble than its worth.

And there are still going to be issues with equivalence statements.

Later,
David S. Miller
davem@dm.cobaltmicro.com


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: egcs-1.1 release schedule
@ 1998-06-21 23:07 Jeffrey A Law
  1998-06-22 12:04 ` ix86 `double' alignment (was Re: egcs-1.1 release schedule) Craig Burley
  0 siblings, 1 reply; 23+ messages in thread
From: Jeffrey A Law @ 1998-06-21 23:07 UTC (permalink / raw)
  To: Dave Love; +Cc: egcs

  In message < rzqaf79nru7.fsf@djlvig.dl.ac.uk >you write:
  > _Please_ include some means of allowing Fortran (at least) to get
  > stack-allocated doubles double-aligned on x86 (modulo libc).  (I hope
  > I haven't missed this going in at some stage!)  The one-line patch for
  > STACK_BOUNDARY used by g77 0.5.22 is good enough.
I'm still waiting on some kind of solution that doesn't totally break
the ABI.

To do this "right" you have to:

	* Make sure gcc always allocates stack in multiples of 8 bytes,
	  adding dummy outgoing args as necessary to keep the stack
	  properly aligned at call points.

	  You can't do this with STACK_BOUNDARY since that says we
	  will 100% always have a properly aligned stack, which can
	  never be true since we might be linking in code from
	  another compiler which didn't keep the stack suitably
	  aligned.

	  If the stack gets mis-aligned relative to STACK_BOUNDARY
	  combine could end up removing a seemingly useless
	  stack operation/address calculation.

	  The idea is to make sure the stack is 8 byte aligned in the
	  common cases, but not absolutely rely on it for correct code
	  generation.


	* Second, assuming that gcc always keeps the pointer aligned
	  for itself, then arrange for doubles to end up 8 byte
	  aligned relative to the stack pointer.

	  If the stack gets mis-aligned due to an old module, then
	  our doubles won't be aligned correctly, but the vast majority
	  of the time they will be suitably aligned.

	  I don't think there's any mechanism to do this when the
	  desired alignment is less than STACK_BOUNDARY.  I fact
	  I know that to be the case since I worked on a similar
	  problem recently.

	* The ABI is still going to mandate that some doubles in
	  argument lists are going to be mis-aligned.  We'd have
	  to arrange to copy them from the arglist into a suitable
	  stack slot.  This may be more trouble than its worth.



Note that some non-ABI breaking changes to align doubles and other
values have gone into the x86 compiler.  In particular we should be
properly aligning all data in the static store.

jeff




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

end of thread, other threads:[~1998-06-28 18:01 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-06-23 10:23 ix86 `double' alignment (was Re: egcs-1.1 release schedule) John Wehle
1998-06-23 14:56 ` Craig Burley
1998-06-23 22:55 ` Jeffrey A Law
  -- strict thread matches above, loose matches on Subject: below --
1998-06-24 17:12 ix86 double " John Wehle
1998-06-24 21:23 ` Jeffrey A Law
1998-06-23  3:32 John Wehle
1998-06-23 15:06 ` Craig Burley
1998-06-23 22:55   ` Jeffrey A Law
1998-06-24 10:08   ` Dave Love
1998-06-24 21:23     ` Jeffrey A Law
1998-06-22  5:19 egcs-1.1 release schedule David S. Miller
1998-06-22 18:20 ` ix86 double alignment (was Re: egcs-1.1 release schedule) Craig Burley
1998-06-23  3:32   ` Jeffrey A Law
1998-06-23  5:13     ` Craig Burley
1998-06-23  3:32   ` David S. Miller
1998-06-23  6:30     ` Craig Burley
1998-06-21 23:07 egcs-1.1 release schedule Jeffrey A Law
1998-06-22 12:04 ` ix86 `double' alignment (was Re: egcs-1.1 release schedule) Craig Burley
1998-06-23  3:32   ` Jeffrey A Law
1998-06-23  5:13     ` Craig Burley
1998-06-24  2:28       ` Jeffrey A Law
1998-06-24 14:50         ` Craig Burley
1998-06-25  0:25           ` Jeffrey A Law
1998-06-25  9:59             ` Tim Hollebeek
1998-06-28 18:01             ` Marc Lehmann

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