libstdc++/8230: Buggy allocator behaviour

Gabriel Dos Reis gdr@integrable-solutions.net
Thu Nov 14 16:32:00 GMT 2002


Matt Austern <austern@apple.com> writes:

[...]

| > In general, I would like to see us starting using use 
| > __builtin_expect()
| > at places where we do checks for limits cases.  Thoughts?
| 
| Two questions.
| 
| First, is it known how much of a speedup this gives on typical 
| platforms?

I didn't make measurements by myself but I'm trusting its implementor
(RTH) :-)

Maybe RTH could provide us with some datapoint here?

| Second, if the answer to question 1 is "a lot": is there some sensible
| way to use this in the compiler itself?  I suppose it'd have to involve
| some ghastly macro hackery because of the bootstrap problem, but
| it we're talking big performance wins, it might be worth it.

If the answer to the first question is "a lot", then I agree with you
that it makes perfect sense to use it in the compiler itself.  I
could imagine something along the lines

#if !defined(__GNUC__) || __GNUC__ < 3  /* correct the version number */
#  define __builtin_expect(EXP, PROB) EXP
#endif

in system.h or wherever appropriate.

-- Gaby



More information about the Libstdc++ mailing list