This is my first patch submittal so constructive criticism is appreciated.
This patch causes PowerPC AltiVec local stack arrays > 16 bytes to be
aligned at 16 bytes.
2011-01-27 Pat Wellander <pwell...@codesourcery.com>
* config/rs6000/rs6000.h (LOCAL_ALIGNMENT):
AltiVec local arrays >= 16 bytes are now aligned to at least 16 bytes.
Index: config/rs6000/rs6000.h
===================================================================
--- config/rs6000/rs6000.h (revision 171171)
+++ config/rs6000/rs6000.h (working copy)
@@ -686,9 +686,16 @@
/* A C expression to compute the alignment for a variables in the
local store. TYPE is the data type, and ALIGN is the alignment
- that the object would ordinarily have. */
-#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
- DATA_ALIGNMENT (TYPE, ALIGN)
+ that the object would ordinarily have.
+ Align most data using the DATA_ALIGNMENT macro but
+ align local Altivec arrays >= 16 bytes
+ to 16 bytes (128 bits). The DATA_ALIGNMENT macro aligns
+ all char arrays (not struct fields) to 16 bytes. These
+ alignments don't appear to affect struct field arrays. */
+#define LOCAL_ALIGNMENT(TYPE, ALIGN) \
+ (TARGET_ALTIVEC && (TREE_CODE (TYPE) == ARRAY_TYPE) \
+ && tree_low_cst (TYPE_SIZE (TYPE), 1) >= 128 ? 128 \
+ : DATA_ALIGNMENT (TYPE, ALIGN))
/* Alignment of field after `int : 0' in a structure. */
#define EMPTY_FIELD_BOUNDARY 32
2011-01-27 Pat Wellander <pwell...@codesourcery.com>
* gcc.target/powerpc/altivec-34.c: Test AltiVec local array alignment
Index: gcc.target/powerpc/altivec-34.c
===================================================================
--- gcc.target/powerpc/altivec-34.c (revision 0)
+++ gcc.target/powerpc/altivec-34.c (revision 0)
@@ -0,0 +1,27 @@
+/* altivec-34.c */
+/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-options "-O0 -maltivec" } */
+
+#include <stdlib.h>
+
+/* Align large local Altivec arrays at 128 bits */
+
+int main(void)
+{
+ long a1[5], a2[6], a3[4];
+ char c1[4], c2[17];
+ if (((long)(&a1[0])) & 0xf)
+ abort ();
+ if (((long)(&a2[0])) & 0xf)
+ abort ();
+ if (((long)(&a3[0])) & 0xf)
+ abort ();
+ if (((long)(&c1[0])) & 0xf)
+ abort ();
+ if (((long)(&c2[0])) & 0xf)
+ abort ();
+ exit (0);
+}
+
+