Commit 6849c16
committed
Use 128-bit Widening Multiply on More Platforms
The 128-bit widening multiplication was previously gated by simply
checking the target pointer width. This works as a simple heuristic, but
a better heuristic can be used:
1. Most 64-bit architectures except SPARC64 and Wasm64 support the
128-bit widening multiplication, so it shouldn't be used on those two
architectures.
2. The target pointer width doesn't always indicate that we are dealing
with a 64-bit architecture, as there are ABIs that reduce the pointer
width, especially on AArch64 and x86-64.
3. WebAssembly (regardless of pointer width) supports 64-bit to 128-bit
widening multiplication with the `wide-arithmetic` proposal.
The `wide-arithmetic` proposal is available since the LLVM 20 update and
works perfectly for this use case as can be seen here:
https://rust.godbolt.org/z/9jY7fxqxK
Using `wasmtime explore`, we can see it compiles down to the ideal
instructions on x86-64:
```nasm
mulx rax, rdx, r10
xor rax, rdx
```
Based on the same change in
[`foldhash`](orlp/foldhash#17).1 parent dc5c33f commit 6849c16
1 file changed
+21
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
202 | 217 | | |
203 | 218 | | |
204 | | - | |
| 219 | + | |
205 | 220 | | |
206 | 221 | | |
207 | 222 | | |
| |||
216 | 231 | | |
217 | 232 | | |
218 | 233 | | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
| 234 | + | |
223 | 235 | | |
224 | 236 | | |
225 | 237 | | |
| |||
228 | 240 | | |
229 | 241 | | |
230 | 242 | | |
231 | | - | |
232 | | - | |
| 243 | + | |
| 244 | + | |
233 | 245 | | |
234 | 246 | | |
235 | 247 | | |
| |||
0 commit comments