Wrap `gmpz_tdiv_{q,r,qr}_ui` to optimize `quot`/`rem`
authorHerbert Valerio Riedel <hvr@gnu.org>
Wed, 8 Jan 2014 21:45:13 +0000 (22:45 +0100)
committerHerbert Valerio Riedel <hvr@gnu.org>
Wed, 8 Jan 2014 22:37:41 +0000 (23:37 +0100)
commitaf2ba9c81cf6a3223ccc74c5aa17de18138fd824
treef00ae5b5f2f1e64ab933408393883fb42d67b798
parent8ed8ac58b4a5c8654fccee4436ca62bf7c690474
Wrap `gmpz_tdiv_{q,r,qr}_ui` to optimize `quot`/`rem`

This is useful as `quot`/`rem` are often used with small-int divisors,
like when computing the digits of an `Integer`. This optimization
reduces allocations in the following `nofib` benchmarks:

      Program        Size    Allocs   Runtime   Elapsed  TotalMem
   -----------------------------------------------------------------
        power       +0.3%     -0.8%     -1.2%     -1.2%     +0.0%
    primetest       +0.3%     -3.9%      0.07      0.07     +0.0%
          rsa       +0.3%     -4.0%      0.02      0.02     +0.0%
       symalg       +0.2%     -1.4%      0.01      0.01     +0.0%

This addresses #8647

Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
GHC/Integer/GMP/Prim.hs
GHC/Integer/Type.lhs
cbits/gmp-wrappers.cmm