[RFA] optimizing predictable branches on x86

Paolo Bonzini bonzini@gnu.org
Mon Mar 3 13:44:00 GMT 2008


>>> I hope so too. For the kernel we have some parts where
>>> __builtin_expect is used quite a lot and noticably helps, and could
>>> help even more if we cut down the use of cmov too. I guess on
>>> architectures with even more predictated instructions it could be
>>> even more useful too.
>> Looking at kernel's __builtin_expect usage, I think we ought to do a lot
>> better on taking the hints than we do now.  In particular we should
>> be able to derrive more from
>>  likely (test1||test2) and likely (test1&&test2)
>> and similar cases.  I will try to prepare patch for this later too.

Right now it does

   1. __b_e (a && b, 1) => __b_e (a, 1) && __b_e (b, 1)
   2. __b_e (a && b, 0) => a && __b_e (b, 0)
   3. __b_e (a || b, 1) => a || __b_e (b, 1)
   4. __b_e (a || b, 0) => __b_e (a, 0) || __b_e (b, 0)

See http://gcc.gnu.org/ml/gcc-patches/2007-07/msg00410.html

Paolo



More information about the Gcc-patches mailing list