public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Use get_pointer_alignment in vect_compute_data_ref_alignment
@ 2011-06-23 14:14 Jakub Jelinek
  2011-06-23 16:28 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2011-06-23 14:14 UTC (permalink / raw)
  To: Ira Rosen, Richard Guenther; +Cc: gcc-patches

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?

2011-06-23  Jakub Jelinek  <jakub@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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-23 16:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-23 14:14 [PATCH] Use get_pointer_alignment in vect_compute_data_ref_alignment Jakub Jelinek
2011-06-23 16:28 ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).