This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR 16660, attribute((aligned)) doesn't work for variables on the stack for greater than required alignment
- From: Dorit Nuzman <DORIT at il dot ibm dot com>
- To: Andrew_Pinski at PlayStation dot Sony dot com
- Cc: gcc-patches at gcc dot gnu dot org, Russell_Olsen at PlayStation dot Sony dot com, Trevor_Smigiel at PlayStation dot Sony dot com
- Date: Tue, 6 Feb 2007 00:40:14 +0200
- Subject: Re: [PATCH] Fix PR 16660, attribute((aligned)) doesn't work for variables on the stack for greater than required alignment
> Hi,
> This patch fixes PR 16660 where we ignore the user supplied allignment
> on stack variables if it is greater than the required alignment on the
> specific target. This fixes the issue by oversizing the stack variable
> and then manually aligning the variable.
>
does this mean that during vectorization we could avoid doing this in
'vect_can_force_dr_alignment_p':
return (alignment <= PREFERRED_STACK_BOUNDARY);
and just return 1 instead, relying on your patch to take care of things,
since we mark the decl as having a user-supplied-alignment:
DECL_USER_ALIGN (base) = 1;
?
(i.e. - with your patch, would it be ok to let the vectorizer increase the
alignment of arrays (on the stack) even if the required alignment is
greater than PREFERRED_STACK_BOUNDARY?)
thanks,
dorit
> I had to remove some asserts from the x86 back-end as they are no longer
> valid from the point of view of the middle-end could have a case where
> preferred_alignment is greater than the target's preferred alignment and
> the stack alignment that is needed can be greater than the target's
> preferred alignment.
>
>
> OK? Bootstrapped and tested on i686-linux-gnu and powerpc-linux-gnu with
> no regressions.
>
> Thanks,
> Andrew Pinski
>
> :ADDPATCH middle-end:
>
> ChangeLog:
>
> * expr.h (allocate_dynamic_stack_space_1): New function
prototype.
> * functionc.c (assign_temp): Take into account the alignment
> of the temp if it is greater than the target's preferred
> alignment.
> * cfgexpand.c: Include optabs.h.
> (get_decl_align_unit): Update comment and don't lower the
> alignment
> if it is greater than the target's preferred alignment.
> (alloc_stack_frame_space): Take an unsigned HOST_WIDE_INT for
> align.
> Take into account the variable's alignment if it is greater than
> the target's preferred alignment.
> (expand_one_stack_var_at): Likewise.
> (defer_stack_allocation): Defer variables who's alignment is
> greater
> than the target's preferred alignment.
> * explow.c (allocate_dynamic_stack_space_1): Split out from
> allocate_dynamic_stack_space and take into acount the required
> alignment.
> (allocate_dynamic_stack_space): Call
> allocate_dynamic_stack_space_1.
> * Makefile.in (cfgexpand.o): Update dependecies.
> * stmt.c (expand_decl): Take into account the alignment
> of the variable if it is greater than the target's preferred
> alignment.
> * config/i386/i386.c (ix86_compute_frame_layout): Don't assert
> that preferred alignment is greater than the normal preferred
> alignment. Don't assert that the stack alignment needed is
> greater
> than the normal preferred alignment.
>
>
> [attachment "attributealignedstack.diff.txt" deleted by Dorit
> Nuzman/Haifa/IBM]