From patchwork Fri Aug 2 14:31:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 264295 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D81C62C0097 for ; Sat, 3 Aug 2013 00:31:58 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=E4GrheMqiZN9EX6bykiwgTeEwiOrLUXCWP4ab4HplcASJo H4/x7i8yKab5w/rfoFfo3uvZOnMFJqUP8UcvxgghqdBJEP6lrOjQuPQ6m37CeM2V 0+FKzS93rTpXs1pMY3lauvhl/nqNgX15AjMTVPWJO7LmMjCgaw6VC7YEs3bYY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=tycTNZD3CZaa5LB0OS7FsdRTdO4=; b=RnGTphV44R5sk9EzBydT dU1gBHuawpr7VqaxZcW27KXvsJZuvA1wcK7MH+0XXdJ9zVJ7MGR+4DcegP0MTN/4 sHP6oTLTVGQHowjOfACU9r+A/BhLlPHDkWnNVL6cx1a3l3cuFOHTwGlZiMheqrU7 ifkTNN4uOYth2zkRQJ8x1js= Received: (qmail 7156 invoked by alias); 2 Aug 2013 14:31:51 -0000 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 Received: (qmail 7147 invoked by uid 89); 2 Aug 2013 14:31:51 -0000 X-Spam-SWARE-Status: No, score=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.1 Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 02 Aug 2013 14:31:50 +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 r72EVgBV006488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Aug 2013 10:31:43 -0400 Received: from Mair.local (vpn-63-101.rdu2.redhat.com [10.10.63.101]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r72EVeC9013488 for ; Fri, 2 Aug 2013 10:31:41 -0400 Message-ID: <51FBC2CC.8000609@redhat.com> Date: Fri, 02 Aug 2013 10:31:40 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: GCC Patches Subject: patch to fix PR57963 (s390) X-Virus-Found: No The following patch fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57963 The page contains a good analysis of the PR from Andreas Krebbel. The patch was successfully bootstrapped and tested on x86/x86-64 and s390x. Committed as rev. 201438. 2013-08-02 Vladimir Makarov PR rtl-optimization/57963 * lra-constraints.c (reverse_equiv_p, contains_reloaded_insn_p): New. (lra_constraints): Use them. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 201435) +++ lra-constraints.c (working copy) @@ -3600,6 +3600,40 @@ init_insn_rhs_dead_pseudo_p (int regno) return false; } +/* Return TRUE if REGNO has a reverse equivalence. The equivalence is + reverse only if we have one init insn with given REGNO as a + source. */ +static bool +reverse_equiv_p (int regno) +{ + rtx insns, set; + + if ((insns = ira_reg_equiv[regno].init_insns) == NULL_RTX) + return false; + if (! INSN_P (XEXP (insns, 0)) + || XEXP (insns, 1) != NULL_RTX) + return false; + if ((set = single_set (XEXP (insns, 0))) == NULL_RTX) + return false; + return REG_P (SET_SRC (set)) && (int) REGNO (SET_SRC (set)) == regno; +} + +/* Return TRUE if REGNO was reloaded in an equivalence init insn. We + call this function only for non-reverse equivalence. */ +static bool +contains_reloaded_insn_p (int regno) +{ + rtx set; + rtx list = ira_reg_equiv[regno].init_insns; + + for (; list != NULL_RTX; list = XEXP (list, 1)) + if ((set = single_set (XEXP (list, 0))) == NULL_RTX + || ! REG_P (SET_DEST (set)) + || (int) REGNO (SET_DEST (set)) != regno) + return true; + return false; +} + /* Entry function of LRA constraint pass. Return true if the constraint pass did change the code. */ bool @@ -3643,7 +3677,6 @@ lra_constraints (bool first_p) else if ((x = get_equiv_substitution (reg)) != reg) { bool pseudo_p = contains_reg_p (x, false, false); - rtx set, insns; /* After RTL transformation, we can not guarantee that pseudo in the substitution was not reloaded which might @@ -3675,13 +3708,13 @@ lra_constraints (bool first_p) removed the insn. When the equiv can be a constant, the right hand side of the init insn can be a pseudo. */ - || (! ((insns = ira_reg_equiv[i].init_insns) != NULL_RTX - && INSN_P (XEXP (insns, 0)) - && XEXP (insns, 1) == NULL_RTX - && (set = single_set (XEXP (insns, 0))) != NULL_RTX - && REG_P (SET_SRC (set)) - && (int) REGNO (SET_SRC (set)) == i) - && init_insn_rhs_dead_pseudo_p (i)) + || (! reverse_equiv_p (i) + && (init_insn_rhs_dead_pseudo_p (i) + /* If we reloaded the pseudo in an equivalence + init insn, we can not remove the equiv init + insns and the init insns might write into + const memory in this case. */ + || contains_reloaded_insn_p (i))) /* Prevent access beyond equivalent memory for paradoxical subregs. */ || (MEM_P (x)