binaryen
binaryen copied to clipboard
Optimizer and compiler/toolchain library for WebAssembly
Binaryen already has `getMaxBits` which check max possible bits for expressions and allow some optimizations without pattern matching. I propose calculate also "min possible bits" which open opportunities for simplifications...
I am calling binaryen's ModuleReader and ModuleWriter APIs from Rust and discovered that there are three cases in file.cpp where it calls `exit`. This isn't suitable for embedding in other...
This removes any hard-coded references to `env` (the mangic module name used by llvm and emscripten) and instead imports from whatever module name is used in import declaration.
More details in this [comment](https://github.com/WebAssembly/binaryen/pull/5044#pullrequestreview-1109698230).
### Bug Description ```sh echo "`binaryen/bin/wasm-opt --version` | `uname -m`" wasm-opt version 101 (version_101-62-g35f9da76d) | x86_64 git rev-parse HEAD 35f9da76d53401ba4de054f4db631ce4177b32f1 ``` `wasm-opt` produces an error when given a valid Wasm...
Say a compiler uses Binaryen as its backend, and the compiler reuses as much as possible from Binaryen, incrementally generating IR nodes and types while compiling a program. Now say...
```ts i32(x) % -C => i32(x) % C i64(x) % -C => i64(x) % C, if C != C_min ``` It may reduce size (however not sure) and canonicalize expression...
E.g. ```wat (i32.gt_u (i32.shr_u (local.get $0) (i32.const 1) ) (i32.const 100) ) =-> (i32.gt_u (local.get $0) (i32.const 201) ) ``` Instead of dividing by 2 and then comparing, we can...
E.g. ```wat (i32.lt_u (i32.ne (local.get $0) (i32.const 0) ) (i32.const 128) ) =-> (i32.const 1) ``` `i32.ne` returns 0 or 1, so it is max 1 bit, and that is...