Commit d840fb6
committed
Use the trifecta div algorithm for 128-bit div on wasm
This commit updates the `#[cfg]` annotations used to select the
implementation of 128-bit division in compiler-builtins on wasm targets.
This is done with relation to
https://github.com/WebAssembly/128-bit-arithmetic where performance of
128-bit operations is being investigated on WebAssembly. While I don't
know much about the particulars of the two algorithms involved here the
comments indicate that the "trifecta" variant is preferred if possible
but it's not selected on 32-bit architectures. This rationale isn't as
applicable to WebAssembly targets because despite the 32-bit pointer
width there are often wider-than-pointer operations available as it's
typically run on 64-bit machines.
Locally in testing a benchmark that performs division with a Rust-based
bignum libraries whent from 350% slower-than-native to 220%
slower-than-native with this change, a nice increase in speed. While
this was tested with Wasmtime other runtimes are likely to see an
improvement as well.1 parent 729ba06 commit d840fb6
1 file changed
+15
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
140 | 143 | | |
141 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
142 | 148 | | |
143 | 149 | | |
144 | 150 | | |
| |||
152 | 158 | | |
153 | 159 | | |
154 | 160 | | |
155 | | - | |
156 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
157 | 164 | | |
158 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
159 | 169 | | |
160 | 170 | | |
161 | 171 | | |
| |||
0 commit comments