On Jun 29, 2006, at 9:20 AM, Paolo Bonzini wrote:
Well, G is known to escape anyway here. Even worse is this:
...
where there is not even the possibility to optimize *P1 in foo.
While compiling f1.c, the compiler does not even know that G
escapes and must assume the worse.
It's a different story for static variables or for -fwhole-program,
but then the compiler (as for the second load from *P1) can
optimize the third load anyway, independent of whether P1 is const
or not.
If the compiler has such a detailed knowledge of aliasing, why would
it have to depend on "const"? Assuming "const" were safe for the
compiler to use (which it isn't, obviously), it would only add value
if the compiler didn't have perfect knowledge of aliases already.
-Chris