[LLVMdev] precondition suggestion to LLVM

Chandler Carruth chandlerc at google.com
Mon Oct 22 20:35:15 PDT 2012


On Mon, Oct 22, 2012 at 8:06 PM, Dmitry N. Mikushin <maemarcus at gmail.com> wrote:
> Hi Niko,
>
> Do you mean branch prediction, i.e. __builtin_expect [1]? Many
> compilers support it, I think clang (LLVM's C/C++ frontend) is among
> them.

Clang+LLVM support __builtin_expect *when used directly inside of a
conditional*. This last is an important constraint.

Another way of thinking about it is that Clang+LLVM supports
expressing control flow biases and optimizes based on them. However,
there is no direct support for expressing value range biases or
optimizing based on them. This is largely due to the overall lack of
value range biasing and asserting support in the IR of LLVM.

While __builtin_expect can in theory be used to encode value range
biases, we see it overwhelmingly more often used to express control
flow biases, and that has been the focus of LLVM's profile-guided
optimization efforts.



More information about the llvm-dev mailing list