From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26187 invoked by alias); 20 Jul 2002 00:03:31 -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 26175 invoked from network); 20 Jul 2002 00:03:30 -0000 Received: from unknown (HELO potter.sfbay.redhat.com) (205.180.83.107) by sources.redhat.com with SMTP; 20 Jul 2002 00:03:30 -0000 Received: from dot.sfbay.redhat.com (dot.sfbay.redhat.com [172.16.24.7]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id g6K03xQ05712; Fri, 19 Jul 2002 17:03:59 -0700 Received: (from rth@localhost) by dot.sfbay.redhat.com (8.11.6/8.11.6) id g6K03Ui15764; Fri, 19 Jul 2002 17:03:30 -0700 X-Authentication-Warning: dot.sfbay.redhat.com: rth set sender to rth@redhat.com using -f Date: Sat, 20 Jul 2002 12:12:00 -0000 From: Richard Henderson To: Toon Moene , gcc@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Subject: Re: Alias analysis - does base_alias_check still work ? Message-ID: <20020719170330.A15734@redhat.com> Mail-Followup-To: Richard Henderson , Toon Moene , gcc@gcc.gnu.org, gcc-patches@gcc.gnu.org References: <3D346B28.47039CD9@moene.indiv.nluug.nl> <3D3824DA.B198DC39@moene.indiv.nluug.nl> <20020719095446.A15598@redhat.com> <3D38543D.F5D84797@moene.indiv.nluug.nl> <3D386E94.E6D03C8B@moene.indiv.nluug.nl> <20020719153514.B15706@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="opJtzjQTFsWo+cga" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020719153514.B15706@redhat.com>; from rth@redhat.com on Fri, Jul 19, 2002 at 03:35:14PM -0700 X-SW-Source: 2002-07/txt/msg00892.txt.bz2 --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 769 On Fri, Jul 19, 2002 at 03:35:14PM -0700, Richard Henderson wrote: > The remaining sts/lds pairs are writes then reads from SY. > We've lost track of the fact that the write is to index I > and the read from index I+1, and so cannot overlap. This appears to be the unroller doing stupid things. The attached patch1 should cure this. If this patch can be shown to be a win, we can axe this section of code properly rather than goto out of it. I also tried running the unroller during the first loop pass so that the second loop pass could clean up the giv lossage. This didn't work for this case, but I'd be interested in knowing what effect this has generically. I.e. a three-way benchmark comparison: with -fno-rerun-loop-opt without patch2 with patch2 r~ --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch1 Content-length: 1379 Index: unroll.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/unroll.c,v retrieving revision 1.169 diff -c -p -d -r1.169 unroll.c *** unroll.c 30 Jun 2002 05:06:01 -0000 1.169 --- unroll.c 19 Jul 2002 23:51:44 -0000 *************** find_splittable_givs (loop, bl, unroll_t *** 2867,2875 **** register to hold the split value of the DEST_ADDR giv. Emit insn to initialize its value before loop start. */ ! rtx tem = gen_reg_rtx (v->mode); ! struct induction *same = v->same; ! rtx new_reg = v->new_reg; record_base_value (REGNO (tem), v->add_val, 0); /* If the address giv has a constant in its new_reg value, --- 2867,2885 ---- register to hold the split value of the DEST_ADDR giv. Emit insn to initialize its value before loop start. */ ! rtx tem; ! struct induction *same; ! rtx new_reg; ! ! /* ??? This appears to be entirely crap. All it appears ! to do is scrog giv combination and confuse alias ! analysis such that it forgets that two DEST_ADDR ! givs have the same base register. */ ! continue; ! ! tem = gen_reg_rtx (v->mode); ! same = v->same; ! new_reg = v->new_reg; record_base_value (REGNO (tem), v->add_val, 0); /* If the address giv has a constant in its new_reg value, --opJtzjQTFsWo+cga Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch2 Content-length: 4243 Index: loop.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/loop.c,v retrieving revision 1.412 diff -c -p -d -r1.412 loop.c *** loop.c 19 Jul 2002 16:31:40 -0000 1.412 --- loop.c 19 Jul 2002 23:51:43 -0000 *************** strength_reduce (loop, flags) *** 5320,5326 **** collected. Always unroll loops that would be as small or smaller unrolled than when rolled. */ if ((flags & LOOP_UNROLL) ! || (!(flags & LOOP_FIRST_PASS) && loop_info->n_iterations > 0 && unrolled_insn_copies <= insn_count)) unroll_loop (loop, insn_count, 1); --- 5320,5326 ---- collected. Always unroll loops that would be as small or smaller unrolled than when rolled. */ if ((flags & LOOP_UNROLL) ! || ((flags & LOOP_AUTO_UNROLL) && loop_info->n_iterations > 0 && unrolled_insn_copies <= insn_count)) unroll_loop (loop, insn_count, 1); Index: loop.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/loop.h,v retrieving revision 1.61 diff -c -p -d -r1.61 loop.h *** loop.h 30 May 2002 20:55:11 -0000 1.61 --- loop.h 19 Jul 2002 23:51:43 -0000 *************** Software Foundation, 59 Temple Place - S *** 28,34 **** #define LOOP_UNROLL 1 #define LOOP_BCT 2 #define LOOP_PREFETCH 4 ! #define LOOP_FIRST_PASS 8 /* Get the loop info pointer of a loop. */ #define LOOP_INFO(LOOP) ((struct loop_info *) (LOOP)->aux) --- 28,34 ---- #define LOOP_UNROLL 1 #define LOOP_BCT 2 #define LOOP_PREFETCH 4 ! #define LOOP_AUTO_UNROLL 8 /* Get the loop info pointer of a loop. */ #define LOOP_INFO(LOOP) ((struct loop_info *) (LOOP)->aux) Index: toplev.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/toplev.c,v retrieving revision 1.658 diff -c -p -d -r1.658 toplev.c *** toplev.c 17 Jul 2002 03:03:40 -0000 1.658 --- toplev.c 19 Jul 2002 23:51:43 -0000 *************** *** 1,4 **** - /* Top level of GNU C compiler Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. --- 1,3 ---- *************** rest_of_compilation (decl) *** 2878,2883 **** --- 2877,2884 ---- if (optimize > 0 && flag_loop_optimize) { + int do_unroll, do_prefetch; + timevar_push (TV_LOOP); delete_dead_jumptables (); cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_PRE_LOOP); *************** rest_of_compilation (decl) *** 2885,2896 **** /* CFG is no longer maintained up-to-date. */ free_bb_for_insn (); if (flag_rerun_loop_opt) { cleanup_barriers (); /* We only want to perform unrolling once. */ ! loop_optimize (insns, rtl_dump_file, LOOP_FIRST_PASS); /* The first call to loop_optimize makes some instructions trivially dead. We delete those instructions now in the --- 2886,2900 ---- /* CFG is no longer maintained up-to-date. */ free_bb_for_insn (); + do_unroll = flag_unroll_loops ? LOOP_UNROLL : LOOP_AUTO_UNROLL; + do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0; if (flag_rerun_loop_opt) { cleanup_barriers (); /* We only want to perform unrolling once. */ ! loop_optimize (insns, rtl_dump_file, do_unroll); ! do_unroll = 0; /* The first call to loop_optimize makes some instructions trivially dead. We delete those instructions now in the *************** rest_of_compilation (decl) *** 2903,2911 **** reg_scan (insns, max_reg_num (), 1); } cleanup_barriers (); ! loop_optimize (insns, rtl_dump_file, ! (flag_unroll_loops ? LOOP_UNROLL : 0) | LOOP_BCT ! | (flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0)); /* Loop can create trivially dead instructions. */ delete_trivially_dead_insns (insns, max_reg_num ()); --- 2907,2913 ---- reg_scan (insns, max_reg_num (), 1); } cleanup_barriers (); ! loop_optimize (insns, rtl_dump_file, do_unroll | LOOP_BCT | do_prefetch); /* Loop can create trivially dead instructions. */ delete_trivially_dead_insns (insns, max_reg_num ()); --opJtzjQTFsWo+cga--