[GHC] #13040: realToFrac into Complex Double has no specialization
GHC
ghc-devs at haskell.org
Wed Dec 28 08:02:44 UTC 2016
#13040: realToFrac into Complex Double has no specialization
-------------------------------------+-------------------------------------
Reporter: akio | Owner:
Type: feature | Status: new
request |
Priority: normal | Milestone:
Component: | Version: 8.0.1
libraries/base |
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Runtime
Unknown/Multiple | performance bug
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Example:
{{{#!hs
module Foo where
import Data.Complex
f :: Double -> Complex Double
f x = realToFrac x
}}}
`ghc -O -ddump-simpl` gives:
{{{
f =
\ (w_s17v :: Double) ->
case w_s17v of _ [Occ=Dead] { GHC.Types.D# ww1_s17y ->
case GHC.Float.$w$ctoRational ww1_s17y
of _ [Occ=Dead] { (# ww3_a152, ww4_a153 #) ->
case GHC.Float.rationalToDouble ww3_a152 ww4_a153
of dt_a15c { GHC.Types.D# ipv_a15g ->
Data.Complex.:+ @ Double dt_a15c Data.Complex.$fFloatingComplex1
}
}
}
}}}
This means the conversion goes through Rational. However, in this case,
the conversion could be done much more efficiently with `(:+0)`. It would
be nice if this happened automatically.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13040>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list