|
|
|
|
|
by Arcuru
526 days ago
|
|
> Much better :) But what about C? Let’s try it: > I tried both versions (modulo 2 and bitwise AND) and got the same result. I think the optimizer recognizes modulo 2 and converts it to bitwise AND. Yes, even without specifying optimizations - https://godbolt.org/z/9se9c6qKT You can see that the output of the compiler is identical whether you use `i%2 == 0` or `(i&1) == 0`. The bitwise AND is instruction 12 in the output. Using -O3 like in the post actually compiles to SIMD instructions on x86-64 - https://godbolt.org/z/dWbcK947G |
|