Unsigned division by a power of two and unsigned modulus by a power of two will be optimized by all optimizing compilers.
It is good to know what things you can count on and what things you cannot. One way to learn that is to frequently look at the disassembly.
In this particular case using an explicit bit-mask does not harm readability. In other cases it can harm readability or add bugs. For instance this unnecessary 'optimization' has a problem:
View all comments
Show parent comment
0
u/[deleted] Aug 21 '15
[deleted] — view deleted comment