#3034: divInt# floated into a position which leads to low arity
--------------------------------------+-------------------------------------
Reporter: batterseapower | Owner:
Type: run-time performance bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.10.1
Severity: normal | Resolution:
Keywords: | Testcase:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
--------------------------------------+-------------------------------------
Comment (by twhitehead):
I should avoiding the division altogether through quotRem generates really
bad code as well
where digit :: Int -> Int -> ParseInt Int Int
digit !x = do !y <- lift get
( if y < ym || y==ym && x<=xm
then lift (put $ y*10+x) >> s2
else throwError "integer overflow" )
where (ym,xm) = maxBound`quotRem`10
Putting separate "ym = maxBound`quot`10" and "xm = maxBound`rem`10"
bindings gives good code.
Examining the assembler for a seperate routine like
demo :: Int -> Int -> Int
demo x y = q+r
where q = quot x y
r = rem x y
shows this isn't a really great option in general because the GHC does it
through two identical idivs on the x86_64. I am guessing the underlying
issue is much the same due to no IntQuotRem prim op.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3034#comment:3>
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