From patchwork Thu Jan 17 04:16:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 213139 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A373C2C0087 for ; Thu, 17 Jan 2013 15:17:06 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1359001027; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:From:To:Cc:Subject:References:Date: In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=QSIDJzJerhGih/tkc6iq f2Nca7s=; b=A96Cd5W7B6UlzKNdd4Kq8lXrDdRrqw4/w5/O08i9bfTSjc2eNYQz Y5fXDgrdLsnPLsMMdmMQ6s+XdnrVd/LMK2yKYv8MiQfrVrv5amGSBBQWrM1WyRKW GkdUgQ6PBVlty7RGHUmysYvr4OAMqw1B2XcsPDsHAIDFUw7dMrensBE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=tJ4O//HH5pH6ehYNvgglpMkH7VYwkCTuE42dFPcxVKWiBo16aeO9W0FOSmCcol t8Q2HF4gh8MiR87VkrGCankKANIkVdUIilrAyqrfLBO+i08oBwwfUmT5Pxx25LjS t8zl0iHBwU/rF3GNIyA1MVz/llng53Sqmko1U9x60F07g=; Received: (qmail 13510 invoked by alias); 17 Jan 2013 04:16:55 -0000 Received: (qmail 13479 invoked by uid 22791); 17 Jan 2013 04:16:52 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, T_TVD_MIME_NO_HEADERS 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, 17 Jan 2013 04:16:41 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0H4GerB007593 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Jan 2013 23:16:40 -0500 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0H4GamK018552 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Jan 2013 23:16:39 -0500 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.5/8.14.5) with ESMTP id r0H4GPpa027778; Thu, 17 Jan 2013 02:16:27 -0200 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id r0H4GN5p013783; Thu, 17 Jan 2013 02:16:23 -0200 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id r0H4GM0W013781; Thu, 17 Jan 2013 02:16:22 -0200 From: Alexandre Oliva To: Richard Henderson Cc: ubizjak@gmail.com, Aldy Hernandez , gcc-patches@gcc.gnu.org Subject: Re: [PR55547] fix alias regression on alpha on misaligned symbols References: <50F582CE.3090201@redhat.com> <50F585DB.2020706@redhat.com> <50F70571.3080606@redhat.com> Date: Thu, 17 Jan 2013 02:16:21 -0200 In-Reply-To: <50F70571.3080606@redhat.com> (Richard Henderson's message of "Wed, 16 Jan 2013 11:54:25 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Jan 16, 2013, Richard Henderson wrote: > I notice that these expressions (including the first hunk that uses > ifs) are now all the same. It would seem extremely prudent to pull > this out to a function so that they stay the same. Here's a revised patch that makes that change, making the overlap computation clearer (to me) while at that. The other fix was to avoid adjusting zero sizes at alignment expressions, lest they'd lose the special meaning. Regstrapping on x86_64-linux-gnu and i686-linux-gnu. Ok to install? Be conservative about negative sizes on symbols, use abs elsewhere From: Alexandre Oliva for gcc/ChangeLog PR rtl-optimization/55547 PR rtl-optimization/53827 PR debug/53671 PR debug/49888 * alias.c (memrefs_conflict_p): Use abs of sizes all over, retaining the conservative special case for symbolic constants. --- gcc/alias.c | 46 ++++++++++++++++++++++++++++------------------ 1 files changed, 28 insertions(+), 18 deletions(-) diff --git a/gcc/alias.c b/gcc/alias.c index 9a386dd..f3cd014 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -1904,6 +1904,20 @@ addr_side_effect_eval (rtx addr, int size, int n_refs) return addr; } +/* Return TRUE if an object X sized at XSIZE bytes and another object + Y sized at YSIZE bytes, starting C bytes after X, may overlap. If + any of the sizes is zero, assume an overlap, otherwise use the + absolute value of the sizes as the actual sizes. */ + +static inline bool +offset_overlap_p (HOST_WIDE_INT c, int xsize, int ysize) +{ + return (xsize == 0 || ysize == 0 + || (c >= 0 + ? (abs (xsize) > c) + : (abs (ysize) > -c))); +} + /* Return one if X and Y (memory addresses) reference the same location in memory or if the references overlap. Return zero if they do not overlap, else return @@ -1976,23 +1990,17 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) else if (GET_CODE (x) == LO_SUM) x = XEXP (x, 1); else - x = addr_side_effect_eval (x, xsize, 0); + x = addr_side_effect_eval (x, abs (xsize), 0); if (GET_CODE (y) == HIGH) y = XEXP (y, 0); else if (GET_CODE (y) == LO_SUM) y = XEXP (y, 1); else - y = addr_side_effect_eval (y, ysize, 0); + y = addr_side_effect_eval (y, abs (ysize), 0); if (rtx_equal_for_memref_p (x, y)) { - if (xsize <= 0 || ysize <= 0) - return 1; - if (c >= 0 && xsize > c) - return 1; - if (c < 0 && ysize+c > 0) - return 1; - return 0; + return offset_overlap_p (c, xsize, ysize); } /* This code used to check for conflicts involving stack references and @@ -2062,8 +2070,7 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) x0 = canon_rtx (XEXP (x, 0)); y0 = canon_rtx (XEXP (y, 0)); if (rtx_equal_for_memref_p (x0, y0)) - return (xsize == 0 || ysize == 0 - || (c >= 0 && xsize > c) || (c < 0 && ysize+c > 0)); + return offset_overlap_p (c, xsize, ysize); /* Can't properly adjust our sizes. */ if (!CONST_INT_P (x1)) @@ -2093,7 +2100,8 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) { if (xsize > 0) xsize = -xsize; - xsize += sc + 1; + if (xsize) + xsize += sc + 1; c -= sc + 1; return memrefs_conflict_p (xsize, canon_rtx (XEXP (x, 0)), ysize, y, c); @@ -2107,7 +2115,8 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) { if (ysize > 0) ysize = -ysize; - ysize += sc + 1; + if (ysize) + ysize += sc + 1; c += sc + 1; return memrefs_conflict_p (xsize, x, ysize, canon_rtx (XEXP (y, 0)), c); @@ -2119,8 +2128,7 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) if (CONST_INT_P (x) && CONST_INT_P (y)) { c += (INTVAL (y) - INTVAL (x)); - return (xsize <= 0 || ysize <= 0 - || (c >= 0 && xsize > c) || (c < 0 && ysize+c > 0)); + return offset_overlap_p (c, xsize, ysize); } if (GET_CODE (x) == CONST) @@ -2136,10 +2144,12 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c) return memrefs_conflict_p (xsize, x, ysize, canon_rtx (XEXP (y, 0)), c); + /* Assume a potential overlap for symbolic addresses that went + through alignment adjustments (i.e., that have negative + sizes), because we can't know how far they are from each + other. */ if (CONSTANT_P (y)) - return (xsize <= 0 || ysize <= 0 - || (rtx_equal_for_memref_p (x, y) - && ((c >= 0 && xsize > c) || (c < 0 && ysize+c > 0)))); + return (xsize < 0 || ysize < 0 || offset_overlap_p (c, xsize, ysize)); return -1; }