...
> It can see the lock values don't have any effect on 'a'. What actually
> does keep this stuff from moving around?
Lack of ambition?
I'm pretty sure that the only reasons *to* reorder instructions are:
1) there could be a performance gain, as in a) loop unrolling b) pipeline fill considerations c) unnecessary
assignment(e.g. result is ignored, or only used on one
path)
2) the optimization level allows it (-O0 does not reorder at all)
I vaguely recall that the gcc docs discuss the kinds of optimizations
allowed at each level. Presumably IBM's AIX compiler was a bit more
aggressive in evaluating costs or pipeline fills than is gcc on other
processors.
- Thomas