[llvm-dev] [RFC] remove the llvm.expect intrinsic

Sanjay Patel via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 22 09:20:08 PDT 2016

I've proposed removing the llvm.expect intrinsic:

The motivation for this change is in:

For reference:
1. We created an intrinsic that's only reason for existing is to improve
perf, but the intrinsic can harm optimization by interfering with
transforms in other passes.

2. To solve that, we created a pass to always transform the intrinsic into
metadata at a very early stage in LLVM. But now every program is paying a
compile-time tax (running the LowerExpectIntrinsic pass) for a feature that
is rarely used.

A possible front-end replacement transformation for a source-level
"builtin_expect()" is in D19299: I think a front-end can always directly
create metadata for this kind of programmer hint rather than using an
intermediate representation (the intrinsic). Likewise, if there's some
out-of-tree IR pass that is creating an llvm.expect, it should be able to
create branch weight metadata directly instead.

Please let me know if you see any problems with this proposal or the

For reference, here's the original post-commit review thread for
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160422/d8861332/attachment.html>

More information about the llvm-dev mailing list