Skip to content

Use wasm math opcodes in wasm NCG

Currently, the wasm NCG lowers Cmm math MachOps like MO_F64_Sqrt to call their respective functions in libc. Some of these operations are actually available as a single wasm opcode (e.g. f64.sqrt). The wasm NCG should lower to a single math opcode whenever possible.

https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/sources/math/math-builtins.c is a good reference for what math functions are available as a single wasm opcode. wasi-libc already takes advantage of these opcodes, but it's still nice to avoid the function call overhead when possible.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information