On Wed, 20 May 2009, Mark Mitchell wrote: > Richard Guenther wrote: > > >> void f(float *f, int *n) { > >> for (int i = 0; i < *n; ++i) { > >> f[i] *= 2; > >> } > >> } > > > The difference is if you want to sink a load from *n beyond the > > store to f[i] - in which case you ask if there is an anti-dependence > > which we cannot exclude in this case (no TBAA is allowed here). > > By "not allowed", you don't mean "would be an invalid optimization", but > rather "will no longer be done by GCC", right?
Right, not invalid in the above case but nevertheless no longer being done by GCC. This is to properly support int i; float f; void foo() { int *p = (int *)malloc(sizeof(int)); *p = 1; i = *p; float *q = (float *)p; *q = 2.0; f = *q; } where we need to avoid scheduling the store via *q before the load from *p. The above is valid as I read C99 6.5/6, it is an object with no declared type (obtained via malloc) and has type int due to the store via *p "for that access and for subsequent accesses _that do not modify the stored value_." (emphasis mine). So for objects without a declared type C can do "placement new" by simply storing with a different type. In C++ we of course have the usual placement new situations. Richard.