This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Not pulling out obvious non-aliasing global from the loop
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>, Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Cc: gcc-patches Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 30 Aug 2004 19:11:38 -0700
- Subject: Re: Not pulling out obvious non-aliasing global from the loop
- References: <A4945A7C-F710-11D8-A009-00039351ED8A@physics.uc.edu> <76B15E29-FAD8-11D8-BE87-00039351ED8A@physics.uc.edu>
On Aug 30, 2004, at 4:01 PM, Andrew Pinski wrote:
On Aug 25, 2004, at 8:33 PM, Andrew Pinski wrote:
While working on a loop pass, I noticed that we were not pulling out
the load
from a global variable from a loop where it obviously cannot alias
anything in
the loop. This seems like it would hurt the vectorizer also.
This example comes from bzip2:
unsigned short *q;
#define NOSB 10
void h1(int last)
{
int i;
for (i=0;i<last+NOSB;i++)
q[i] = 0;
}
Tree after lim:
I looked at this again with respect to lim and found that lim was doing
invariant load motion because the cost was not high enough, I think
we need to change the cost for this case even though it increases
register pressure as we then can do other optimizations on the loop
which
actually decrease it and maybe even vectorize the loop.
And here is the patch which I am testing to fix this.
Is this the right approach or is something else needed?
Thanks,
Andrew Pinski
ChangeLog:
* tree-ssa-loop-im.c (stmt_cost): Gimple variables should be
pulled out too as they cause memory accesses.
Index: tree-ssa-loop-im.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-im.c,v
retrieving revision 2.7
diff -u -p -r2.7 tree-ssa-loop-im.c
--- tree-ssa-loop-im.c 25 Aug 2004 21:21:17 -0000 2.7
+++ tree-ssa-loop-im.c 31 Aug 2004 02:10:12 -0000
@@ -350,7 +350,7 @@ stmt_cost (tree stmt)
/* 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))
+ if (is_gimple_addressable (rhs))
cost += 20;
switch (TREE_CODE (rhs))