Commit bb80eb0
authored
Add #[inline] to mul, sub, inversion and xgcd ops (#1246)
Follow-up to #1229, continuing the inlining work from #981.
This adds `#[inline]` to `mul`, `sub`, `inversion`, and `xgcd` where
benchmarks showed clear wins. I also tried inlining `mul_mod_special`,
but it ended up being significantly slower (~2×), so I left it as-is.
## Benchmarks
Criterion, 100 samples. Showing deltas outside noise:
| Benchmark | Change |
| --- | --- |
| `sub`, I512 | **-19.2%** |
| `xgcd/256` | **-3.9%** |
| `xgcd/3` | **-3.6%** |
| `concatenating_mul`, I128 | **-3.4%** |
| `sub`, I4096 | **-3.4%** |
| `xgcd/64` | **-3.1%** |
| `wrapping_square`, U256 | **-1.7%** |
| `wrapping_mul`, U256 | **-1.5%** |
| `wrapping_mul`, I4096 | **-1.5%** |
| `xgcd/16` | **-1.5%** |
No regressions outside noise.1 parent 4cfae53 commit bb80eb0
4 files changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| |||
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| 136 | + | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
0 commit comments