This is the mail archive of the gcc@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] | |
Hi I would like to share some plans about improving the situation with vector alignment tracking. First of all, I would like to start with a well-known bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50716. There are several aspects of the problem: 1) We would like to avoid the quiet segmentation fault. 2) We would like to warn a user about the potential problems considering assignment of vectors with different alignment. 3) We would like to replace obvious aligned vector assignments with aligned move, and unaligned with unaligned. All these aspects are interconnected and in order to find the problem, we have to improve the alignment tracking facilities. 1) Currently in C we cannot provide information that an array is aligned to a certain number. The problem is hidden in the fact, that pointer can represents an array or an address of an object. And it turns out that current aligned attribute doesn't help here. My proposal is to introduce an attribute called array_alligned (I am very flexible on the name) which can be applied only to the pointers and which would show that the pointer of this type represents an array, where the first element is aligned to the given number. 2) After we have the new attribute, we can have a pass which would check all the pointer arithmetic expressions, and in case of vectors, mark the assignments with __builtin_assume_aligned. 3) In the separate pass we need to mark an alignments of the function return types, in order to propagate this information through the flow-graph. 4) In case of LTO, it becomes possible to track all the pointer dereferences, and depending on the parameters warn, or change aligned assignment to unaligned and vice-versa. As a very first draft of (1) I include the patch, that introduces array_aligned attribute. The attribute sets is_array_flag in the type, ans uses alignment number to store the alignment of the array. In this implementation, we loose information about the alignment of the pointer itself, but I don't know if we need it in this particular situation. Alternatively we can keep array_alignment in a separate field, which one is better I am not sure. Thanks, Artem.
Attachment:
array_aligned.diff
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |