From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17673 invoked by alias); 26 Mar 2003 08:49:37 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 17627 invoked from network); 26 Mar 2003 08:49:36 -0000 Received: from unknown (HELO mta04bw.bigpond.com) (139.134.6.87) by sources.redhat.com with SMTP; 26 Mar 2003 08:49:36 -0000 Received: from bubble.local ([144.135.24.87]) by mta04bw.bigpond.com (Netscape Messaging Server 4.15 mta04bw Jul 16 2002 22:47:55) with SMTP id HCCLUL00.9NK for ; Wed, 26 Mar 2003 18:49:33 +1000 Received: from CPE-144-136-188-60.sa.bigpond.net.au ([144.136.188.60]) by bwmam07bpa.bigpond.com(MailRouter V3.2g 62/4286498); 26 Mar 2003 18:49:33 Received: (qmail 27441 invoked by uid 179); 26 Mar 2003 08:49:33 -0000 Date: Wed, 26 Mar 2003 10:36:00 -0000 From: Alan Modra To: gcc@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: REQ_EQUAL and mems hoisted out of loops Message-ID: <20030326084933.GU931@bubble.sa.bigpond.net.au> Mail-Followup-To: gcc@gcc.gnu.org, gcc-patches@gcc.gnu.org References: <20030325121216.GL931@bubble.sa.bigpond.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030325121216.GL931@bubble.sa.bigpond.net.au> User-Agent: Mutt/1.4i X-SW-Source: 2003-03/txt/msg01592.txt.bz2 On Tue, Mar 25, 2003 at 10:42:16PM +1030, Alan Modra wrote: > Oops, reg 145 has changed in the meantime at insn 41. From what I can > tell, the REG_EQUAL notes in combination with the fact that the store > to "y" has been moved out of the loop by loop optimization, is the cause > of cse confusion. > > So it seems a possible fix would be to delete all REG_EQUAL notes > that mention any mem hoisted out of a loop. Before I try to do that, > I thought I'd solicit comments on the approach. Reasonable? This cures the failures. Bootstrapped, regression tested powerpc-linux and powerpc64-linux on 3.3 branch. Currently testing on mainline. * loop.c: Include tree.h. (find_mem_in_note_1, find_mem_in_note): New functions. (load_mems): Remove invalid REG_EQUAL notes after hoisting. OK? Index: gcc/loop.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/loop.c,v retrieving revision 1.448 diff -u -p -r1.448 loop.c --- gcc/loop.c 15 Mar 2003 22:51:33 -0000 1.448 +++ gcc/loop.c 26 Mar 2003 08:40:23 -0000 @@ -39,6 +39,7 @@ Software Foundation, 59 Temple Place - S #include "coretypes.h" #include "tm.h" #include "rtl.h" +#include "tree.h" #include "tm_p.h" #include "function.h" #include "expr.h" @@ -328,6 +329,8 @@ static void update_reg_last_use PARAMS ( static rtx next_insn_in_loop PARAMS ((const struct loop *, rtx)); static void loop_regs_scan PARAMS ((const struct loop *, int)); static int count_insns_in_loop PARAMS ((const struct loop *)); +static int find_mem_in_note_1 PARAMS ((rtx *, void *)); +static rtx find_mem_in_note PARAMS ((rtx)); static void load_mems PARAMS ((const struct loop *)); static int insert_loop_mem PARAMS ((rtx *, void *)); static int replace_loop_mem PARAMS ((rtx *, void *)); @@ -9800,6 +9803,29 @@ count_insns_in_loop (loop) return count; } +static int +find_mem_in_note_1 (x, data) + rtx *x; + void *data; +{ + if (*x != NULL_RTX && GET_CODE (*x) == MEM) + { + rtx *res = (rtx *) data; + *res = *x; + return 1; + } + return 0; +} + +static rtx +find_mem_in_note (note) + rtx note; +{ + if (note && for_each_rtx (¬e, find_mem_in_note_1, ¬e)) + return note; + return NULL_RTX; +} + /* Move MEMs into registers for the duration of the loop. */ static void @@ -10130,6 +10156,25 @@ load_mems (loop) try_swap_copy_prop (loop, reg, j); }); CLEAR_REG_SET (&store_copies); + + /* If we hoist a mem write out of the loop, then REG_EQUAL + notes referring to the mem are no longer valid. */ + if (written) + { + for (p = next_insn_in_loop (loop, loop->scan_start); + p != NULL_RTX; + p = next_insn_in_loop (loop, p)) + { + rtx note, sub; + + if (INSN_P (p) + && (note = find_reg_note (p, REG_EQUAL, NULL_RTX)) + && (sub = find_mem_in_note (note)) + && alias_sets_conflict_p (MEM_ALIAS_SET (mem), + MEM_ALIAS_SET (sub))) + remove_note (p, note); + } + } } } -- Alan Modra IBM OzLabs - Linux Technology Centre