[llvm-dev] [RFC] remove the llvm.expect intrinsic
Sanjay Patel via llvm-dev
llvm-dev at lists.llvm.org
Fri Apr 22 10:47:56 PDT 2016
On Fri, Apr 22, 2016 at 11:41 AM, Mehdi Amini <mehdi.amini at apple.com> wrote:
>
> PGO is also a user input: the user is basically saying "I want the code to
> be optimized for *this* use case".
> So interestingly I would have thought the opposite: PGO overrides the
> source code annotation.
> Here are a couple of reasons why:
> - libraries can be used by different client and what is common in one
> case might not for another.
> - code evolves, and user can fail to revisit assumption about the common
> case
> - the user can be wrong, PGO should not (?).
>
>
> For this last point, whatever information prevails in the end, it may be
> valuable to report to the user some optimization hints about the mismatch
> between the PGO measurement and the annotation.
>
>
I like that idea. My feeling is that builtin_expect() should be treated
like a super-power. If it's wrong, it's the programmer's fault. But I
understand your point that PGO is another user input.
Note that the GCC docs (because there's no corresponding clang doc for this
afaict) do warn:
"You may use __builtin_expect to provide the compiler with branch
prediction information. In general, you should prefer to use actual profile
feedback for this (-fprofile-arcs), as programmers are notoriously bad at
predicting how their programs actually perform."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160422/0a71de34/attachment.html>
More information about the llvm-dev
mailing list