------- Comment #133 from mark at codesourcery dot com 2007-05-23 19:43 -------
Subject: Re: [4.0/4.1/4.2/4.3 Regression] placement
new does not change the dynamic type as it should
ian at airs dot com wrote:
> The case where TBAA is most useful is on a deeply pipelined in-order processor
> with multiple function units and a high latency memory cache. One example
> I've
> worked on is an embedded VLIW processor with vector instructions. TBAA is of
> relatively little interest on an out-of-order processor.
The original motivating case for me was stuff like:
void f (int *a, double *d) {
for (int i = 1; i < N; ++i) {
a[i] += i;
d[i] = d[i-1] * a[i];
}
}
That's not the right code, but the point is that TBAA can allow us to
avoid reloading d[i-1] from one iteration to the next, despite the store
to a[i]. That reduces memory access and instruction count. Ordinary
PTA does not allow this.
Of course, Gaby's memory model doesn't allow this optimization either;
we have to worry that "a" and "d" are both in some union somewhere.
That's why Gaby's model is so bad from an optimization point of view; it
makes the compiler assume a worst-case situation, even though that
worst-case situation almost never actually happens.
I'm not an expert on CPU models, so I'm not sure how out-of-order vs.
in-order might matter here.
> And I think we see the outlines of a
> successful patch: make placement new return a pointer which effectively
> aliases
> everything. That will permit us to reorder loads and eliminate dead stores.
> It won't permit us to arbitrarily re-order loads and stores, but I'm skeptical
> that that will count as a severe penalty.
That's exactly what I think.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29286