diff options
author | Max Graey <maxgraey@gmail.com> | 2020-11-10 21:41:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 11:41:22 -0800 |
commit | 0c20d9f427b63a6fdc354bb917c11f382068eaec (patch) | |
tree | 750a49a311872f566d6c5b91a29d19d5f2a2e3c1 /test/wasm2js | |
parent | 5d2c13f16af2183a5d1861828e512fe0f964990c (diff) | |
download | binaryen-0c20d9f427b63a6fdc354bb917c11f382068eaec.tar.gz binaryen-0c20d9f427b63a6fdc354bb917c11f382068eaec.tar.bz2 binaryen-0c20d9f427b63a6fdc354bb917c11f382068eaec.zip |
Canonicalize subtraction with constant on the right to addition (#3321)
Using addition in more places is better for gzip, and helps simplify the
optimizer as well.
Add a FinalOptimizer phase to do optimizations like our signed LEB tweaks, to
reduce binary size in the rare case when we do want a subtraction.
Diffstat (limited to 'test/wasm2js')
-rw-r--r-- | test/wasm2js/atomics_32.2asm.js | 2 | ||||
-rw-r--r-- | test/wasm2js/atomics_32.2asm.js.opt | 2 | ||||
-rw-r--r-- | test/wasm2js/bulk-memory.2asm.js | 6 | ||||
-rw-r--r-- | test/wasm2js/bulk-memory.2asm.js.opt | 4 | ||||
-rw-r--r-- | test/wasm2js/dynamicLibrary.2asm.js | 2 | ||||
-rw-r--r-- | test/wasm2js/dynamicLibrary.2asm.js.opt | 2 | ||||
-rw-r--r-- | test/wasm2js/emscripten-grow-no.2asm.js | 2 | ||||
-rw-r--r-- | test/wasm2js/emscripten-grow-no.2asm.js.opt | 2 | ||||
-rw-r--r-- | test/wasm2js/emscripten-grow-yes.2asm.js | 2 | ||||
-rw-r--r-- | test/wasm2js/emscripten-grow-yes.2asm.js.opt | 2 | ||||
-rw-r--r-- | test/wasm2js/emscripten.2asm.js | 2 | ||||
-rw-r--r-- | test/wasm2js/emscripten.2asm.js.opt | 2 | ||||
-rw-r--r-- | test/wasm2js/i64-ctz.2asm.js.opt | 4 | ||||
-rw-r--r-- | test/wasm2js/unary-ops.2asm.js.opt | 6 |
14 files changed, 20 insertions, 20 deletions
diff --git a/test/wasm2js/atomics_32.2asm.js b/test/wasm2js/atomics_32.2asm.js index 12cdbe8ff..d3c1ba22b 100644 --- a/test/wasm2js/atomics_32.2asm.js +++ b/test/wasm2js/atomics_32.2asm.js @@ -147,7 +147,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "aGVsbG8s"); memorySegments[1] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "d29ybGQh"); diff --git a/test/wasm2js/atomics_32.2asm.js.opt b/test/wasm2js/atomics_32.2asm.js.opt index 4a7a5d85f..a12b684dc 100644 --- a/test/wasm2js/atomics_32.2asm.js.opt +++ b/test/wasm2js/atomics_32.2asm.js.opt @@ -143,7 +143,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "aGVsbG8s"); memorySegments[1] = base64DecodeToExistingUint8Array(new Uint8Array(6), 0, "d29ybGQh"); diff --git a/test/wasm2js/bulk-memory.2asm.js b/test/wasm2js/bulk-memory.2asm.js index 2b7431486..c847dbdfd 100644 --- a/test/wasm2js/bulk-memory.2asm.js +++ b/test/wasm2js/bulk-memory.2asm.js @@ -180,7 +180,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 0, "qrvM3Q=="); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); } @@ -287,7 +287,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(4), 0, "qrvM3Q=="); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); } @@ -405,7 +405,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(0), 0, ""); base64DecodeToExistingUint8Array(bufferView, 0, ""); diff --git a/test/wasm2js/bulk-memory.2asm.js.opt b/test/wasm2js/bulk-memory.2asm.js.opt index 77e682c41..4e6ccc529 100644 --- a/test/wasm2js/bulk-memory.2asm.js.opt +++ b/test/wasm2js/bulk-memory.2asm.js.opt @@ -180,7 +180,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 0, "qrvM3Q=="); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); } @@ -287,7 +287,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } memorySegments[0] = base64DecodeToExistingUint8Array(new Uint8Array(4), 0, "qrvM3Q=="); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); } diff --git a/test/wasm2js/dynamicLibrary.2asm.js b/test/wasm2js/dynamicLibrary.2asm.js index b570fab36..22d483f45 100644 --- a/test/wasm2js/dynamicLibrary.2asm.js +++ b/test/wasm2js/dynamicLibrary.2asm.js @@ -81,7 +81,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, memoryBase, "ZHluYW1pYyBkYXRh"); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }, diff --git a/test/wasm2js/dynamicLibrary.2asm.js.opt b/test/wasm2js/dynamicLibrary.2asm.js.opt index 4d7b4ac42..cd959acb8 100644 --- a/test/wasm2js/dynamicLibrary.2asm.js.opt +++ b/test/wasm2js/dynamicLibrary.2asm.js.opt @@ -73,7 +73,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, memoryBase, "ZHluYW1pYyBkYXRh"); var retasmFunc = asmFunc( { abort: function() { throw new Error('abort'); }, diff --git a/test/wasm2js/emscripten-grow-no.2asm.js b/test/wasm2js/emscripten-grow-no.2asm.js index 998527287..4d6bb4c77 100644 --- a/test/wasm2js/emscripten-grow-no.2asm.js +++ b/test/wasm2js/emscripten-grow-no.2asm.js @@ -63,7 +63,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1600, "YWJj"); return asmFunc(asmLibraryArg, wasmMemory.buffer) diff --git a/test/wasm2js/emscripten-grow-no.2asm.js.opt b/test/wasm2js/emscripten-grow-no.2asm.js.opt index 998527287..4d6bb4c77 100644 --- a/test/wasm2js/emscripten-grow-no.2asm.js.opt +++ b/test/wasm2js/emscripten-grow-no.2asm.js.opt @@ -63,7 +63,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1600, "YWJj"); return asmFunc(asmLibraryArg, wasmMemory.buffer) diff --git a/test/wasm2js/emscripten-grow-yes.2asm.js b/test/wasm2js/emscripten-grow-yes.2asm.js index 3cb5371b1..213524377 100644 --- a/test/wasm2js/emscripten-grow-yes.2asm.js +++ b/test/wasm2js/emscripten-grow-yes.2asm.js @@ -87,7 +87,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1600, "YWJj"); return asmFunc(asmLibraryArg, wasmMemory.buffer) diff --git a/test/wasm2js/emscripten-grow-yes.2asm.js.opt b/test/wasm2js/emscripten-grow-yes.2asm.js.opt index 3cb5371b1..213524377 100644 --- a/test/wasm2js/emscripten-grow-yes.2asm.js.opt +++ b/test/wasm2js/emscripten-grow-yes.2asm.js.opt @@ -87,7 +87,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1600, "YWJj"); return asmFunc(asmLibraryArg, wasmMemory.buffer) diff --git a/test/wasm2js/emscripten.2asm.js b/test/wasm2js/emscripten.2asm.js index 9d08b03a2..e71aaaa83 100644 --- a/test/wasm2js/emscripten.2asm.js +++ b/test/wasm2js/emscripten.2asm.js @@ -220,7 +220,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1024, "aGVsbG8sIHdvcmxkIQoAAJwMAAAtKyAgIDBYMHgAKG51bGwpAAAAAAAAAAAAAAAAEQAKABEREQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAARAA8KERERAwoHAAETCQsLAAAJBgsAAAsABhEAAAAREREAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAEQAKChEREQAKAAACAAkLAAAACQALAAALAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAADAAAAAAJDAAAAAAADAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAANAAAABA0AAAAACQ4AAAAAAA4AAA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAADwAAAAAPAAAAAAkQAAAAAAAQAAAQAAASAAAAEhISAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAS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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="); diff --git a/test/wasm2js/emscripten.2asm.js.opt b/test/wasm2js/emscripten.2asm.js.opt index 0e438f81d..05ecfea7d 100644 --- a/test/wasm2js/emscripten.2asm.js.opt +++ b/test/wasm2js/emscripten.2asm.js.opt @@ -201,7 +201,7 @@ for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; } - return uint8Array; + return uint8Array; } base64DecodeToExistingUint8Array(bufferView, 1024, "aGVsbG8sIHdvcmxkIQoAAJwMAAAtKyAgIDBYMHgAKG51bGwp"); base64DecodeToExistingUint8Array(bufferView, 1072, "EQAKABEREQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAARAA8KERERAwoHAAETCQsLAAAJBgsAAAsABhEAAAARERE="); diff --git a/test/wasm2js/i64-ctz.2asm.js.opt b/test/wasm2js/i64-ctz.2asm.js.opt index aaacbfc51..9cda827f4 100644 --- a/test/wasm2js/i64-ctz.2asm.js.opt +++ b/test/wasm2js/i64-ctz.2asm.js.opt @@ -30,8 +30,8 @@ function asmFunc(env) { function __wasm_ctz_i64($0, $1) { var $2 = 0, $3 = 0; if ($0 | $1) { - $2 = $1 + -1 | 0; - $3 = $0 + -1 | 0; + $2 = $1 - 1 | 0; + $3 = $0 - 1 | 0; $2 = ($3 | 0) != -1 ? $2 + 1 | 0 : $2; $3 = Math_clz32($0 ^ $3) + 32 | 0; $0 = Math_clz32($1 ^ $2); diff --git a/test/wasm2js/unary-ops.2asm.js.opt b/test/wasm2js/unary-ops.2asm.js.opt index b854489b6..272ea822c 100644 --- a/test/wasm2js/unary-ops.2asm.js.opt +++ b/test/wasm2js/unary-ops.2asm.js.opt @@ -26,7 +26,7 @@ function asmFunc(env) { function $7($0) { $0 = $0 | 0; if ($0) { - $0 = 31 - Math_clz32($0 + -1 ^ $0) | 0 + $0 = 31 - Math_clz32($0 - 1 ^ $0) | 0 } else { $0 = 32 } @@ -71,8 +71,8 @@ function asmFunc(env) { function __wasm_ctz_i64($0, $1_1) { var $2 = 0, $3 = 0; if ($0 | $1_1) { - $2 = $1_1 + -1 | 0; - $3 = $0 + -1 | 0; + $2 = $1_1 - 1 | 0; + $3 = $0 - 1 | 0; $2 = ($3 | 0) != -1 ? $2 + 1 | 0 : $2; $3 = Math_clz32($0 ^ $3) + 32 | 0; $0 = Math_clz32($1_1 ^ $2); |