From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10109 invoked by alias); 10 Mar 2003 05:16:01 -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 10077 invoked by uid 71); 10 Mar 2003 05:16:01 -0000 Date: Mon, 10 Mar 2003 05:16:00 -0000 Message-ID: <20030310051601.10058.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-03/txt/msg00449.txt.bz2 List-Id: The following reply was made to PR c/7871; it has been noted by GNATS. From: Jim Wilson To: Richard Henderson Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, rz@linux-m68k.org, wilson@gcc.gnu.org Subject: Re: c/7871: ICE on legal code, global register variables problems Date: 10 Mar 2003 00:16:23 -0500 Let me recap a bit. The current code calls mark_set_1 (...CLOBBER...) and mark_used_regs. This causes CALL_INSNs to get a REG_UNDEAD note for a global_reg, which confuses combine into deleting the insn that initializes the global_reg. If I change this to mark_set_1 (...SET...), then there are no REG_DEAD/REG_UNUSED notes which is correct. However, there are LOG_LINKS from the insn that sets the global_reg to the CALL_INSN, and from the CALL_INSN to the insn that uses the global_reg. This causes combine to merge the 3 instructions together, and the result is that the first insn that sets the global_reg gets simplified away. This could perhaps be fixed by modifying combine to know that calls and global_regs are special. If I avoid calling mark_set_1, then there are no REG_DEAD/REG_UNUSED notes, but there is still a LOG_LINK from the first insn that sets the global_reg to the CALL_INSN. When combine merges an unrelated insn into the CALL_INSN, it sees a LOG_LINK that doesn't appear to belong on the CALL_INSN, so it moves it to the next insn which uses the global_reg. Combine then merges two instructions that set/use the global_reg, and the first global_reg set before the call disappears again. Thus it seems that in order to get the right behavior, we need to avoid adding any REG_NOTES or LOG_LINKS for global_regs. I had to go back to gcc-2.95.1 to find a compiler that worked for my two testcases, and it has this behavior. The change that broke it is: 2000-04-07 Richard Henderson * flow.c (loop_depth): Remove. (reg_next_use, cc0_live, mem_set_list): Replace with ... ... (mark_set_reg): Break out of mark_set_1. ... I didn't manage to find the mail message for this patch. This command cvs diff -p -r 1.247 -r 1.248 flow.c will show you the patch if you want to look at it. This is a large change that was mostly reorganizing code, but another thing it does is delete one line of code in mark_set_1 that handles global_regs like the frame pointer and arg pointer register. If I re-add this one line of code, then both testcases I have start working again. I am off on a trip, so it will be a while before I am able to continue working on this. 2003-03-10 James E Wilson * flow.c (mark_set_1): Handle global_regs like the frame pointer. Index: flow.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/flow.c,v retrieving revision 1.549 diff -p -r1.549 flow.c *** flow.c 28 Feb 2003 10:11:47 -0000 1.549 --- flow.c 10 Mar 2003 05:05:08 -0000 *************** mark_set_1 (pbi, code, reg, cond, insn, *** 2709,2714 **** --- 2709,2715 ---- #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM && ! (regno_first == ARG_POINTER_REGNUM && fixed_regs[regno_first]) #endif + && ! (regno_first < FIRST_PSEUDO_REGISTER && global_regs[regno_first]) ) { int some_was_live = 0, some_was_dead = 0;