From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 929 invoked by alias); 9 Feb 2008 20:59:33 -0000 Received: (qmail 921 invoked by uid 22791); 9 Feb 2008 20:59:32 -0000 X-Spam-Check-By: sourceware.org Received: from hiauly1.hia.nrc.ca (HELO hiauly1.hia.nrc.ca) (132.246.100.193) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 09 Feb 2008 20:59:16 +0000 Received: from hiauly1.hia.nrc.ca (hiauly1.hia.nrc.ca [127.0.0.1] (may be forged)) by hiauly1.hia.nrc.ca (8.14.1/8.14.1) with ESMTP id m19Kx7of022348; Sat, 9 Feb 2008 15:59:12 -0500 (EST) Received: (from dave@localhost) by hiauly1.hia.nrc.ca (8.14.1/8.14.1/Submit) id m19Kx66u022347; Sat, 9 Feb 2008 15:59:06 -0500 (EST) Message-Id: <200802092059.m19Kx66u022347@hiauly1.hia.nrc.ca> Subject: Re: RFC: Fix PR middle-end/34150 -- Lost LABEL_NUSES counts To: dave@hiauly1.hia.nrc.ca (John David Anglin) Date: Sat, 09 Feb 2008 22:03:00 -0000 From: "John David Anglin" Cc: gcc-patches@gcc.gnu.org In-Reply-To: from "John David Anglin" at Jan 23, 2008 10:12:45 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2008-02/txt/msg00291.txt.bz2 > The attached patch is a target specific fix for PR middle-end/34150. > Is this the right approach, or should reload handle this? I have convinced myself that this is the right approach. alpha.md has a postreload split that handles LABEL_REFs in a similar manner. I checked the lreg and greg rtl dumps for the testcase in the PR. We now have identical REG_NOTES when setting a register with a LABEL_REF after lreg and greg. Similarly, the LABEL_NUSES counts for nonlocal goto labels agree. The patch has been tested on hppa-unknown-linux-gnu and hppa64-hp-hpux11.11. Committed to all active branches. Dave -- J. David Anglin dave.anglin@nrc-cnrc.gc.ca National Research Council of Canada (613) 990-0752 (FAX: 952-6602) 2008-02-09 John David Anglin PR middle_end/34150 * pa.c (legitimize_pic_address): Add REG_EQUAL note on sets with a pic_label_operand source. Similarly, add a REG_LABEL_OPERAND note and update LABEL_NUSES during and after reload. Index: config/pa/pa.c =================================================================== --- config/pa/pa.c (revision 132195) +++ config/pa/pa.c (working copy) @@ -668,6 +668,8 @@ /* Labels need special handling. */ if (pic_label_operand (orig, mode)) { + rtx insn; + /* We do not want to go through the movXX expanders here since that would create recursion. @@ -678,7 +680,24 @@ So instead we just emit the raw set, which avoids the movXX expanders completely. */ mark_reg_pointer (reg, BITS_PER_UNIT); - emit_insn (gen_rtx_SET (VOIDmode, reg, orig)); + insn = emit_insn (gen_rtx_SET (VOIDmode, reg, orig)); + + /* Put a REG_EQUAL note on this insn, so that it can be optimized. */ + REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_EQUAL, orig, REG_NOTES (insn)); + + /* During and after reload, we need to generate a REG_LABEL_OPERAND note + and update LABEL_NUSES because this is not done automatically. */ + if (reload_in_progress || reload_completed) + { + /* Extract LABEL_REF. */ + if (GET_CODE (orig) == CONST) + orig = XEXP (XEXP (orig, 0), 0); + /* Extract CODE_LABEL. */ + orig = XEXP (orig, 0); + REG_NOTES (insn) = gen_rtx_INSN_LIST (REG_LABEL_OPERAND, orig, + REG_NOTES (insn)); + LABEL_NUSES (orig)++; + } current_function_uses_pic_offset_table = 1; return reg; }