> 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
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?
--
__("
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
> > > 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
> >
> > 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
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
> 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
>
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,
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
[ 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
10 matches
Mail list logo