[GHC] #5161: Poor performance of division; unnecessary branching
GHC
cvs-ghc at haskell.org
Thu Apr 28 10:31:20 CEST 2011
#5161: Poor performance of division; unnecessary branching
---------------------------------+------------------------------------------
Reporter: rtvd | Owner:
Type: bug | Status: new
Priority: normal | Component: libraries/base
Version: 7.0.3 | Keywords: div quot rem mod performance slow branching
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Runtime performance bug
---------------------------------+------------------------------------------
In case an Int* is divided by a constant the compiled code contains
unnecessary checks whether the value being divided is minBound. This check
is necessary only if a value is being divided by -1 so that an exception
would be thrown.
The branch can be removed by the GHC's optimiser after a small change: the
two parts of the corresponding condition have to be flipped. This provides
an opportunity to short-circuit this condition to 'false' without knowing
the first argument (patch is attached).
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5161>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list