Compiler optimizations questions for ghc 6.10...
Tyson Whitehead
twhitehead at gmail.com
Thu Feb 19 22:00:01 EST 2009
On February 19, 2009 18:20:33 Krasimir Angelov wrote:
> Oh. I looked at the primops.txt.pp for something suspicious but I
> didn't checked the actual implementation of quot. I thought that quot
> calls quotInt# directly. When I use quotInt in the code I can get the
> real idiv assembly instruction. Still the code generated by GHC is
> strange it doesn't throw any exception actually. It just evaluates the
> same expression but with the constant maxBound.
>
> On Thu, Feb 19, 2009 at 11:19 PM, Max Bolingbroke
> > a `quot` b
> >
> > | b == 0 = divZeroError
> > | a == minBound && b == (-1) = overflowError
> > | otherwise = a `quotInt` b
I checked the quot one like you said. Kind of strange all right.
It looks like it is performing the a == minBound check (where a = maxBound-x)
despite the b == (-1) check (where b = 10) being optimized away.
Cheers! -Tyson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20090219/2b9cdda3/attachment.bin
More information about the Glasgow-haskell-users
mailing list