[GHC] #16122: `round :: Double -> Int64` much slower than `fromIntegral @Int @Int64 . round`

GHC ghc-devs at haskell.org
Mon Jan 7 05:13:23 UTC 2019


#16122: `round :: Double -> Int64` much slower than `fromIntegral @Int @Int64 .
round`
-------------------------------------+-------------------------------------
        Reporter:  Fuuzetsu          |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.6.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Fuuzetsu):

 Replying to [comment:4 simonpj]:
 >The reason things go wrong is that in the RHS of hte rule in `GHC.Int`
 you really want to apply the rule `"round/Double->Int"` in `GHC.Float`,
 but perhaps it is not imported by `GHC.Int`?
 >
 > Anyway, probably the best solution here is to rewrite the rule in
 `GHC.Int` to
 > {{{
 > "round/Double->Int64"
 >     round    = (fromIntegral :: Int -> Int64) . GHC.Float.roundDoubleInt
 > }}}
 > (And maybe the same for `fromIntegral`?)

 It seems wrong to me to manually expand rules that already exist. Seems
 very unprincipled and easy to miss other existing cases: I'm confident
 {{{Int64}}} isn't the only offender, there are similar rules all around.

 I'm happy to submit a patch as proposed but I wonder if there isn't a
 better way to ensure the relevant rules are in scope together...

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/16122#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list