search for: _builtin_expect

Displaying 4 results from an estimated 4 matches for "_builtin_expect".

Did you mean: __builtin_expect
2018 May 09
3
Ignored branch predictor hints
Hello, #define likely(x) __builtin_expect((x),1) // switch like char * b(int e) { if (likely(e == 0)) return "0"; else if (e == 1) return "1"; else return "f"; } GCC correctly prefers the first case: b(int): mov eax, OFFSET FLAT:.LC0 test edi, edi jne .L7 ret But Clang s...
2018 May 09
0
Ignored branch predictor hints
...t gmail.com>: > I did > > https://bugs.llvm.org/show_bug.cgi?id=37368 > > 2018-05-09 20:29 GMT+02:00 David Zarzycki <dave at znu.io>: > >> I’d wager that the if-else chain is being converted to a "switch >> statement” during an optimization pass and the __builtin_expect() hint is >> lost. Can you file a bug? https://bugs.llvm.org >> >> >> On May 9, 2018, at 1:57 PM, Dávid Bolvanský via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >> Hello, >> >> #define likely(x) __builtin_expect((x),1) >&...
2018 May 09
2
Ignored branch predictor hints
Hi Dávid, Looks like you can defeat the switch conversion by adding a dummy asm(“”): #define likely(x) __builtin_expect((x),1) // switch like char * b(int e) { if (likely(e == 0)) return "0"; asm(""); if (e == 1) return "1"; else return "f"; } Dave > On May 9, 2018, at 2:33 PM, Dávid Bolvanský via llvm-dev <llvm-dev at lists.llvm.org&gt...
2018 May 09
0
Ignored branch predictor hints
...e branch predictor hints are broken in a valid C++20 code: https://godbolt.org/g/dpSDqd Dňa st 9. 5. 2018, 20:40 David Zarzycki <dave at znu.io> napísal(a): > Hi Dávid, > > Looks like you can defeat the switch conversion by adding a dummy asm(“”): > > #define likely(x) __builtin_expect((x),1) > > // switch like > char * b(int e) { > if (likely(e == 0)) > return "0"; > asm(""); > if (e == 1) > return "1"; > else return "f"; > } > > Dave > > On May 9, 2018, at 2:33 PM,...