|
|
|
|
|
by gpderetta
2329 days ago
|
|
Not really: cnt += *ptr++ == '\n'
Should compile down to no branches (not even cmov) by summing the value of the flag register directly. Would be a it hard to stop without taking a branch though. Would you consider function pointer calls a branch? If that's too easy, what about taking a segfault? |
|
https://godbolt.org/z/XCBGYW
Only icc vectorizes this at -O2 (still branchless, of course), but clang and gcc vectorize it if you go to -O3.