On Wed, May 22, 2013 at 3:57 PM, Sandra Loosemore <san...@codesourcery.com> wrote: > On 05/22/2013 02:01 AM, Richard Biener wrote: >> >> On Wed, May 22, 2013 at 3:57 AM, David Edelsohn <dje....@gmail.com> wrote: >>> >>> >>> Increasing the alignment of arrays within structs and unions would be >>> nice, but that probably will change the ABI. I think that they best we >>> may be able to do is increase the alignment if the array is the first >>> element of the struct or union, see ROUND_TYPE_ALIGN for AIX. >>> Although this might be more trouble than it is worth. >> >> >> Maybe the idea was to increase the alignment of the struct (without >> affecting it's layout) when that increases the alignment of a contained >> array member. Like for >> >> struct { int i; int j; float a[1024]; int x; }; >> >> where aligning to sizeof (int) * 2 would get 'a' a bigger alignment. > > > In fact, this is what the patch I posted earlier this week does, except the > alignment it looks for is 16 bytes. In other words, it doesn't change the > alignment of arrays inside structs (which would cause all sorts of > compatibility problems), but it checks to see whether there is already some > array inside the struct aligned on a 16-byte offset so that the whole > containing struct object would benefit from being aligned on a 16-byte > boundary. > > This was a generalization of the suggestion from the previous review to > align structs that contain an array as the first or only element.... I > realized we'd want to handle unions too, and look at all fields in a union > instead of just the first one in a struct, and unifying the two cases made > the code come out tidier. :-)
Right. Btw, the code should all be target independent ... just the desired alignment for an array should be queried from it. pass_ipa_increase_alignment and/or the vectorizer code itself should use that info. Richard. > -Sandra >