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

H.J. Lu hjl.tools@gmail.com
Sat Oct 17 18:22:00 GMT 2009


On Fri, Oct 16, 2009 at 5:59 PM, Ian Lance Taylor <iant@google.com> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> @@ -947,6 +949,12 @@ vect_verify_datarefs_alignment (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo)
>>              }
>>            return false;
>>          }
>> +
>> +      mode = TYPE_MODE (STMT_VINFO_VECTYPE (stmt_info));
>> +      align = GET_MODE_ALIGNMENT (mode);
>> +      if (cfun->hard_stack_alignment < align)
>> +     cfun->hard_stack_alignment = align;
>> +
>>        if (supportable_dr_alignment != dr_aligned
>>            && vect_print_dump_info (REPORT_ALIGNMENT))
>>          fprintf (vect_dump, "Vectorizing an unaligned access.");
>
> I do not understand why this is the right place to set your new cfun
> field.  Your patch is about a misaligned stack.  The code you are
> changing here does not appear to have anything to do with a misaligned
> stack.  This code is about the correct alignment of data.  The data
> may be on the stack but it need not be.  If the data is on the stack,
> then the compiler should be able to determine the alignment available
> on the stack.

The issue here is to set proper incoming stack alignment. We have
to do it before RTL expansion which uses this information to check
if stack alignment is needed. To do that, we need to know what the
minimum stack alignment required by hardware. We collect hard
stack alignment when we put variables on stack and check the alignment
generated by vectorizer.


-- 
H.J.



More information about the Gcc-patches mailing list