-
Simon Marlow authored
Division by an integral log2 can't be directly optimised to a shift right, because shift right behaves like a division that rounds to negative infinity, whereas we want one that rounds to zero. Fix this by adding (divisor-1) to the dividend when it is negative before shifting. We do this without jumps, generating very slightly worse code than gcc, which uses conditional moves on CPUs that support it.
91a9aeeb