[GHC] #13040: realToFrac into Complex Double has no specialization

#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

#13040: realToFrac into Complex Double has no specialization -------------------------------------+------------------------------------- Reporter: akio | Owner: akio Type: feature request | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2901 Wiki Page: | -------------------------------------+------------------------------------- Changes (by akio): * owner: => akio * differential: => Phab:D2901 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13040#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13040: realToFrac into Complex Double has no specialization
-------------------------------------+-------------------------------------
Reporter: akio | Owner: akio
Type: feature request | Status: new
Priority: normal | Milestone:
Component: libraries/base | Version: 8.0.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2901
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#13040: realToFrac into Complex Double has no specialization -------------------------------------+------------------------------------- Reporter: akio | Owner: akio Type: feature request | Status: closed Priority: normal | Milestone: 8.2.1 Component: libraries/base | Version: 8.0.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2901 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed * milestone: => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13040#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC