This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/26367] multiple levels of __builtin_expect
- From: "acahalan at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Feb 2006 03:49:04 -0000
- Subject: [Bug c/26367] multiple levels of __builtin_expect
- References: <bug-26367-12219@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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