diff options
author | Alon Zakai <azakai@google.com> | 2022-06-08 15:54:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-08 15:54:09 -0700 |
commit | 0b66981d0e3aa958877b5c04769e75836497b4c0 (patch) | |
tree | 6ae22c373eacba3bd31c283170de07ca7761ec21 /src/ir/module-utils.cpp | |
parent | b76d2fb1e5bb839249b25b7094db94219695f515 (diff) | |
download | binaryen-0b66981d0e3aa958877b5c04769e75836497b4c0.tar.gz binaryen-0b66981d0e3aa958877b5c04769e75836497b4c0.tar.bz2 binaryen-0b66981d0e3aa958877b5c04769e75836497b4c0.zip |
GlobalStructInference: Handle >2 globals if values coincide (#4714)
In GSI we look for a read of a global in a situation like this:
$global1: value1
$global2: value2
(struct.get $Type (ref))
If global inference shows this get must be of either $global1 or $global2, then we
can optimize to this:
(ref) == $global1 ? value1 : value2
We focus on the case of two values because 1 is handled by other passes, and >2
makes the tradeoffs less clear.
However, a simple extension is the case where there are more than 2 globals, but
there are only two values, and one value is unique to one global:
$global1: valueA
$global2: valueB
$global3: valueA
=>
(ref) == $global2 ? valueB : valueA
We can still use a single comparison here, on the global that has the
unique value. Then the else will handle all the other globals.
This increases the cases that GSI can optimize J2Wasm output by over 50%.
Diffstat (limited to 'src/ir/module-utils.cpp')
0 files changed, 0 insertions, 0 deletions