This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Improve lim for pulling loads from global variable out of loops
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: Andrew Pinski <pinskia at physics dot uc dot edu>,"gcc-patches at gcc dot gnu dot org Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 12 Nov 2004 16:09:02 +0100
- Subject: Re: [PATCH] Improve lim for pulling loads from global variable out of loops
- References: <1100271825.20892.2.camel@localhost.localdomain>
Hello,
> > * tree-ssa-loop-im.c (stmt_cost): Gimple variables should be
> > pulled out too as they cause memory accesses.
> >
> Your ChangeLog entry doesn't match the code. Also, testing only for
> is_gimple_addressable will not include global variables. You want to
> test is_global_var.
Diego, I think you are wrong in both points -- is_gimple_addressable
includes global variables (any variables, in fact), and the changelog
entry seems to match the change.
However the patch is wrong -- is_gimple_addressable also matches SSA
names. So the right patch should be
Index: tree-ssa-loop-im.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-im.c,v
retrieving revision 2.21
diff -c -3 -p -r2.21 tree-ssa-loop-im.c
*** tree-ssa-loop-im.c 8 Nov 2004 13:54:39 -0000 2.21
--- tree-ssa-loop-im.c 12 Nov 2004 11:29:40 -0000
*************** stmt_cost (tree stmt)
*** 367,373 ****
/* Hoisting memory references out should almost surely be a win. */
if (!is_gimple_variable (lhs))
cost += 20;
! if (is_gimple_addressable (rhs) && !is_gimple_variable (rhs))
cost += 20;
switch (TREE_CODE (rhs))
--- 367,373 ----
/* Hoisting memory references out should almost surely be a win. */
if (!is_gimple_variable (lhs))
cost += 20;
! if (is_gimple_addressable (rhs) && TREE_CODE (rhs) != SSA_NAME)
cost += 20;
switch (TREE_CODE (rhs))
Zdenek