On Thu, Dec 13, 2007 at 11:17:10PM +1100, Roman Leshchinskiy wrote:
> Hi everyone,
>
> here's a simple program:
>
> foo :: Int
> foo = 8 `div` 1
>
> I was a bit surprised to see that GHC (both 6.8 and HEAD) generates the 
> following Core for this:
>
> foo = case GHC.Base.divInt# 8 1 of wild21_afL
>         { __DEFAULT -> GHC.Base.I# wild21_afL }
>
> It turns out that there are no rules for divInt#, quotInt#, remInt# and 
> modInt# in GHC.Base and that no constant folding happens for divInt# and 
> modInt# in PrelRules.lhs. In fact, the latter two don't even seem to be 
> primops. This also seems to be the case for their Word# counterparts. I 
> assume this is just an oversight but thought I'd ask before doing anything. 
> Is it ok to add the primops and a couple of rules?

divInt# and modInt# are not primops because (i386) division corresponds
to quotInt# and remInt#, so the other two absolutely need to be
implemented in software.  But I'd call it an probably inliner bug if
they show up in optimized Core output.

Stefan

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to