This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] conditional tweak


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]