Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Optimize integer arithmetic #116

Open
vouillon opened this issue Oct 24, 2024 · 0 comments
Open

[FEATURE REQUEST] Optimize integer arithmetic #116

vouillon opened this issue Oct 24, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@vouillon
Copy link
Collaborator

We could eliminate some unnecessary conversions between 31- and 32-bits integers.

Binaryen does not optimize this at all at the moment. We could implement a pass in Binaryen and/or perform this optimization in Wasm_of_ocaml.

For instance,

(ref.i31 (i32.add (i31.get_s (ref.i31 (local.get $x))) (local.get $y)))

is equivalent to

(ref.i31 (i32.add (local.get $x) (local.get $y)))

We might be able to do more optimizations in Wasm_of_ocaml since we know better the structure of the code that we generate (keep the index of a for loop in a 32-bit integer, interprocedural optimization, ...)

@vouillon vouillon added the enhancement New feature or request label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant