Re: Converting float to double.

2000-05-10 Thread Lennart Augustsson
> How? RULES similar to ghc? Or built-in compiler magic for this case? Built in magic. Since this was the only way to convert between floating types it obviously needed a special case. -- Lennart

Re: Converting float to double.

2000-05-10 Thread Marcin 'Qrczak' Kowalczyk
Wed, 10 May 2000 13:49:30 +0200 (CEST), Lennart Augustsson <[EMAIL PROTECTED]> pisze: > (BTW, hbc has optimized these conversion since about 6 years ago.) How? RULES similar to ghc? Or built-in compiler magic for this case? -- __("

Re: Converting float to double.

2000-05-10 Thread Sven Panne
Lennart Augustsson wrote: > [...] > (BTW, hbc has optimized these conversion since about 6 years ago.) I've just added a whole bunch of RULES for fromIntegral, realToFrac and truncate to the GHC in CVS, so perhaps we've already catched up... >:-) Cheers, Sven -- Sven Panne

RE: Converting float to double.

2000-05-10 Thread Simon Marlow
> > > The compiler cannot guess that some primitive Float->Double > > > function can > > > be used instead of going through Rational. > > > > If enough inlining is done, then it should be able to deforest the > > intermediate Rational and generate the same code. But I > agree, using RULES > >

RE: Converting float to double.

2000-05-10 Thread Lennart Augustsson
> > The compiler cannot guess that some primitive Float->Double > > function can > > be used instead of going through Rational. > > If enough inlining is done, then it should be able to deforest the > intermediate Rational and generate the same code. But I agree, using RULES > here is quicker a

Re: Converting float to double.

2000-05-10 Thread Sven Panne
Simon Marlow wrote: > [...] If enough inlining is done, then it should be able to deforest > the intermediate Rational and generate the same code. [...] I really doubt that, e.g. GHC doesn't know about the relationships between the functions in StgPrimFloat.c, PrelFloat.fromRat' is a rather compl

RE: Converting float to double.

2000-05-10 Thread Simon Marlow
> It only provides specialization of this definition, i.e. > fromRational and > toRational dispatching is done at compile time (which, I hope, is done > automatically anyway at least in cases where such function > gets inlined). > > The compiler cannot guess that some primitive Float->Double >

Re: Converting float to double.

2000-05-10 Thread Sven Panne
Simon Marlow wrote: > Is this 4.06? The current prelude contains > > {-# SPECIALIZE realToFrac :: [ blah blah ] #-} > realToFrac :: (Real a, Fractional b) => a -> b > realToFrac = fromRational . toRational > > which should provide for all your float-converting needs :-) Not exactly,

RE: Converting float to double.

2000-05-10 Thread Marcin 'Qrczak' Kowalczyk
On Wed, 10 May 2000, Simon Marlow wrote: > > {-# RULES > > "realToFrac/Float->Double" realToFrac = floatToDouble > > "realToFrac/Double->Float" realToFrac = doubleToFloat #-} > Is this 4.06? The current prelude contains > > {-# SPECIALIZE realToFrac :: > which should provide for all your floa

RE: Converting float to double.

2000-05-10 Thread Simon Marlow
[ moved to [EMAIL PROTECTED] ] > The Prelude contains: > > realToFrac:: (Real a, Fractional b) => a -> b > realToFrac = fromRational . toRational > > Unfortunately GHC currently does not optimize this into anything > smarter than going through Rational. Fortunately it contains enough > machiner