public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Altivec + 16 byte alignment
@ 2003-02-11 17:25 John David Anglin
  2003-02-11 18:29 ` Franz Sirl
  0 siblings, 1 reply; 26+ messages in thread
From: John David Anglin @ 2003-02-11 17:25 UTC (permalink / raw)
  To: gcc; +Cc: gianni

> I have a problem in that altivec requires all inputs to be 16 byte
> aligned, so I am placing my vectors in a structure like this:
> 
> struct vector {
>         float x,y,z,w;
> }__attribute__((aligned(16)));

We had a similar problem with respect to the alignment of data for
the ldcw instruction on the PA which needs 16-byte alignment on PA 1.X.
We have found an alternative solution.  However, the patch below
will allow the aligned attribute to be respected for stack locals
up to PREFERRED_STACK_BOUNDARY.  Note however, that alignment of
stack locals is only guaranteed up to STACK_BOUNDARY.  The default
alignment for structs on the stack is BIGGEST_ALIGNMENT, which I
presume is set 64 (8 bytes).

It may well be with altvec you really want BIGGEST_ALIGNMENT set to
256, but the change would affect the ABI and alignment of long doubles.
The i386 code provides an example of what needs doing if there are
types such as long doubles that don't require natural alignment.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2003-02-11  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	* function.c (assign_stack_temp_for_type): Allow user to increase
	alignment of stack locals up to PREFERRED_STACK_BOUNDARY.

Index: function.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/function.c,v
retrieving revision 1.388
diff -u -3 -p -r1.388 function.c
--- function.c	27 Nov 2002 02:29:12 -0000	1.388
+++ function.c	6 Dec 2002 23:07:56 -0000
@@ -650,6 +650,12 @@ assign_stack_temp_for_type (mode, size, 
   else
     align = GET_MODE_ALIGNMENT (mode);
 
+  /* Allow the user to increase the default alignment with the aligned
+     attribute but bound the range.  */
+  if (type && TYPE_USER_ALIGN (type))
+    align = MIN (MAX (TYPE_ALIGN (type), align),
+		 MAX (PREFERRED_STACK_BOUNDARY, align));
+
   if (! type)
     type = (*lang_hooks.types.type_for_mode) (mode, 0);
 

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

end of thread, other threads:[~2003-03-04  2:27 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <Message from Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
2002-02-21  6:26 ` powerpc-linux-gnu bootstrap fail Franz Sirl
2002-02-21  8:37   ` David Edelsohn
2002-02-21 10:07     ` Franz Sirl
2002-02-22  8:59       ` Daniel Egger
2003-02-11 17:25 Altivec + 16 byte alignment John David Anglin
2003-02-11 18:29 ` Franz Sirl
2003-02-11 18:32   ` David Edelsohn
2003-02-11 18:57     ` Franz Sirl
2003-02-11 22:35       ` Spundun Bhatt
     [not found]         ` <1045070773.1118.140.camel@lemsip>
2003-02-12 18:06           ` Spundun Bhatt
2003-02-12  0:42   ` Richard Henderson
2003-02-12 21:17     ` Franz Sirl
2003-02-12 21:46       ` Richard Henderson
2003-02-12 22:31         ` Franz Sirl
2003-02-13  0:04           ` Gabriel Paubert
2003-02-12 22:47         ` John David Anglin
2003-02-13  0:40           ` Richard Henderson
2003-02-13  6:31             ` John David Anglin
2003-02-13  8:59               ` Richard Henderson
2003-02-13 18:06                 ` John David Anglin
2003-02-17 20:00                 ` [PATCH]: Stack alignment John David Anglin
2003-02-17 20:47                   ` Geoff Keating
2003-02-17 22:27                     ` John David Anglin
2003-02-18  0:04                     ` John David Anglin
2003-03-01 19:32                     ` [PATCH]: Stack alignment - take 2 John David Anglin
2003-03-04  3:34                       ` Richard Henderson

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