Hacker News new | ask | show | jobs
by furyofantares 526 days ago
> I think the optimizer recognizes modulo 2 and converts it to bitwise AND.

You don't have to guess, you could turn or O3 or look at the disassembly.

2 comments

Interestingly, not only do both versions emit the same assembly, but clang both autovectorizes and unrolls the loop:

https://godbolt.org/z/qxsKWfz9s

gcc does it even when it's not optimizing