PATCH: PR target/40838: gcc shouldn't assume that the stack is aligned

H.J. Lu hjl.tools@gmail.com
Mon Oct 19 16:36:00 GMT 2009


On Sun, Oct 18, 2009 at 12:44 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Sun, Oct 18, 2009 at 9:19 PM, Michael Matz <matz@suse.de> wrote:
>> Hi,
>>
>> On Sat, 17 Oct 2009, Richard Guenther wrote:
>>
>>> > I can't rely on automatic variables for vectorizer when I need
>>> > the information before RTL expansion.
>>>
>>> I don't see how this is too late (I also don't see where expand creates
>>> automatic variables,
>>
>> assign_temp/assign_stack_temp, all over.
>>
>>> but well ... I can imagine reload creating spill slots).  If non-aligned
>>> automatic variables are generated you simply use unaligned moves -
>>> what's the problem?
>>
>> It's obvious: we don't want to generate unaligned moves.  That's the whole
>> point of H.J. patches.  He has a phase ordering problem:
>> (a) alignment of generated temporaries depends on known stack alignment
>> (b) known stack alignment depends on what is put on stack (including late
>>    generated temporaries)
>>
>> He tries to solve this by pessimistically assuming that potentially
>> everything imaginable could go on stack.  What I don't understand is why
>> we don't instead track hard_stack_alignment in assign_*_temp (where we
>> then assume that the stack will be aligned perfectly), and expand stack
>> realignment code _after_ having expanded everything else (plus examined
>> local variables for the possibility of generating spill slots).
>
> I also don't understand how this problem can be solved in the vectorizer
> and how this problem cannot occur the same way when using
> intrinsics.
>

The issues are

1. The incoming stack alignment can't be changed after RTL expansion
starts.
2. When -mstackrealign is used, we want to use 4 byte incoming stack
alignment on functions which use SSE vector insns.
3. SSE vector insns may be generated by intrinsics, vectorizer and
vector operations.

Both intrinsics and and vector operations will always use automatic
variables, which are handled by ix86_minimum_alignment.  Since
vectorizer may not always use automatic variables, I modified
vectorizer to update hard_stack_alignment when vector statements
are generated.

Thanks.


-- 
H.J.



More information about the Gcc-patches mailing list