#5598: Function quotRem is inefficient
----------------------------------------------+-----------------------------
Reporter: boris | Owner:
Type: task | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.0.3
Keywords: division, performance, primop | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: x86 | Failure: Runtime
performance bug
----------------------------------------------+-----------------------------
Comment(by simonpj):
It's true that a `CmmMachOp` can only return one result, but a
'''`CallishMachOp`''' could in principle return more than one.
Background: some `PrimOps` may be implemented by foreign calls (`sin` is
an example). In the translation from STG to Cmm, these primops are
separated out by `CgPrimOp.callishOp`, and we generate a Cmm statement
like
{{{
r = op(a,b)
}}}
Becuase this is a statement, it can have several results. There'd be no
difficulty with
{{{
r,s = op(a,b)
}}}
In contrast, ordinary primops can occur in Cmm ''expressions'' and so can
have only one result.
So I think all we need is a `PrimOp` returning an unboxed pair, with a
type like
{{{
quotRem# :: Int# -> Int# -> (# Int#, Int# #)
}}}
or something like that. It's just barely possible that it'd Just Work if
we added such a primop (provided it was "callish"), and suitably extended
`callishOp`, but I bet we've never tried it with two results, so it'd
probably fail.
Anyway unless I'm wildly off-beam, the point is that we're all set to do
it right now; so someone might like to have a go.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5598#comment:6>
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