This is the mail archive of the
mailing list for the GCC project.
Re: Optimization of conditional access to globals: thread-unsafe?
On Fri, 2007-10-26 at 17:19 -0700, David Daney wrote:
> skaller wrote:
> > On Fri, 2007-10-26 at 14:24 -0700, Ian Lance Taylor wrote:
> >> Michael Matz <firstname.lastname@example.org> writes:
> >> This is basically a public relations exercise. I doubt this
> >> optimization is especially important, so I think it's OK to disable it
> >> to keep people happy. Even though the optimization has been there
> >> since gcc 3.4 and nobody noticed.
> > Most people didn't have multi-core processors then..
> They did use pthreads though. Code correctness in this case does not
> depend on the number of processor cores.
Probably this is mostly correct, though it seems to depend
on whether loads and stores are atomic with respect
to parallel or merely pre-empted accesses.
There are of course cases where it matters. Eg critical
sections on a single core can be implemented by simply
masking interrupts. That doesn't work on a dual core.
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net