From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31737 invoked by alias); 19 Jul 2002 22:35:15 -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 31730 invoked from network); 19 Jul 2002 22:35:15 -0000 Received: from unknown (HELO potter.sfbay.redhat.com) (205.180.83.107) by sources.redhat.com with SMTP; 19 Jul 2002 22:35:15 -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 g6JMZhQ05485; Fri, 19 Jul 2002 15:35:43 -0700 Received: (from rth@localhost) by dot.sfbay.redhat.com (8.11.6/8.11.6) id g6JMZEV15730; Fri, 19 Jul 2002 15:35:14 -0700 X-Authentication-Warning: dot.sfbay.redhat.com: rth set sender to rth@redhat.com using -f Date: Sat, 20 Jul 2002 12:05:00 -0000 From: Richard Henderson To: Toon Moene Cc: gcc@gcc.gnu.org Subject: Re: Alias analysis - does base_alias_check still work ? Message-ID: <20020719153514.B15706@redhat.com> Mail-Followup-To: Richard Henderson , Toon Moene , gcc@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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <3D386E94.E6D03C8B@moene.indiv.nluug.nl>; from toon@moene.indiv.nluug.nl on Fri, Jul 19, 2002 at 09:55:00PM +0200 X-SW-Source: 2002-07/txt/msg00890.txt.bz2 On Fri, Jul 19, 2002 at 09:55:00PM +0200, Toon Moene wrote: > Well, it obviously doesn't work on the Alpha. First of all I have to > specify -fno-rerun-loop-opts to get any loop unrolling at all, and then the > unrolled loop looks like this: Havn't looked at what exactly goes wrong with rerun-loop-opts, except to notice that loop loses track of the register that contains the iteration count. As for the aliasing, the problem is that Alpha doesn't have indexed addressing, so we wind up with the base addresses being strength reduced, and presumably that confuses the alias analysis code enough that it considers the memory references to be "variable", and thus may alias anything. One solution is to make use of the new MEM_EXPR field and record this information such that it can't (or shouldn't) get lost ever. Try the following. For me it cleans up the example a bit: $L6: lds $f10,0($18) lds $f12,-4($3) lda $1,-3($5) lda $5,-4($5) lds $f11,4($18) lds $f13,8($18) addl $1,$31,$4 lds $f14,12($18) lda $18,16($18) muls $f15,$f10,$f10 muls $f15,$f11,$f11 muls $f15,$f13,$f13 muls $f15,$f14,$f14 adds $f12,$f10,$f12 sts $f12,-4($2) lds $f10,0($3) adds $f10,$f11,$f10 sts $f10,0($2) lds $f11,4($3) adds $f11,$f13,$f11 sts $f11,4($2) lds $f10,8($3) lda $3,16($3) adds $f10,$f14,$f10 sts $f10,8($2) lda $2,16($2) bge $4,$L6 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. r~ Index: alias.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/alias.c,v retrieving revision 1.177 diff -c -p -d -r1.177 alias.c *** alias.c 20 Jun 2002 07:29:59 -0000 1.177 --- alias.c 19 Jul 2002 22:23:34 -0000 *************** nonoverlapping_memrefs_p (x, y) *** 1957,1962 **** --- 1957,1970 ---- moffsetx = adjust_offset_for_component_ref (exprx, moffsetx); exprx = t; } + else if (TREE_CODE (exprx) == INDIRECT_REF) + { + exprx = TREE_OPERAND (exprx, 0); + if (flag_argument_noalias < 2 + || TREE_CODE (exprx) != PARM_DECL) + return 0; + } + moffsety = MEM_OFFSET (y); if (TREE_CODE (expry) == COMPONENT_REF) { *************** nonoverlapping_memrefs_p (x, y) *** 1965,1970 **** --- 1973,1985 ---- return 0; moffsety = adjust_offset_for_component_ref (expry, moffsety); expry = t; + } + else if (TREE_CODE (expry) == INDIRECT_REF) + { + expry = TREE_OPERAND (expry, 0); + if (flag_argument_noalias < 2 + || TREE_CODE (expry) != PARM_DECL) + return 0; } if (! DECL_P (exprx) || ! DECL_P (expry)) Index: emit-rtl.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v retrieving revision 1.284 diff -c -p -d -r1.284 emit-rtl.c *** emit-rtl.c 11 Jul 2002 10:32:54 -0000 1.284 --- emit-rtl.c 19 Jul 2002 22:23:34 -0000 *************** set_mem_attributes (ref, t, objectp) *** 1805,1811 **** } while (TREE_CODE (t) == ARRAY_REF); ! if (TREE_CODE (t) == COMPONENT_REF) { expr = component_ref_for_mem_expr (t); if (host_integerp (off_tree, 1)) --- 1805,1821 ---- } while (TREE_CODE (t) == ARRAY_REF); ! if (DECL_P (t)) ! { ! expr = t; ! if (host_integerp (off_tree, 1)) ! offset = GEN_INT (tree_low_cst (off_tree, 1)); ! size = (DECL_SIZE_UNIT (t) ! && host_integerp (DECL_SIZE_UNIT (t), 1) ! ? GEN_INT (tree_low_cst (DECL_SIZE_UNIT (t), 1)) : 0); ! align = DECL_ALIGN (t); ! } ! else if (TREE_CODE (t) == COMPONENT_REF) { expr = component_ref_for_mem_expr (t); if (host_integerp (off_tree, 1)) *************** set_mem_attributes (ref, t, objectp) *** 1813,1818 **** --- 1823,1845 ---- /* ??? Any reason the field size would be different than the size we got from the type? */ } + else if (flag_argument_noalias > 1 + && TREE_CODE (t) == INDIRECT_REF + && TREE_CODE (TREE_OPERAND (t, 0)) == PARM_DECL) + { + expr = t; + offset = NULL; + } + } + + /* If this is a Fortran indirect argument reference, record the + parameter decl. */ + else if (flag_argument_noalias > 1 + && TREE_CODE (t) == INDIRECT_REF + && TREE_CODE (TREE_OPERAND (t, 0)) == PARM_DECL) + { + expr = t; + offset = NULL; } } Index: print-rtl.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/print-rtl.c,v retrieving revision 1.84 diff -c -p -d -r1.84 print-rtl.c *** print-rtl.c 18 Jun 2002 20:12:13 -0000 1.84 --- print-rtl.c 19 Jul 2002 22:23:34 -0000 *************** print_mem_expr (outfile, expr) *** 92,97 **** --- 92,103 ---- fprintf (outfile, ".%s", IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (expr, 1)))); } + else if (TREE_CODE (expr) == INDIRECT_REF) + { + fputs (" (*", outfile); + print_mem_expr (outfile, TREE_OPERAND (expr, 0)); + fputs (")", outfile); + } else if (DECL_NAME (expr)) fprintf (outfile, " %s", IDENTIFIER_POINTER (DECL_NAME (expr))); else if (TREE_CODE (expr) == RESULT_DECL)