std::max/min optimization
Nathan Myers
ncm-nospam@cantrip.org
Wed Nov 26 19:23:00 GMT 2003
On Wed, Nov 26, 2003 at 10:17:03AM -0800, Ulrich Drepper wrote:
> > Summing over all the programs that are actually run,
> > which produces a better overall result?
>
> Completely irrelevant.
In fact, the overwhelming majority of users don't have time to
hyper-optimize every build of everything, but are nonetheless
strongly affected by the choices we make. That makes it relevant.
> You say it yourself:
>
> > on the assumption that
> > users who care most about performance are using fast machines.
>
> The fastest code for the fastest machine is generated with by gcc using
> the plain old a > b ? a : b code.
That's true only if they compile, themselves, with "-march" options.
Why should it be necessary to rebuild everything with special
compiler options to get good performance, when we can give good
performance without?
I am not any more proposing changing the a > b ? a : b library code.
I am proposing that the default optimization choices should reflect the
real mix of targets. More specifically, the x86 compiler,
with -march=pentiumpro or better should produce a conditional-move
instruction.
with -mtune=i486 or worse probably should produce a conditional branch.
with neither should produce a bitwise-operations sequence.
"-O" alone is supposed to give good performance on the majority of
modern target machines. That implies generating bitwise operations,
in preference to branches, wherever it helps.
But this is now the wrowng list to discuss it.
Nathan Myers
ncm-nospam@cantrip.org
More information about the Libstdc++
mailing list