patch applied (ghc): Fix truncate on amd64 NCG; fixes arith005.
Ian Lynagh
igloo at earth.li
Mon May 7 06:18:32 EDT 2007
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 <igloo at earth.li>
> > * 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...
> Who is right? I'd have thought the primop should round by default, but
> then the RULE is wrong.
Perhaps we should have one or both of truncateFloat2Int and
roundFloat2Int instead?
Thanks
Ian
More information about the Cvs-ghc
mailing list