From patchwork Fri May 24 15:34:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 246196 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 B59202C00AB for ; Sat, 25 May 2013 01:34: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=Tw+QMecggjaOWOYc36WIj7bZv8TvNOlLgooYl+bpb7i1Wj M9gvMN1nAn2ZWL7C9cuNLWcbJ9A3r67APmMNIyqXZ5X5Ys+bipfzcYuyYOY4TWjt OhON1fc4Hd5hv4ECtuzTmlFHA7MGgKmSAJGvG0d6RKWXWj0g0CG5hjUWIxnj4= 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=SKsakD7CMpcYvFip8yyR+zrUJiA=; b=HDsJKwrOArUytM+gO66m 5ob575VnQEnLNONURaFZHCeiIRkyYbT3LVbK5p0/jZV5TbHuRusAAZlF5RWzlTQT fEV0NW7pa2hxNhahjdZT9oOrPdmguIb/LW1XF5lr8iL8o4Ls+5V4IMuP1mRx0g5c 7Qz+6GNuK+TMARSWdw/I3wM= Received: (qmail 27094 invoked by alias); 24 May 2013 15:34:52 -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 27084 invoked by uid 89); 24 May 2013 15:34:52 -0000 X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 24 May 2013 15:34:51 +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 r4OFYobu023371 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 24 May 2013 11:34:50 -0400 Received: from Mair.local (vpn-62-68.rdu2.redhat.com [10.10.62.68]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4OFYnF3010302 for ; Fri, 24 May 2013 11:34:49 -0400 Message-ID: <519F8898.1020109@redhat.com> Date: Fri, 24 May 2013 11:34:48 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: GCC Patches Subject: a lra patch X-Virus-Found: No The following patch contains some changes needed for porting LRA to rs6000 and s390. The patch was successfully bootstrapped on x86/x86-64. Committed as rev. 199298. 2013-05-24 Vladimir Makarov * lra-constraints.c (emit_spill_move): Use smaller mode for mem-mem moves. (check_and_process_move): Consider mem-reg moves for secondary too. (curr_insn_transform): Don't lose insns emitted before for secondary memory moves. (inherit_in_ebb): Mark defined reg. Add usage only if it is not a reg set up in the current insn. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 199273) +++ lra-constraints.c (working copy) @@ -859,10 +859,20 @@ emit_spill_move (bool to_p, rtx mem_pseu { if (GET_MODE (mem_pseudo) != GET_MODE (val)) { - val = gen_rtx_SUBREG (GET_MODE (mem_pseudo), - GET_CODE (val) == SUBREG ? SUBREG_REG (val) : val, - 0); - LRA_SUBREG_P (val) = 1; + lra_assert (GET_MODE_SIZE (GET_MODE (mem_pseudo)) + >= GET_MODE_SIZE (GET_MODE (val))); + if (! MEM_P (val)) + { + val = gen_rtx_SUBREG (GET_MODE (mem_pseudo), + GET_CODE (val) == SUBREG ? SUBREG_REG (val) : val, + 0); + LRA_SUBREG_P (val) = 1; + } + else + { + mem_pseudo = gen_lowpart_SUBREG (GET_MODE (val), mem_pseudo); + LRA_SUBREG_P (mem_pseudo) = 1; + } } return (to_p ? gen_move_insn (mem_pseudo, val) @@ -890,7 +900,7 @@ check_and_process_move (bool *change_p, dreg = SUBREG_REG (dest); if (GET_CODE (src) == SUBREG) sreg = SUBREG_REG (src); - if (! REG_P (dreg) || ! REG_P (sreg)) + if (! (REG_P (dreg) || MEM_P (dreg)) || ! (REG_P (sreg) || MEM_P (sreg))) return false; sclass = dclass = NO_REGS; if (REG_P (dreg)) @@ -911,14 +921,22 @@ check_and_process_move (bool *change_p, if (sclass == ALL_REGS) /* See comments above. */ return false; + if (sclass == NO_REGS && dclass == NO_REGS) + return false; #ifdef SECONDARY_MEMORY_NEEDED - if (dclass != NO_REGS && sclass != NO_REGS - && SECONDARY_MEMORY_NEEDED (sclass, dclass, GET_MODE (src))) + if (SECONDARY_MEMORY_NEEDED (sclass, dclass, GET_MODE (src)) +#ifdef SECONDARY_MEMORY_NEEDED_MODE + && ((sclass != NO_REGS && dclass != NO_REGS) + || GET_MODE (src) != SECONDARY_MEMORY_NEEDED_MODE (GET_MODE (src))) +#endif + ) { *sec_mem_p = true; return false; } #endif + if (! REG_P (dreg) || ! REG_P (sreg)) + return false; sri.prev_sri = NULL; sri.icode = CODE_FOR_nothing; sri.extra_cost = 0; @@ -3006,16 +3024,22 @@ curr_insn_transform (void) /* If the target says specifically to use another mode for secondary memory moves we can not reuse the original insn. */ - after = emit_spill_move (false, new_reg, dest); - lra_process_new_insns (curr_insn, NULL_RTX, after, - "Inserting the sec. move"); - before = emit_spill_move (true, new_reg, src); - lra_process_new_insns (curr_insn, before, NULL_RTX, "Changing on"); - lra_set_insn_deleted (curr_insn); - } + after = emit_spill_move (false, new_reg, dest); + lra_process_new_insns (curr_insn, NULL_RTX, after, + "Inserting the sec. move"); + /* We may have non null BEFORE here (e.g. after address + processing. */ + push_to_sequence (before); + before = emit_spill_move (true, new_reg, src); + emit_insn (before); + before = get_insns (); + end_sequence (); + lra_process_new_insns (curr_insn, before, NULL_RTX, "Changing on"); + lra_set_insn_deleted (curr_insn); + } else if (dest == rld) - { - *curr_id->operand_loc[0] = new_reg; + { + *curr_id->operand_loc[0] = new_reg; after = emit_spill_move (false, new_reg, dest); lra_process_new_insns (curr_insn, NULL_RTX, after, "Inserting the sec. move"); @@ -3023,7 +3047,12 @@ curr_insn_transform (void) else { *curr_id->operand_loc[1] = new_reg; + /* See comments above. */ + push_to_sequence (before); before = emit_spill_move (true, new_reg, src); + emit_insn (before); + before = get_insns (); + end_sequence (); lra_process_new_insns (curr_insn, before, NULL_RTX, "Inserting the sec. move"); } @@ -3823,7 +3852,9 @@ struct usage_insns { /* If the value is equal to CURR_USAGE_INSNS_CHECK, then the member value INSNS is valid. The insns is chain of optional debug insns - and a finishing non-debug insn using the corresponding reg. */ + and a finishing non-debug insn using the corresponding reg. The + value is also used to mark the registers which are set up in the + current insn. The negated insn uid is used for this. */ int check; /* Value of global reloads_num at the last insn in INSNS. */ int reloads_num; @@ -4796,14 +4827,15 @@ inherit_in_ebb (rtx head, rtx tail) && (dst_regno < FIRST_PSEUDO_REGISTER || reg_renumber[dst_regno] >= 0))) { - /* Invalidate. */ + /* Invalidate and mark definitions. */ if (dst_regno >= FIRST_PSEUDO_REGISTER) - usage_insns[dst_regno].check = 0; + usage_insns[dst_regno].check = -(int) INSN_UID (curr_insn); else { nregs = hard_regno_nregs[dst_regno][reg->biggest_mode]; for (i = 0; i < nregs; i++) - usage_insns[dst_regno + i].check = 0; + usage_insns[dst_regno + i].check + = -(int) INSN_UID (curr_insn); } } } @@ -4864,8 +4896,10 @@ inherit_in_ebb (rtx head, rtx tail) = usage_insns[src_regno].insns) != NULL_RTX && NONDEBUG_INSN_P (curr_insn)) add_to_inherit (src_regno, next_usage_insns); - else - /* Add usages. */ + else if (usage_insns[src_regno].check + != -(int) INSN_UID (curr_insn)) + /* Add usages but only if the reg is not set up + in the same insn. */ add_next_usage_insn (src_regno, curr_insn, reloads_num); } else if (src_regno < FIRST_PSEUDO_REGISTER