This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]