From patchwork Tue Oct 16 23:53:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 191915 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 3F93E2C00A6 for ; Wed, 17 Oct 2012 10:53:25 +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=1351036406; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=HihqVv1Z7EYP89h2dl1xbZKKlDY=; b=HHaaALQ95bRl4vv fqSjCtpP4OO8//7hw7JPIW+OfNgFoaJeiWnYUCjeYlLr4YaVCHbrQjsoGbMh6Aan 3cna/8U095i0I9dUQa0riomScPO6Q/lqcpxcOSl+uDEjuPfhSmucgBGsR/mHu+Ic 1a3OuvaCN55zsJ1P1+CxtlCvRENQ= 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:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=MgIBxGzUmm3m35bddHm9gZehhfoMe+D3mSvvifuckTTOFrA7iDzsMU1iDjEpzN qFMN99myxYS9yrf4K4d3XvmXezpqUDS0hFzTacjJOlVC4JXIR8PnFKxo+2614D1U X/m9Bx+SHIyo31+N+Wb/glW++THsT/l0n6bTAJoUN6bPo=; Received: (qmail 25662 invoked by alias); 16 Oct 2012 23:53:22 -0000 Received: (qmail 25654 invoked by uid 22791); 16 Oct 2012 23:53:21 -0000 X-SWARE-Spam-Status: No, hits=-7.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Tue, 16 Oct 2012 23:53:12 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9GNrAAt005138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 16 Oct 2012 19:53:10 -0400 Received: from reynosa.quesejoda.com (vpn-9-158.rdu.redhat.com [10.11.9.158]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9GNr89h014813; Tue, 16 Oct 2012 19:53:08 -0400 Message-ID: <507DF364.2010208@redhat.com> Date: Tue, 16 Oct 2012 19:53:08 -0400 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120911 Thunderbird/15.0.1 MIME-Version: 1.0 To: Ian Lance Taylor CC: gcc-patches , Richard Guenther , Ian Lance Taylor , Jakub Jelinek , Andrew MacLeod Subject: Re: [path] PR 54900: store data race in if-conversion pass References: <507C015F.2090508@redhat.com> In-Reply-To: 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 > I don't see a reason to add this new function. I would just inline it > into noce_can_store_speculate_p, replacing the call to > memory_modified_in_p. And I'm not sure I see a reason to change the > comment for memory_modified_in_p, it seems to already be accurate. My comment was just clearer to me, but probably because I wrote it :). I have revert it. > > Clearly we could consider the possibility of a PARALLEL of SET insns, > but of course most the compiler won't handle that anyhow. I suppose > that would be a reason to use memory_surely_modified_in_insn_p, but in > that case you might as well handle the PARALLEL case now. Done. Is this what you had in mind? Tested on x86-64 Linux by looking at the generated assembly for the testcase with a dominating write and without. Bootstrap and regtested as well. PR rtl-optimization/54900 * ifcvt.c (noce_can_store_speculate_p): Call memory_surely_modified_in_insn_p. * alias.c (memory_surely_modified_in_insn_p): New. (set_dest_equal_p): New. diff --git a/gcc/alias.c b/gcc/alias.c index 0c6a744..f28e9a6 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -2760,6 +2760,39 @@ memory_modified_in_insn_p (const_rtx mem, const_rtx insn) return memory_modified; } +/* Return TRUE if the destination of a set is rtx identical to + ITEM. */ +static inline bool +set_dest_equal_p (const_rtx set, const_rtx item) +{ + rtx dest = SET_DEST (set); + return rtx_equal_p (dest, item); +} + +/* Like memory_modified_in_insn_p, but return TRUE if INSN will + *SURELY* modify the memory contents of MEM. */ +bool +memory_surely_modified_in_insn_p (const_rtx mem, const_rtx insn) +{ + if (!INSN_P (insn)) + return false; + insn = PATTERN (insn); + if (GET_CODE (insn) == SET) + return set_dest_equal_p (insn, mem); + else if (GET_CODE (insn) == PARALLEL) + { + int i; + for (i = 0; i < XVECLEN (insn, 0); i++) + { + rtx sub = XVECEXP (insn, 0, i); + if (GET_CODE (sub) == SET + && set_dest_equal_p (sub, mem)) + return true; + } + } + return false; +} + /* Initialize the aliasing machinery. Initialize the REG_KNOWN_VALUE array. */ diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 2f486a2..659e464 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -2415,7 +2415,7 @@ noce_can_store_speculate_p (basic_block top_bb, const_rtx mem) || (CALL_P (insn) && (!RTL_CONST_CALL_P (insn))))) return false; - if (memory_modified_in_insn_p (mem, insn)) + if (memory_surely_modified_in_insn_p (mem, insn)) return true; if (modified_in_p (XEXP (mem, 0), insn)) return false; diff --git a/gcc/rtl.h b/gcc/rtl.h index cd5d435..d449ee1 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2614,6 +2614,7 @@ extern void init_alias_analysis (void); extern void end_alias_analysis (void); extern void vt_equate_reg_base_value (const_rtx, const_rtx); extern bool memory_modified_in_insn_p (const_rtx, const_rtx); +extern bool memory_surely_modified_in_insn_p (const_rtx, const_rtx); extern bool may_be_sp_based_p (rtx); extern rtx gen_hard_reg_clobber (enum machine_mode, unsigned int); extern rtx get_reg_known_value (unsigned int);