From patchwork Mon Nov 1 19:23:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 69830 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 38839B70DA for ; Tue, 2 Nov 2010 06:23:58 +1100 (EST) Received: (qmail 28967 invoked by alias); 1 Nov 2010 19:23:56 -0000 Received: (qmail 28959 invoked by uid 22791); 1 Nov 2010 19:23:55 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, 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; Mon, 01 Nov 2010 19:23:51 +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.13.8/8.13.8) with ESMTP id oA1JNo8d020733 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 1 Nov 2010 15:23:50 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oA1JNnWf027859 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 1 Nov 2010 15:23:49 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id oA1JNmWi024130 for ; Mon, 1 Nov 2010 20:23:48 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id oA1JNmJK024128 for gcc-patches@gcc.gnu.org; Mon, 1 Nov 2010 20:23:48 +0100 Date: Mon, 1 Nov 2010 20:23:48 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix -fcompare-debug issue in reload1 (PR debug/46252) Message-ID: <20101101192348.GB29412@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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 Hi! delete_dead_insn removes unused preceeding insn, but will not do that if there are debug insns in between. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-11-01 Jakub Jelinek PR debug/46252 * rtl.h (prev_real_nondebug_insn): New prototype. * emit-rtl.c (prev_real_nondebug_insn): New function. * reload1.c (delete_dead_insn): Use it instead of prev_real_insn. * cfgcleanup.c (try_head_merge_bb): Likewise. * gcc.dg/pr46252.c: New test. Jakub --- gcc/rtl.h.jj 2010-11-01 09:07:23.000000000 +0100 +++ gcc/rtl.h 2010-11-01 15:41:31.000000000 +0100 @@ -1751,6 +1751,7 @@ extern rtx prev_nonnote_nondebug_insn (r extern rtx next_nonnote_nondebug_insn (rtx); extern rtx prev_real_insn (rtx); extern rtx next_real_insn (rtx); +extern rtx prev_real_nondebug_insn (rtx); extern rtx prev_active_insn (rtx); extern rtx next_active_insn (rtx); extern int active_insn_p (const_rtx); --- gcc/emit-rtl.c.jj 2010-11-01 09:07:23.000000000 +0100 +++ gcc/emit-rtl.c 2010-11-01 15:41:01.000000000 +0100 @@ -3133,8 +3133,8 @@ next_real_insn (rtx insn) return insn; } -/* Return the last INSN, CALL_INSN or JUMP_INSN before INSN; - or 0, if there is none. This routine does not look inside +/* Return the last INSN, CALL_INSN, JUMP_INSN or DEBUG_INSN + before INSN; or 0, if there is none. This routine does not look inside SEQUENCEs. */ rtx @@ -3150,6 +3150,23 @@ prev_real_insn (rtx insn) return insn; } +/* Return the last INSN, CALL_INSN or JUMP_INSN before INSN; + or 0, if there is none. This routine does not look inside + SEQUENCEs. */ + +rtx +prev_real_nondebug_insn (rtx insn) +{ + while (insn) + { + insn = PREV_INSN (insn); + if (insn == 0 || NONDEBUG_INSN_P (insn)) + break; + } + + return insn; +} + /* Return the last CALL_INSN in the current list, or 0 if there is none. This routine does not look inside SEQUENCEs. */ --- gcc/reload1.c.jj 2010-11-01 09:07:24.000000000 +0100 +++ gcc/reload1.c 2010-11-01 15:39:21.000000000 +0100 @@ -2112,7 +2112,7 @@ spill_failure (rtx insn, enum reg_class static void delete_dead_insn (rtx insn) { - rtx prev = prev_real_insn (insn); + rtx prev = prev_real_nondebug_insn (insn); rtx prev_dest; /* If the previous insn sets a register that dies in our insn, delete it --- gcc/cfgcleanup.c.jj 2010-11-01 09:07:23.000000000 +0100 +++ gcc/cfgcleanup.c 2010-11-01 15:42:08.000000000 +0100 @@ -2054,9 +2054,7 @@ try_head_merge_bb (basic_block bb) max_match--; if (max_match == 0) return false; - do - e0_last_head = prev_real_insn (e0_last_head); - while (DEBUG_INSN_P (e0_last_head)); + e0_last_head = prev_real_nondebug_insn (e0_last_head); } if (max_match == 0) --- gcc/testsuite/gcc.dg/pr46252.c.jj 2010-11-01 16:12:22.000000000 +0100 +++ gcc/testsuite/gcc.dg/pr46252.c 2010-11-01 16:12:07.000000000 +0100 @@ -0,0 +1,15 @@ +/* PR debug/46252 */ +/* { dg-do compile } */ +/* { dg-options "-O -frerun-cse-after-loop -fno-tree-loop-optimize -funroll-loops -fcompare-debug" } */ + +void +foo (float *f) +{ + int i; + for (i = 0; i < 4; i++) + f[i] = i; + bar (); + for (i = 0; i < 4; i++) + if (f[i] != i) + __builtin_abort (); +}