patch applied (ghc): Fix a bug in optimising division to shift right
Simon Marlow
simonmar at microsoft.com
Wed Apr 12 10:42:50 EDT 2006
Wed Apr 12 07:42:47 PDT 2006 Simon Marlow <simonmar at microsoft.com>
* Fix a bug in optimising division to shift right
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.
M ./compiler/cmm/CmmOpt.hs -7 +30
More information about the Cvs-ghc
mailing list