[GHC] #1687: A faster (^)-function.
GHC
ghc-devs at haskell.org
Tue Aug 27 02:19:31 UTC 2013
#1687: A faster (^)-function.
---------------------------------+---------------------------
Reporter: moonlite@… | Owner:
Type: bug | Status: new
Priority: normal | Milestone: _|_
Component: Prelude | Version: 6.6.1
Resolution: | Keywords:
Operating System: Linux | Architecture: x86
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
---------------------------------+---------------------------
Changes (by rwbarton):
* cc: rwbarton@… (added)
Comment:
moonlite's algorithm does squaring and multiplication by the small number
`x`, while GHC's algorithm does squaring and multiplication of those
squares together in an accumulator. Squaring big integers is a constant
factor faster than multiplying different numbers of similar size, so
moonlite's algorithm wins on Integer when the numbers involved are large.
The downside is that it is not tail-recursive, which costs when
multiplications are actually very cheap like for Int.
But anyways, how about binding to `mpz_pow_ui` and using a RULE in the
case of Integer base?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/1687#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list