diff options
author | Alon Zakai <azakai@google.com> | 2022-09-01 10:34:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-01 10:34:19 -0700 |
commit | f058bb53b3d8977f800894d305b7f537b9aff3d5 (patch) | |
tree | 2da33a1d13c9d8c0b63c8fdbfb2f00993d0740e4 /test/example/c-api-unused-mem.cpp | |
parent | 7c5f6c2aca80d70cf05fc83739f87ff23c75a1e3 (diff) | |
download | binaryen-f058bb53b3d8977f800894d305b7f537b9aff3d5.tar.gz binaryen-f058bb53b3d8977f800894d305b7f537b9aff3d5.tar.bz2 binaryen-f058bb53b3d8977f800894d305b7f537b9aff3d5.zip |
OptimizeInstructions: Select => and/or in more cases (#4154)
x ? 0 : y ==> z & y where z = !x
x ? y : 1 ==> z | y where z = !x
Only do this when we have z = !x, that is, we can invert x without adding
an actual eqz (which would add work).
To do this, canonicalize selects to prefer to flip the arms, when
possible, if it would move a constant to a location that the existing
optimizations already turn into an and/or. That is,
x >= 5 ? 0 : y != 42
would be canonicalized into
x < 5 ? y != 42 : 0
and existing opts turn that into
(x < 5) & (y != 42)
The canonicalization does not always help this optimization, as we need
the values to be boolean to do this, but canonicalizing is still nice to get
more regular code which might compress slightly better.
Diffstat (limited to 'test/example/c-api-unused-mem.cpp')
0 files changed, 0 insertions, 0 deletions