about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
diff options
context:
space:
mode:
authorChristopher Swenson <swenson@swenson.io>2024-08-03 08:49:38 -0700
committerChristopher Swenson <swenson@swenson.io>2024-08-03 08:49:38 -0700
commit36a805939e6e9d4bdff03c28bc1ad9dbd36bdb95 (patch)
treebd786648b52572ab4d7c27556a638441e5cb6531 /compiler/rustc_codegen_gcc
parent1df0458781d6fd753a68c4cdc4de5313b1635dbd (diff)
downloadrust-36a805939e6e9d4bdff03c28bc1ad9dbd36bdb95.tar.gz
rust-36a805939e6e9d4bdff03c28bc1ad9dbd36bdb95.zip
Remove unnecessary constants from flt2dec dragon
The "dragon" `flt2dec` algorithm uses multi-precision multiplication by
(sometimes large) powers of 10. It has precomputed some values to help
with these calculations.

BUT:

* There is no need to store powers of 10 and 2 * powers of 10: it is
  trivial to compute the second from the first.
* We can save a chunk of memory by storing powers of 5 instead of powers
  of 10 for the large powers (and just shifting by 2 as appropriate).
* This also slightly speeds up the routines (by ~1-3%) since the
  intermediate products are smaller and the shift is cheap.

In this PR, we remove the unnecessary constants and do the necessary
adjustments.

Relevant benchmarks before (on my Threadripper 3970X, x86_64-unknown-linux-gnu):

```
num::flt2dec::bench_big_shortest                      137.92/iter   +/- 2.24
num::flt2dec::strategy::dragon::bench_big_exact_12   2135.28/iter  +/- 38.90
num::flt2dec::strategy::dragon::bench_big_exact_3     904.95/iter  +/- 10.58
num::flt2dec::strategy::dragon::bench_big_exact_inf 47230.33/iter +/- 320.84
num::flt2dec::strategy::dragon::bench_big_shortest   3915.05/iter  +/- 51.37
```

and after:

```
num::flt2dec::bench_big_shortest                      137.40/iter   +/- 2.03
num::flt2dec::strategy::dragon::bench_big_exact_12   2101.10/iter  +/- 25.63
num::flt2dec::strategy::dragon::bench_big_exact_3     873.86/iter   +/- 4.20
num::flt2dec::strategy::dragon::bench_big_exact_inf 47468.19/iter +/- 374.45
num::flt2dec::strategy::dragon::bench_big_shortest   3877.01/iter  +/- 45.74
```
Diffstat (limited to 'compiler/rustc_codegen_gcc')
0 files changed, 0 insertions, 0 deletions