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

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


On Mon, Oct 19, 2009 at 10:30 AM, Ian Lance Taylor <iant@google.com> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> On Mon, Oct 19, 2009 at 10:05 AM, Ian Lance Taylor <iant@google.com> wrote:
>>> "H.J. Lu" <hjl.tools@gmail.com> writes:
>>>
>>>> Vectorizer may not call assign_*_temp at all. Instead, x86 backend
>>>> may call gen_reg_rtx to generate pseudo registers when expanding
>>>> vector statement.
>>>
>>> It simply does not make sense to change the vectorizer, of all things,
>>> to set the stack alignment.  Stack alignment depends upon the
>>> types/modes of automatic variables stored on the stack.  Therefore,
>>> you should set the required stack alignment based on the creation of
>>> automatic variables.  Ideally you would set the required stack
>>> alignment for automatic variables stored on the stack, but apparently
>>> you can't change the stack alignment after expand (though I don't see
>>> why not).  So if you can't set the stack alignment based on automatic
>>> variables stored on the stack, then you should set it based on the
>>> creation of automatic variables.
>>>
>>
>> It is about setting the incoming stack alignment, which has to be
>> done before RTL expansion. Vectorizer may not use any automatic
>> variables. But the RTL expander may generate pseudo vector registers
>> based on vector statement, at which time, it is too late to go back to
>> change incoming stack alignment.  I only modified vectorizer to
>> record what it does. I didn't change any statements generated by
>> vectorizer. The x86 backend uses this information to set the
>> incoming stack alignment before RTL expansion.
>
> If somebody asked you "where does gcc set the required stack
> alignment?" would you expect the answer to be "in the vectorizer
> code?"

Yes, vectorizer may put requirement on stack alignment. But it is up
to backend to decide and it isn't the only place gcc may require
certain stack alignment.

> Is there any way we can fix incoming stack alignment so that it can be
> controlled by automatic stack variables?  I don't understand why this

The incoming stack alignment can be controlled by automatic stack
variables. But it can't be controlled by pseudo registers.

> is not done by the prologue and epilogue code.
>

Because the prologue and epilogue code is generated after
RTL expansion starts?


-- 
H.J.



More information about the Gcc-patches mailing list