From patchwork Tue Jul 13 09:41:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 58721 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 68765B6EFE for ; Tue, 13 Jul 2010 19:41:38 +1000 (EST) Received: (qmail 6009 invoked by alias); 13 Jul 2010 09:41:36 -0000 Received: (qmail 5987 invoked by uid 22791); 13 Jul 2010 09:41:34 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL, BAYES_50, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 13 Jul 2010 09:41:27 +0000 Received: (qmail 14510 invoked from network); 13 Jul 2010 09:41:25 -0000 Received: from unknown (HELO ?84.152.190.179?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 13 Jul 2010 09:41:25 -0000 Message-ID: <4C3C34B4.3070309@codesourcery.com> Date: Tue, 13 Jul 2010 11:41:08 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100625 Thunderbird/3.0.5 MIME-Version: 1.0 To: GCC Patches CC: "Vladimir N. Makarov" Subject: IRA patch: move clobbers downwards 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 This is an older patch I'm resubmitting. The scheduler can move reg clobbers away from the insns for which they were generated, generating a window during which IRA thinks the register is live when it isn't. This can cause unnecessary conflicts. The real problem here is that IRA does a backwards scan; just as in peep2, it would probably be better to use a forwards scan using REG_DEAD notes. However, I'm told it's expensive to create those. Bootstrapped and regression tested on i686-linux, also regression tested on ARM. Ok? Bernd * ira-lives.c (process_bb_node_lives): Move clobber insns downwards as much as possible before analyzing a basic block. Index: ira-lives.c =================================================================== --- ira-lives.c (revision 161371) +++ ira-lives.c (working copy) @@ -877,7 +877,7 @@ process_bb_node_lives (ira_loop_tree_nod int i, freq; unsigned int j; basic_block bb; - rtx insn; + rtx insn, prev; bitmap_iterator bi; bitmap reg_live_out; unsigned int px; @@ -925,6 +925,42 @@ process_bb_node_lives (ira_loop_tree_nod /* Invalidate all allocno_saved_at_call entries. */ last_call_num++; + /* Previous passes such as the first scheduling pass may have lengthened + the lifetime of pseudos by moving CLOBBER insns upwards. Undo this + here. */ + FOR_BB_INSNS_REVERSE_SAFE (bb, insn, prev) + { + rtx pat, next, reg; + if (!NONJUMP_INSN_P (insn) || insn == BB_END (bb)) + continue; + pat = PATTERN (insn); + if (GET_CODE (pat) != CLOBBER) + continue; + reg = XEXP (pat, 0); + if (!REG_P (reg) || REGNO (reg) < FIRST_PSEUDO_REGISTER) + continue; + next = insn; + while (next != BB_END (bb)) + { + next = NEXT_INSN (next); + if (!NONDEBUG_INSN_P (next)) + continue; + if (reg_mentioned_p (XEXP (pat, 0), PATTERN (next))) + break; + } + if (next == NEXT_INSN (insn)) + continue; + + NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); + PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); + + PREV_INSN (insn) = PREV_INSN (next); + NEXT_INSN (insn) = next; + + NEXT_INSN (PREV_INSN (next)) = insn; + PREV_INSN (next) = insn; + } + /* Scan the code of this basic block, noting which allocnos and hard regs are born or die.