[wasm2js] Support nontrapping float-to-int conversions directly in JS - #9019
[wasm2js] Support nontrapping float-to-int conversions directly in JS#9019sbc100 wants to merge 1 commit into
Conversation
|
I ran the whole |
d3f41bf to
83f7451
Compare
83f7451 to
7b14553
Compare
|
@kripken WDYT about these two stacked PRs combined? Do you think this approach is OK? I can't say I fully understand all the edge cases but the emscripten tests suite seems to pass fully for wasm2js, which is the only user I know of these passes. |
|
I think this makes sense to me. I don't see a problem, at least. To get more confidence, perhaps run the binaryen fuzzer locally, specifically the wasm2js one there. |
I'm not sure I've ever done that before. looking it up now.. What would the failure mode be that I am looking for? |
|
Looks like we might need to enable these features in the wasm2js fuzzer first: #9024 |
7b14553 to
149eaef
Compare
149eaef to
5b2a3f9
Compare
Now that 64-bit `trunc_sat` instructions are supported directly in `I64ToI32Lowering` (#9017), and 32-bit `trunc_sat` instructions are handled directly in `wasm2js` (`~~expr` and `~~expr >>> 0`), we no longer need to run `llvm-nontrapping-fptoint-lowering` when `--emscripten` is passed. In `wasm2js`, trapping float-to-int operations (`i32.trunc_*` and `i64.trunc_*`) are already lowered to non-trapping JS conversions (`~~expr` and float arithmetic in `I64ToI32Lowering`), which do not trap on out-of-range values or NaN/Infinity (matching C/C++ UB semantics rather than strict Wasm trapping semantics). Removing `llvm-nontrapping-fptoint-lowering` extends that same direct approach to `trunc_sat` instructions under `--emscripten`, eliminating branching overhead and reducing code size.
5b2a3f9 to
f0a2110
Compare
Now that 64-bit
trunc_satinstructions are supported directly inI64ToI32Lowering(#9017), and 32-bittrunc_satinstructions are handled directly inwasm2js(~~exprand~~expr >>> 0), we no longer need to runllvm-nontrapping-fptoint-loweringwhen--emscriptenis passed.In
wasm2js, trapping float-to-int operations (i32.trunc_*andi64.trunc_*) are already lowered to non-trapping JS conversions (~~exprand float arithmetic inI64ToI32Lowering), which do not trap on out-of-range values or NaN/Infinity (matching C/C++ UB semantics rather than strict Wasm trapping semantics).Removing
llvm-nontrapping-fptoint-loweringextends that same direct approach totrunc_satinstructions under--emscripten, eliminating branching overhead and reducing code size.Finally, add a commit to
LLVMNontrappingFPToIntLowering.cppabout it have no known users after this change.