From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26446 invoked by alias); 23 Jun 2011 14:08:11 -0000 Received: (qmail 26436 invoked by uid 22791); 23 Jun 2011 14:08:10 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Jun 2011 14:07:41 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p5NE7e3k022172 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 23 Jun 2011 10:07:41 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p5NE7dtr029162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Jun 2011 10:07:40 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p5NE7deu012983; Thu, 23 Jun 2011 16:07:39 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p5NE7cv1012168; Thu, 23 Jun 2011 16:07:38 +0200 Date: Thu, 23 Jun 2011 14:14:00 -0000 From: Jakub Jelinek To: Ira Rosen , Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Use get_pointer_alignment in vect_compute_data_ref_alignment Message-ID: <20110623140738.GQ16443@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg01760.txt.bz2 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 * 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