From patchwork Fri Oct 1 22:14:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 66526 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 F3205B710F for ; Sat, 2 Oct 2010 08:14:57 +1000 (EST) Received: (qmail 21767 invoked by alias); 1 Oct 2010 22:14:55 -0000 Received: (qmail 21754 invoked by uid 22791); 1 Oct 2010 22:14:54 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS 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; Fri, 01 Oct 2010 22:14:49 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o91MEm4t011816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 1 Oct 2010 18:14:48 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o91MEhoH007197 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 1 Oct 2010 18:14:47 -0400 Received: from livre.localdomain (livre.oliva.athome.lsd.ic.unicamp.br [172.31.160.2]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.4/8.14.4) with ESMTP id o91MEgwp016738 for ; Fri, 1 Oct 2010 19:14:43 -0300 Received: from livre.localdomain (aoliva@localhost [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o91MEfq3023670; Fri, 1 Oct 2010 19:14:41 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id o91MEdsG023668; Fri, 1 Oct 2010 19:14:39 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: [PR debug/45656] Don't let BB-trailing debug insns break cc0 cse Date: Fri, 01 Oct 2010 19:14:38 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 presence of debug insns at the end of a block may change CC0-specific behavior of cse. Also, debug insns should be skipped between CC0 setter and user, rather than reset the cc0 status. H-P Nilsson confirms this patch fixes the problem he ran into, and doesn't introduce regressions on cris-elf. Also regstrapped (along with other patches) on x86_64-linux-gnu and i686-pc-linux-gnu. Useless, I know, no CC0 there ;-) Ok to install? for gcc/ChangeLog from Alexandre Oliva PR debug/45656 * cse.c (cse_extended_basic_block): Preserve cc0 info across debug isnsn. Skip them when searching for cc0 setter. (set_live_p): Skip debug insns when searching for cc0 user. Index: gcc/cse.c =================================================================== --- gcc/cse.c.orig 2010-09-21 06:53:10.268422325 -0300 +++ gcc/cse.c 2010-09-21 06:59:33.104422820 -0300 @@ -6348,29 +6348,30 @@ cse_extended_basic_block (struct cse_bas recorded_label_ref = true; #ifdef HAVE_cc0 - /* If the previous insn set CC0 and this insn no longer - references CC0, delete the previous insn. Here we use - fact that nothing expects CC0 to be valid over an insn, - which is true until the final pass. */ - { - rtx prev_insn, tem; - - prev_insn = PREV_INSN (insn); - if (prev_insn && NONJUMP_INSN_P (prev_insn) - && (tem = single_set (prev_insn)) != 0 - && SET_DEST (tem) == cc0_rtx - && ! reg_mentioned_p (cc0_rtx, PATTERN (insn))) - delete_insn (prev_insn); - } - - /* If this insn is not the last insn in the basic block, - it will be PREV_INSN(insn) in the next iteration. If - we recorded any CC0-related information for this insn, - remember it. */ - if (insn != BB_END (bb)) + if (!DEBUG_INSN_P (insn) || insn == BB_END (bb)) { - prev_insn_cc0 = this_insn_cc0; - prev_insn_cc0_mode = this_insn_cc0_mode; + /* If the previous insn set CC0 and this insn no longer + references CC0, delete the previous insn. Here we use + fact that nothing expects CC0 to be valid over an insn, + which is true until the final pass. */ + rtx prev_insn, tem; + + prev_insn = prev_nonnote_nondebug_insn (insn); + if (prev_insn && NONJUMP_INSN_P (prev_insn) + && (tem = single_set (prev_insn)) != NULL_RTX + && SET_DEST (tem) == cc0_rtx + && ! reg_mentioned_p (cc0_rtx, PATTERN (insn))) + delete_insn (prev_insn); + + /* If this insn is not the last insn in the basic block, + it will be PREV_INSN(insn) in the next iteration. If + we recorded any CC0-related information for this insn, + remember it. */ + if (!DEBUG_INSN_P (insn) && insn != BB_END (bb)) + { + prev_insn_cc0 = this_insn_cc0; + prev_insn_cc0_mode = this_insn_cc0_mode; + } } #endif } @@ -6713,7 +6714,7 @@ set_live_p (rtx set, rtx insn ATTRIBUTE_ #ifdef HAVE_cc0 else if (GET_CODE (SET_DEST (set)) == CC0 && !side_effects_p (SET_SRC (set)) - && ((tem = next_nonnote_insn (insn)) == 0 + && ((tem = next_nonnote_nondebug_insn (insn)) == NULL_RTX || !INSN_P (tem) || !reg_referenced_p (cc0_rtx, PATTERN (tem)))) return false;