From patchwork Thu Oct 27 13:18:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 122157 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 406D21007D8 for ; Fri, 28 Oct 2011 00:19:17 +1100 (EST) Received: (qmail 27279 invoked by alias); 27 Oct 2011 13:19:15 -0000 Received: (qmail 27270 invoked by uid 22791); 27 Oct 2011 13:19:14 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_FW, TW_TM, 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; Thu, 27 Oct 2011 13:18:56 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p9RDItI8013015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 27 Oct 2011 09:18:55 -0400 Received: from freie.oliva.athome.lsd.ic.unicamp.br (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p9RDIr2x024017 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 27 Oct 2011 09:18:55 -0400 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie.oliva.athome.lsd.ic.unicamp.br (8.14.4/8.14.4) with ESMTP id p9RDIrTv011015 for ; Thu, 27 Oct 2011 11:18:53 -0200 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p9RDIqsI006685; Thu, 27 Oct 2011 11:18:52 -0200 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id p9RDIpj8006683; Thu, 27 Oct 2011 11:18:52 -0200 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: fwprop: fix REG_DEAD notes rendered incorrect Date: Thu, 27 Oct 2011 11:18:51 -0200 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 fwprop may propagate a SET_SRC that contains the last use of a REG to a later point, but it will leave the REG_DEAD note in place, even though it is no longer correct. I noticed this while investigating PR50826: the initialization of the internal_arg_pointer has a REG_DEAD note for %r29, but even after it is fwpropped, the note remains there. This patch fixes this bug. It also reduces the risk of code divergence in VTA-enabled compilations, by enabling the simpler test in all_uses_available_at when there are debug insns between the def and the use. Regstrapped on x86_64-linux-gnu and i686-linux-gnu. Ok to install? for gcc/ChangeLog from Alexandre Oliva * fwprop.c (all_uses_available_at): Skip debug insns. (try_fwprop_subst): Drop outdated REG_DEAD notes. Index: gcc/fwprop.c =================================================================== --- gcc/fwprop.c.orig 2011-10-26 06:37:08.154321512 -0200 +++ gcc/fwprop.c 2011-10-26 06:52:44.163150398 -0200 @@ -801,7 +801,7 @@ all_uses_available_at (rtx def_insn, rtx /* If target_insn comes right after def_insn, which is very common for addresses, we can use a quicker test. */ - if (NEXT_INSN (def_insn) == target_insn + if (next_nondebug_insn (def_insn) == target_insn && REG_P (SET_DEST (def_set))) { rtx def_reg = SET_DEST (def_set); @@ -1019,6 +1019,22 @@ try_fwprop_subst (df_ref use, rtx *loc, } } + if (ok) + { + rtx *link = ®_NOTES (def_insn); + + while (*link) + if (REG_NOTE_KIND (*link) == REG_DEAD + && reg_mentioned_p (XEXP (*link, 0), new_rtx)) + /* We could propagate the REG_DEAD note if we knew we're + propagating into what will become a death point. + Considering multiple uses in different BBs, some of which + may be debug uses requiring debug stmts to be introduced, + how about we just let DF take care of it? */ + *link = XEXP (*link, 1); + else + link = &XEXP (*link, 1); + } if ((ok || note) && !CONSTANT_P (new_rtx)) update_df (insn, note);