当前位置: 动力学知识库 > 问答 > 编程问答 >

prediction - __builtin_expect from GCC with probability

问题描述:

__builtin_expect from GCC can be used by programmer to show which variants are expected to be very often and which are rare. But __builtin_expect have only "true" and "false" (0% or 100% probability)

For some big projects it is vary hard to get profile feedback (-fprofile-arcs), and sometimes programmer does know, what probability of branch he have in some point of program.

It is possible to give a hint to compiler that a branch have probability >0% and <100% ?

网友答案:

True and false really mean that "the first variant is more likely" and "the second variant is more likely". There's no practical need for any values other than these. The compiler won't be able to use that information.

网友答案:

Non-determinism is not a desirable trait for compiler output, let alone language features. There is no real benefit to only partial optimization preferring one branch, and no compiler I'm aware of can do this.

分享给朋友:
您可能感兴趣的文章:
随机阅读: