This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] conditional tweak
Gabriel Dos Reis wrote:
...
| This conditional actually does happen to have a significant impact
| on performance -- fill() is called every time a number is inserted
| into a stream, for example.
compared to the actual work for formatting?
Believe it or not (although it depends if you consider an improvement
of a few tenths of a percent significant and worth the uglification;
I don't mind __builtin_expect() so much but I would probably have
second thoughts about the #pragma since it would have to be guarded
in portable code).
...
I have no idea of how HP aCC $pragma works. Can you display the actual
work or is it covered by proprietary rules?
The #pragma is documented here(*). It can be set up to work analogously
to __builtin_expect. This use, for instance
int foo (int n) {
if (n < 2) {
#pragma ESTIMATED_FREQUENCY 0
return 1;
}
return n * foo (n - 1);
}
is equivalent to gcc's
int foo (int n) {
if (__builtin_expect (n < 2, false)) {
return 1;
}
return n * foo (n - 1);
}
http://docs.hp.com/hpux/onlinedocs/B3901-90008/00/00/44-con.html#bgedagfi
Martin