------- Comment #2 from acahalan at gmail dot com  2006-02-20 03:49 -------
I gave two examples. (you may assume I want code to run fast)

I first saw this feature proposed on the linux-kernel mailing list when there
was some argument over whether or not __builtin_expect() should be used in a
particular location. For one architecture it was good (i386 if I remember
right), but for another architecture (ARM if I remember right) it was bad. The
problem is that the behavior change is appropriate at X% likelyhood on one
architecture, and Y% likelyhood on a different architecture. X and Y are not
documented.

So somebody wished that __builtin_expect() would take an argument to specify
probability. I agree.

For each change of compiler behavior (setting an instruction bit, moving code
out of line, making unlikely code as if -Os were specified...) there is an
architecture-specific probability level at which it makes sense.

A more awkward way to expose this would be as a predefined preprocessor symbol
that specifies the architecture-specific likelyhood at which __builtin_expect()
may be useful. It's a bit nicer to just let the programmer give a 3rd argument.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26367

Reply via email to