[Bug rtl-optimization/20367] alias analysis doesn't take into account that variables that haven't their address taken can't alias arbitrary MEMs

amylaar at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Mar 8 05:08:00 GMT 2005


------- Additional Comments From amylaar at gcc dot gnu dot org  2005-03-08 05:08 -------
(In reply to comment #5)
> The testcase given above is already optimizated on the mainline via some of
the aliasing code on the 
> tree level but still needs to be more, witness 19905 or even the following
testcase which is basically 
> 19905 still:
> void g();
> int
> f(int s, int *a)
> {
>   static int i;
>   for (i = 0; i < 800; i++)
>   {
>     g();
>     s += a[i];
>   }
>   return s;
> }
> 
> But all of this needs to be on the tree level to be really effective.

You can't optimize this because g is not pure.  g might call f.
But I had some real-life code that did allow the optimization inside a loop,
but prevented completely changing the static variable because of non-pure
function callsabove and below the loop.  IIRC the static variable was not
initialized right before the loop, but earlier in the function, so if you
really had some recursion, fun things would happen.  As a matter of fact,
an early version of my patch failed to take recursion into account, and we
found a few months later that rm got miscompiled because it uses indirect
recusion and static variables in a rather interesting way.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20367



More information about the Gcc-bugs mailing list