From patchwork Thu Jun 28 18:06:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 167934 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 07FD3B6FFC for ; Fri, 29 Jun 2012 04:07:10 +1000 (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=1341511631; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=7Sy5Oow ULUv/pbn9NNkBT5LUMaw=; b=i1yPBSqLO7DlOe+43E8oQVXJ4X+TjpwL8xUf3QK KgAOxXbl5TGSsdROmR7eQtdvdDSxgGaEZSOVQ/k/BZW+9sIDSRx1n6LSeyp9Q8cM HERpzB7FOg8SdNIuTGTz6Hr+DMclZgLs1HIt4L5KXx/QeO23peq9faaL4e3GOTn0 Q1aw= 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:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=a1shScS81ha/adKuQMN9d5jxua3gk3Pv8EtbKPhODNdUpUVpjqjvspWAAhYA1A b0k2VhU8sw/tv2nhMUbe0yHcKVYayv8z0qxj322DxbW1B1zV6R9zvJVHiIcVnFuA SAfP89f4lwVFGGf/7agAZEsAMS5qbCRkGVXE6SFoFog18=; Received: (qmail 29399 invoked by alias); 28 Jun 2012 18:07:06 -0000 Received: (qmail 29382 invoked by uid 22791); 28 Jun 2012 18:07:04 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, MAY_BE_FORGED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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, 28 Jun 2012 18:06:45 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5SI6j8p019767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Jun 2012 14:06:45 -0400 Received: from toll.usersys.redhat.com (unused [10.15.16.165] (may be forged)) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5SI6hnI002027 for ; Thu, 28 Jun 2012 14:06:44 -0400 Message-ID: <4FEC9D2F.8090203@redhat.com> Date: Thu, 28 Jun 2012 14:06:39 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: gcc-patches Subject: [lra] a patch to fix last testsuite regression on x86/x86-64 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 The following patch fixes last GCC testsuite regression (in comparison with reload) on x86/x86-64 after last merge of trunk into lra. The patch actually implements recent Bernd's optimization (restoring an argument pseudo value from the call result) in LRA. The patch was successfully bootstrapped on x86/x86-64. Committed as rev. 189051. 2012-06-28 Vladimir Makarov * lra-constraints.c (inherit_in_ebb): Implement restoring argument pseudo value from the call result. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 189016) +++ lra-constraints.c (working copy) @@ -4344,7 +4344,7 @@ inherit_in_ebb (rtx head, rtx tail) { int i, src_regno, dst_regno; bool change_p, succ_p; - rtx prev_insn, next_usage_insns, set, first_insn, last_insn, next_insn; + rtx prev_insn, next_usage_insns, set, first_insn, last_insn, next_insn; enum reg_class cl; struct lra_insn_reg *reg; basic_block last_processed_bb, curr_bb = NULL; @@ -4354,7 +4354,6 @@ inherit_in_ebb (rtx head, rtx tail) bitmap_iterator bi; bool head_p, after_p; - change_p = false; curr_usage_insns_check++; reloads_num = calls_num = 0; @@ -4536,7 +4535,41 @@ inherit_in_ebb (rtx head, rtx tail) to_inherit[i].insns)) change_p = true; if (CALL_P (curr_insn)) - calls_num++; + { + rtx cheap, pat, dest, restore; + int regno, hard_regno; + + calls_num++; + if ((cheap = find_reg_note (curr_insn, + REG_RETURNED, NULL_RTX)) != NULL_RTX + && ((cheap = XEXP (cheap, 0)), true) + && (regno = REGNO (cheap)) >= FIRST_PSEUDO_REGISTER + && (hard_regno = reg_renumber[regno]) >= 0 + /* If there are pending saves/restores, the + optimization is not worth. */ + && usage_insns[regno].calls_num == calls_num - 1 + && TEST_HARD_REG_BIT (call_used_reg_set, hard_regno)) + { + /* Restore the pseudo from the call result as + REG_RETURNED note says that the pseudo value is + in the call result and the pseudo is an argument + of the call. */ + pat = PATTERN (curr_insn); + if (GET_CODE (pat) == PARALLEL) + pat = XVECEXP (pat, 0, 0); + dest = SET_DEST (pat); + start_sequence (); + emit_move_insn (cheap, copy_rtx (dest)); + restore = get_insns (); + end_sequence (); + lra_process_new_insns (curr_insn, NULL, restore, + "Inserting call parameter restore"); + /* We don't need to save/restore of the pseudo from + this call. */ + usage_insns[regno].calls_num = calls_num; + bitmap_set_bit (&check_only_regs, regno); + } + } to_inherit_num = 0; /* Process insn usages. */ for (reg = curr_id->regs; reg != NULL; reg = reg->next)