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: gcc-patches Patches <gcc-patches at gcc dot gnu dot org>
- Cc: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- Date: Tue, 31 Aug 2004 15:40:00 -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> <173B5962-FAF3-11D8-BE87-00039351ED8A@physics.uc.edu> <20040831072104.GA1828@atrey.karlin.mff.cuni.cz>
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:
And here is the patch which I am testing to fix this.
Is this the right approach or is something else needed?
Oh, I did get something wrong because it did not bootsrap at all
because we were pulling out invariant SSA_NAME also which for the
hell of me I cannot figure out but anyways this patch works for me
and for the testcases which I was able to find.
I also filed another bug for an aliasing bug which I found when using
this patch which can be reproduced right now with "-O2 --param
lim-expensive=1".
OK? Bootstrapped and tested on powerpc-apple-darwin with no regressions.
This actually fixes PR 16803 and improves bzip2 in SPEC and most likely
others too but I did not check.
Thanks,
Andrew Pinski
ChangeLog
* tree-ssa-loop-im.c (stmt_cost): Gimple variables except
for SSA_NAMEs 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 20:55:14 -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) && TREE_CODE (rhs) != SSA_NAME)
cost += 20;
switch (TREE_CODE (rhs))