rust/library/core
Jonas Schievink fd868d02d1
Rollup merge of #81484 - Kogia-sima:perf/optimize-udiv_1e19, r=nagisa
Optimize decimal formatting of 128-bit integers

## Description

This PR optimizes the `udivmod_1e19` function, which is used for formatting 128-bit integers, based on the algorithm provided in \[1\]. This optimization improves performance of formatting 128-bit integers, especially on 64-bit architectures. It also slightly reduces the output binary size.

## Assembler comparison

https://godbolt.org/z/YrG5zY

## Performance

#### previous results

```
test fmt::write_u128_max                                        ... bench:         552 ns/iter (+/- 4)
test fmt::write_u128_min                                        ... bench:         125 ns/iter (+/- 2)
```

#### new results

```
test fmt::write_u128_max                                        ... bench:         205 ns/iter (+/- 13)
test fmt::write_u128_min                                        ... bench:         129 ns/iter (+/- 5)
```

## Reference

\[1\] T. Granlund and P. Montgomery, “Division by Invariant Integers Using Multiplication” in Proc. of the SIGPLAN94 Conference on Programming Language Design and Implementation, 1994, pp. 61–72
2021-01-31 01:47:36 +01:00
..
benches Add more benchmarks 2021-01-08 09:50:35 +00:00
src Rollup merge of #81484 - Kogia-sima:perf/optimize-udiv_1e19, r=nagisa 2021-01-31 01:47:36 +01:00
tests Rollup merge of #80470 - SimonSapin:array-intoiter-type, r=m-ou-se 2021-01-31 01:47:25 +01:00
Cargo.toml