diff options
author | Alon Zakai <azakai@google.com> | 2023-07-27 13:30:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-27 20:30:21 +0000 |
commit | 8375f80fa789afaac58b0c86ba5c9396c2003635 (patch) | |
tree | d735c6473d3e293e5349a1467e61864059160661 /src/analysis | |
parent | 5d787c8d89915e257bd11d294ad5cbf882bac2e1 (diff) | |
download | binaryen-8375f80fa789afaac58b0c86ba5c9396c2003635.tar.gz binaryen-8375f80fa789afaac58b0c86ba5c9396c2003635.tar.bz2 binaryen-8375f80fa789afaac58b0c86ba5c9396c2003635.zip |
GUFA: Add a version that casts all of our inferences (#5846)
GUFA refines existing casts, but does not add new casts for fear of increasing code size
and adding more cast operations at runtime. This PR adds a version that does add all
those casts, and it looks like at least code size improves rather than regresses, at least
on J2Wasm and Kotlin. That is, this pass adds a lot more casts, but subsequent
optimizations benefit enough to shrink overall code size.
However, this may still not be worthwhile, as even if code size decreases we may end
up doing more casts at runtime, and those casts might be hard to remove, e.g.:
(call $foo
(x) ;; inferred to be non-null
)
(func $foo (param (ref null $A)
=>
(call $foo
(ref.cast $A (x) ;; add a cast here
)
(func $foo (param (ref $A) ;; later pass refines here
That new cast cannot be removed after we refine the function parameter. If the
function never benefits from the fact that the input is non-null, then the cast is
wasted work (e.g. if the function only compares the input to another value).
To use this new pass, try --gufa-cast-all rather than --gufa. As with normal GUFA,
running the full optimizer afterwards is important, and even more important in
order to get rid of as many of the new casts as possible.
Diffstat (limited to 'src/analysis')
0 files changed, 0 insertions, 0 deletions