This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] conditional tweak
- From: Phil Edwards <phil at jaj dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Jerry Quinn <jlquinn at optonline dot net>, libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 7 Nov 2003 16:01:57 -0500
- Subject: Re: [v3] conditional tweak
- References: <E1AHXfb-0002FJ-00@smaug> <m3sml2metw.fsf@uniton.integrable-solutions.net>
On Thu, Nov 06, 2003 at 03:05:31AM +0100, Gabriel Dos Reis wrote:
> Jerry Quinn <jlquinn@optonline.net> writes:
>
> | 2003-11-05 Jerry Quinn <jlquinn@optonline.net>
> |
> | * include/bits/basic_ios.h (basic_ios::fill): Use
> | __builtin_expect.
>
> Does it make a real measurable difference?
While I haven't measured Jerry's particular patch, on machines with deep
pipelines, an incorrectly-predicted branch can be a significant stall
(most/all of the pipeline has to be cleared). My own opinion is that
we should use __builtin_expect anywhere we (the humans) can reasonably
predict the result.
The code becomes a bit harder to read... we could adopt a v3 coding
practice of, for example, always "expect"ing the true branch, and then
wrapping __builtin_expect in a much less visible macro. Or whatever.
--
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it.
- Brian W. Kernighan