Portable branch prediction hints

后端 未结 6 1863
谎友^
谎友^ 2020-12-05 02:07

Is there any portable way of doing branch prediction hints? Consider the following example:

  if (unlikely_condition) {
    /* ..A.. */
  } else {
    /* ..B         


        
6条回答
  •  情书的邮戳
    2020-12-05 02:38

    C++20 offers likely and unlikely attributes

    Allow the compiler to optimize for the case where paths of execution including that statement are more or less likely than any alternative path of execution that does not include such a statement

提交回复
热议问题