optimization: replace modulo by a power of two with a bitwise AND