[GHC] #2269: Word type to Double or Float conversions are slower than Int conversions
GHC
ghc-devs at haskell.org
Thu Feb 2 17:10:06 UTC 2017
#2269: Word type to Double or Float conversions are slower than Int conversions
-------------------------------------+-------------------------------------
Reporter: dons | Owner: dons@…
Type: feature request | Status: new
Priority: lowest | Milestone:
Component: Compiler | Version: 6.8.2
Resolution: | Keywords: rules,
| performance, double
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: |
-------------------------------------+-------------------------------------
Comment (by rwbarton):
Replying to [comment:16 thomie]:
> But `testWord` is still 3 times slower than `testInt`.
> {{{
> $ time ./testWord
> 5.00000005e15
>
> real 0m0.579s
> user 0m0.575s
> sys 0m0.003s
>
> $ time ./testInt
> 5.00000005e15
>
> real 0m0.196s
> user 0m0.191s
> sys 0m0.004s
> }}}
>
> As I can not easily explain this difference, I'll leave this ticket open
for now.
It's because the x86 NCG implements the new `MO_UF_Conv` as a call to a C
function, rather than generating code inline like `MO_SF_Conv`
(`cvtsi2sdq`).
Unfortunately there's no corresponding instruction for converting an
unsigned 64-bit integer to float or double, but for converting to double
the code generated by `clang -O` is pretty small and simple and probably
worth inlining. It will still be somewhat slower than `Int` though.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/2269#comment:21>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list