4 ms·
No need to speculate. https://godbolt.org/z/AC2NKY https://godbolt.org/z/AC2NKY . Results significantly vary between compilers. In almost all cases there is at
by Karliss 8y ago
No need to speculate. https://godbolt.org/z/AC2NKY https://godbolt.org/z/AC2NKY . Results significantly vary between compilers.
In almost all cases there is at least one jump generated due to the way comparison with 3 values less than 32 is done. If the number is less than or equal to 32 compiler does a lookup in bitmask indicating which values to skip.
Often Clang and MSVC generated a second jump.
- lostmsu 8y agoNone of the compilers generated branch-free loop. Looks like or short-circuiting is the reason. Now I wonder if getting rid of branches at assembly level actually gives any benefit. That can be achieved by using | instead of ||.