Ian Lynagh wrote:
On Mon, May 07, 2007 at 08:58:33AM +0100, Simon Marlow wrote:
Ian Lynagh wrote:
Thu May 3 15:38:33 PDT 2007 Ian Lynagh <[EMAIL PROTECTED]>
* Fix truncate on amd64 NCG; fixes arith005.
cvts[sd]2siq? ->
cvtts[sd]2siq?
Something still looks odd here. We have a RULE in GHC/Float.hs mapping
truncate on Float->Int to the float2Int# primop (similarly for Double),
which means that either float2Int# should have truncating semantics, or the
RULE is wrong. Looks like you fixed the primop to have truncating
semantics for the x86_64 NCG,
Right.
but it looks it still has rounding semantics
for other platforms: the x86 NCG uses fistpl, which rounds by default, and
I didn't check that one, as stateful instructions make it a pain to be
sure what it's going to do. I think I did check that sparc was also
truncating, though.
when going via C we use a cast, which also rounds.
It looks like it truncates to me...
Ah yes, you're right.
6.3.1.4 Real floating and integer
[#1] When a finite value of real floating type is converted
to integer type other than _Bool, the fractional part is
discarded (i.e., the value is truncated toward zero). If
the value of the integral part cannot be represented by the
integer type, the behavior is undefined.41)
In that case, it seems reasonable that our float2Int# and double2Int# primops
follow the default C casting behaviour. In which case, we probably still have a
bug in the x86 NCG.
Cheers,
Simon
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc