[llvm-dev] __builtin_expect hint ignored (original) (raw)
Vedant Kumar via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 24 14:41:05 PDT 2017
- Previous message: [llvm-dev] __builtin_expect hint ignored
- Next message: [llvm-dev] __builtin_expect hint ignored
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On x86-64, clang-trunk at least checks for the expected case first:
What changed? Well bisection results show that this was fixed by r300440:
[llvm] [mirror/master] [BPI] Use metadata info before any other heuristics
But the gcc 7 snapshot produces a lookup table. That might be better. CC'ing Marcello and Hans to comment, since IIRC they have both worked on switch lowering.
best vedant
On Apr 18, 2017, at 4:20 PM, Adam Nowacki via llvm-dev <llvm-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 case2(); long case3(); long case1(); long caseelse(); long test(long a) { _switch (builtinexpect(a, 2)) { case 2: return case2(); case 3: return case3(); case 1: return case1(); case 0: case 4: case 5: return caseelse(); _default: builtinunreachable(); } }
LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
- Previous message: [llvm-dev] __builtin_expect hint ignored
- Next message: [llvm-dev] __builtin_expect hint ignored
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]