On Thu, Jun 23, 2011 at 4:07 PM, Jakub Jelinek <ja...@redhat.com> wrote: > Hi! > > This is a precondition of the __builtin_assume_aligned patch (otherwise > it wouldn't be useful for vectorization for which it has been designed), > but I've bootstrapped/regtested it on x86_64-linux and i686-linux > separately. > > get_pointer_alignment can tell us that a pointer is already sufficiently > aligned and we don't need to use misaligned loads/stores. It should be > useful even in other cases, such as when the code contains explicit > ptr = (double *) (((uintptr_t) ptr) & ~(uintptr_t) 15); > and similar to guarantee that ptr is already 16 byte aligned, etc. > > I haven't played with doing something additionally just with > SSA_NAME_PTR_INFO (base_addr)->misalign yet if it isn't sufficiently aligned, > but ->align is big enough, for integer_zerop (misalign) I guess we could > just set misalign to that, otherwise? Also, I think we can't leave out the > TYPE_ALIGN_UNIT test, because get_pointer_alignment will often return > just BITS_PER_UNIT, e.g. for PARM_DECLs, even if they are pointers > to sufficiently aligned types. > > Ok for trunk?
Looks good to me. To make use of misalign info we have to fold it into that of DR_OFFSET/INIT though. I eventually wanted to make get_pointer_alignment to also return misalign info (like get_object_alignment_1 does). Thanks, Richard. > 2011-06-23 Jakub Jelinek <ja...@redhat.com> > > * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Use > get_pointer_alignment to see if base isn't sufficiently aligned. > > --- gcc/tree-vect-data-refs.c.jj 2011-06-17 11:02:19.000000000 +0200 > +++ gcc/tree-vect-data-refs.c 2011-06-23 12:37:43.000000000 +0200 > @@ -859,7 +859,9 @@ vect_compute_data_ref_alignment (struct > || (TREE_CODE (base_addr) == SSA_NAME > && tree_int_cst_compare (ssize_int (TYPE_ALIGN_UNIT (TREE_TYPE ( > TREE_TYPE (base_addr)))), > - alignment) >= 0)) > + alignment) >= 0) > + || (get_pointer_alignment (base_addr, TYPE_ALIGN (vectype)) > + >= TYPE_ALIGN (vectype))) > base_aligned = true; > else > base_aligned = false; > > Jakub >