#5598: Function quotRem is inefficient
---------------------------------+------------------------------------------
Reporter: boris | Owner:
Type: task | Status: new
Priority: normal | Component: Compiler
Version: 7.0.3 | Keywords: division, performance, primop
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: x86 | Failure: Runtime performance bug
---------------------------------+------------------------------------------
Function quotRem gets compiled into two div instructions although div
computes both quotient and remainder. This inefficiency exists both with
NCG and LLVM backends. Thus, quotRem is at least twice as slow as it could
be.
As far as I understand, quotRem is decomposed into two primops quotInt#
and remInt# (or quotWord# and remWord#) and each of them is compiled
independently into code which has div instruction. I propose to add new
primops quotRemInt# and quotRemWord# to address this flaw.
Please see the sample code and corresponding assembly.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5598>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs