From patchwork Tue Sep 20 08:46:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bingfeng Mei X-Patchwork-Id: 115464 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 DF10AB70BD for ; Tue, 20 Sep 2011 18:47:30 +1000 (EST) Received: (qmail 22491 invoked by alias); 20 Sep 2011 08:47:28 -0000 Received: (qmail 22480 invoked by uid 22791); 20 Sep 2011 08:47:27 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mms2.broadcom.com (HELO mms2.broadcom.com) (216.31.210.18) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Sep 2011 08:47:05 +0000 Received: from [10.16.192.224] by mms2.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.3.2)); Tue, 20 Sep 2011 01:53:06 -0700 X-Server-Uuid: D3C04415-6FA8-4F2C-93C1-920E106A2031 Received: from SJEXCHCCR02.corp.ad.broadcom.com ([10.16.192.130]) by SJEXCHHUB01.corp.ad.broadcom.com ([10.16.192.224]) with mapi; Tue, 20 Sep 2011 01:46:52 -0700 From: "Bingfeng Mei" To: "gcc-patches@gcc.gnu.org" cc: "Ulrich Weigand" Date: Tue, 20 Sep 2011 01:46:47 -0700 Subject: [PATCH] derive alias information from named address spaces. Message-ID: <7FB04A5C213E9943A72EE127DB74F0ADD15FCB0658@SJEXCHCCR02.corp.ad.broadcom.com> MIME-Version: 1.0 X-IsSubscribed: yes 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 Hello, The following patch is to derive more alias information from named address spaces using existing target hook. It was discussed in http://gcc.gnu.org/ml/gcc/2011-09/msg00180.html Bootstrapped and tested on x86-64. OK for trunk? Thanks, Bingfeng 2011-09-20 Bingfeng Mei * alias.c (nonoverlapping_memrefs_p): derive alias information from named addresss space using target hook. (nonoverlapping_memrefs_p): ditto. (write_dependence_p): ditto. (write_dependence_p): ditto. Index: alias.c =================================================================== --- alias.c (revision 178972) +++ alias.c (working copy) @@ -2306,11 +2306,19 @@ nonoverlapping_memrefs_p (const_rtx x, c return 1; /* If we have MEMs refering to different address spaces (which can - potentially overlap), we cannot easily tell from the addresses - whether the references overlap. */ + potentially overlap), they are not aliased if neither is subset + of the other one. */ if (MEM_P (rtlx) && MEM_P (rtly) && MEM_ADDR_SPACE (rtlx) != MEM_ADDR_SPACE (rtly)) - return 0; + { + if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (rtlx), + MEM_ADDR_SPACE (rtly)) + && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (rtly), + MEM_ADDR_SPACE (rtlx))) + return 1; + else + return 0; + } /* Get the base and offsets of both decls. If either is a register, we know both are and are the same, so use that as the base. The only @@ -2417,10 +2425,18 @@ true_dependence_1 (const_rtx mem, enum m return 0; /* If we have MEMs refering to different address spaces (which can - potentially overlap), we cannot easily tell from the addresses - whether the references overlap. */ + potentially overlap), they are not aliased if neither is subset + of the other one. */ if (MEM_ADDR_SPACE (mem) != MEM_ADDR_SPACE (x)) - return 1; + { + if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (mem), + MEM_ADDR_SPACE (x)) + && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (x), + MEM_ADDR_SPACE (mem))) + return 0; + else + return 1; + } if (! mem_addr) { @@ -2542,10 +2558,18 @@ write_dependence_p (const_rtx mem, const return 0; /* If we have MEMs refering to different address spaces (which can - potentially overlap), we cannot easily tell from the addresses - whether the references overlap. */ + potentially overlap), they are not aliased if neither is subset + of the other one. */ if (MEM_ADDR_SPACE (mem) != MEM_ADDR_SPACE (x)) - return 1; + { + if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (mem), + MEM_ADDR_SPACE (x)) + && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (x), + MEM_ADDR_SPACE (mem))) + return 0; + else + return 1; + } x_addr = XEXP (x, 0); mem_addr = XEXP (mem, 0); @@ -2637,10 +2661,18 @@ may_alias_p (const_rtx mem, const_rtx x) return 0; /* If we have MEMs refering to different address spaces (which can - potentially overlap), we cannot easily tell from the addresses - whether the references overlap. */ + potentially overlap), they are not aliased if neither is subset + of the other one. */ if (MEM_ADDR_SPACE (mem) != MEM_ADDR_SPACE (x)) - return 1; + { + if (!targetm.addr_space.subset_p (MEM_ADDR_SPACE (mem), + MEM_ADDR_SPACE (x)) + && !targetm.addr_space.subset_p (MEM_ADDR_SPACE (x), + MEM_ADDR_SPACE (mem))) + return 0; + else + return 1; + } x_addr = XEXP (x, 0); mem_addr = XEXP (mem, 0);