3 ms·
Branchless Equivalents of Simple Functions (2008)
- mappu 11y agoglibc's abs() implementation is here: https://github.com/bminor/glibc/blob/master/stdlib/abs.c https://github.com/bminor/glibc/blob/master/stdlib/abs.c It's the naive branching version (probably for platform independence?), but my installed GCC 4.9.3 does convert it to branchless cdq/xor trick on both -O3 and -O0.
- rdc12 11y agoLast time I looked the "naive"[1] version of fizzbuzz, when compiled with GCC or Clang, was converted to a branchless version (for x86 at least). I don't remember what -O level was needed thou. [1] as is the if and modulo based way