Comment by kragen
2 months ago
There are, even with optimizations on. You could have checked: https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename...
I didn't find any way to get a compiler to generate a branchless version. I tried clang and GCC, both for amd64, with -O0, -O5, -Os, and for clang, -Oz.
If you change logic and/or to bitwise and/or then it'll be branchless.
True: https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename... but I understood hoten to be saying that compilers would generally produce that version from the short-circuiting version, and they don't.
Yeah I was wrong.
Do we know why the compiler doesn't do it? Surely the output is the same and avoiding branches is clearly faster.
Maybe short circuiting requires such an optimization not be made?
1 reply →