From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32287 invoked by alias); 28 Feb 2003 03:26:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 32259 invoked by uid 71); 28 Feb 2003 03:26:00 -0000 Date: Fri, 28 Feb 2003 03:26:00 -0000 Message-ID: <20030228032600.32258.qmail@sources.redhat.com> To: wilson@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Jim Wilson Subject: Re: c/7871: ICE on legal code, global register variables problems Reply-To: Jim Wilson X-SW-Source: 2003-02/txt/msg01473.txt.bz2 List-Id: The following reply was made to PR c/7871; it has been noted by GNATS. From: Jim Wilson To: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, rz@linux-m68k.org, wilson@gcc.gnu.org, rth@redhat.com Cc: Subject: Re: c/7871: ICE on legal code, global register variables problems Date: Thu, 27 Feb 2003 22:23:53 -0500 This is a multi-part message in MIME format. --------------060600050902010009060203 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7871 PR 7871 was broken by this patch from Richard Henderson http://gcc.gnu.org/ml/gcc-patches/2001-07/msg01050.html This PR uses a global register, and a store to the global register before a call gets deleted as a dead store. The problem with this patch is that it doesn't distinguish between regsters which are definitely set by calls, and registers which might be set by calls. In both cases, we can't do optimizations like cse across the call. However, only in the former case can we delete stores before the call as dead. In the latter case, a store before the call is not dead, because the register might not be set in the call. I think every part of the patch is right except for the flow.c change. The flow.c change marks global regs as killed by calls which is not correct. They might be killed, but we can't assume that, because then we might delete a store that isn't dead. I propose the following patch to fix the bug. I will check it in after running the tests, and add the testcase to the testsuite if there isn't already an equivalent one. Jim --------------060600050902010009060203 Content-Type: text/plain; name="tmp.file" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tmp.file" 2003-02-27 James E Wilson * flow.c (propagate_one_insn): Don't assume that calls set global registers. Index: flow.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/flow.c,v retrieving revision 1.548 diff -p -r1.548 flow.c *** flow.c 31 Jan 2003 06:52:48 -0000 1.548 --- flow.c 28 Feb 2003 03:14:51 -0000 *************** propagate_one_insn (pbi, insn) *** 1798,1806 **** mark_set_1 (pbi, CLOBBER, XEXP (XEXP (note, 0), 0), cond, insn, pbi->flags); ! /* Calls change all call-used and global registers. */ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) ! if (TEST_HARD_REG_BIT (regs_invalidated_by_call, i)) { /* We do not want REG_UNUSED notes for these registers. */ mark_set_1 (pbi, CLOBBER, regno_reg_rtx[i], cond, insn, --- 1798,1810 ---- mark_set_1 (pbi, CLOBBER, XEXP (XEXP (note, 0), 0), cond, insn, pbi->flags); ! /* Calls change all call-used registers. Calls may or may not ! change global registers. Since this will cause previous stores ! to be deleted as dead, we must assume that global registers are ! not set in the call. */ for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) ! if (TEST_HARD_REG_BIT (regs_invalidated_by_call, i) ! && ! global_regs[i]) { /* We do not want REG_UNUSED notes for these registers. */ mark_set_1 (pbi, CLOBBER, regno_reg_rtx[i], cond, insn, --------------060600050902010009060203--