public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Ira Rosen <ira.rosen@linaro.org>, Richard Guenther <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] Use get_pointer_alignment in vect_compute_data_ref_alignment
Date: Thu, 23 Jun 2011 14:14:00 -0000	[thread overview]
Message-ID: <20110623140738.GQ16443@tyan-ft48-01.lab.bos.redhat.com> (raw)

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

             reply	other threads:[~2011-06-23 14:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-23 14:14 Jakub Jelinek [this message]
2011-06-23 16:28 ` Richard Guenther

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110623140738.GQ16443@tyan-ft48-01.lab.bos.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ira.rosen@linaro.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).