diff options
author | Max Graey <maxgraey@gmail.com> | 2020-09-29 22:45:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-29 12:45:08 -0700 |
commit | 781da4c206c54e92b46358c00d079ada66cef0df (patch) | |
tree | 7a89e955a6ab224c65dd8af498865477c18cfcc2 /src/passes/OptimizeInstructions.cpp | |
parent | a629dc27bcb8022fad559ecdb2d3138e39183c6b (diff) | |
download | binaryen-781da4c206c54e92b46358c00d079ada66cef0df.tar.gz binaryen-781da4c206c54e92b46358c00d079ada66cef0df.tar.bz2 binaryen-781da4c206c54e92b46358c00d079ada66cef0df.zip |
Add also non-equal with zero simplification for boolean context (#3178)
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index d77db8093..b0d12eb95 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -1275,7 +1275,6 @@ private: if ((matches(curr, binary(Abstract::Eq, any(&left), ival(0))))) { return builder.makeUnary(EqZInt64, left); } - // Operations on one // (signed)x % 1 ==> 0 if (matches(curr, binary(Abstract::RemS, pure(&left), ival(1)))) { @@ -1298,7 +1297,9 @@ private: return left; } // i64(bool(x)) == 1 ==> i32(bool(x)) - if (matches(curr, binary(EqInt64, any(&left), i64(1))) && + // i64(bool(x)) != 0 ==> i32(bool(x)) + if ((matches(curr, binary(EqInt64, any(&left), i64(1))) || + matches(curr, binary(NeInt64, any(&left), i64(0)))) && Bits::getMaxBits(left, this) == 1) { return builder.makeUnary(WrapInt64, left); } |