[cfe-dev] __builtin_expect hint ignored

Flamedoge via cfe-dev cfe-dev at lists.llvm.org
Tue Apr 18 15:59:38 PDT 2017


I see this with clang trunk on the website too. Perhaps of interest to
llvm-dev?

On Tue, Apr 18, 2017 at 2:56 PM, Adam Nowacki via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> https://godbolt.org/g/VvrbFZ
>
> For the code below generated assembly is the worst possible - test 1, else
> test 3, else test 2 with expected value of 2 last ... Whats going on?
>
> long case_2();
> long case_3();
> long case_1();
> long case_else();
> long test(long a) {
>     switch (__builtin_expect(a, 2)) {
>         case 2: return case_2();
>         case 3: return case_3();
>         case 1: return case_1();
>         case 0:
>         case 4:
>         case 5: return case_else();
>         default: __builtin_unreachable();
>     }
> }
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170418/970d93d2/attachment.html>


More information about the cfe-dev mailing list