diff options
author | Max Graey <maxgraey@gmail.com> | 2021-09-10 02:27:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-09 16:27:21 -0700 |
commit | 0bc719505457acc1a92894b3995ce233fb0cdb20 (patch) | |
tree | a544c18f49c7497b6b1919e45692a93ab0f124ff /src/wasm/wasm-s-parser.cpp | |
parent | d127f82d7dbe27a35e07a4f3a723fa7b6811c756 (diff) | |
download | binaryen-0bc719505457acc1a92894b3995ce233fb0cdb20.tar.gz binaryen-0bc719505457acc1a92894b3995ce233fb0cdb20.tar.bz2 binaryen-0bc719505457acc1a92894b3995ce233fb0cdb20.zip |
[OptimizeInstructions] propagate sign for integer multiplication (#4098)
```ts
-x * -y => (x * y)
-x * y => -(x * y)
x * -y => -(x * y), if x != C && y != C
-x * C => x * -C, if C != C_pot || shrinkLevel != 0
-x * C => -(x * C), otherwise
```
We are skipping propagation when lhs and rhs are constants because this should handled by constant folding. Also skip cases like `-x * 4 -> x * -4` for `shrinkLevel != 0`, as this will be further converted to `-(x << 2)`.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
0 files changed, 0 insertions, 0 deletions