likely/unlikely equivalent for MSVC

前端 未结 6 1582
醉话见心
醉话见心 2020-12-02 18:19

GCC compiler supports __builtin_expect statement that is used to define likely and unlikely macros.

eg.

#define likely(expr)    (__builtin_expect(!!(         


        
6条回答
  •  醉话见心
    2020-12-02 18:36

    According to http://www.akkadia.org/drepper/cpumemory.pdf (page 57), it still makes sense to use static branch prediction even if CPU predicts correctly dynamically. The reason for that is that L1i cache will be used even more efficiently if static prediction was done right.

提交回复
热议问题