diff options
author | Alon Zakai <azakai@google.com> | 2019-04-30 20:30:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-30 20:30:03 -0700 |
commit | 8d4bcd6e02bb0df3ac87e4850896ba733525b055 (patch) | |
tree | 1f98b878c22fd23c918992b53fd8e9f4f78d3788 /test/wasm2js/tee_local.2asm.js | |
parent | fba743ca5bdfe4fb437a36503b8983c5f42e4575 (diff) | |
download | binaryen-8d4bcd6e02bb0df3ac87e4850896ba733525b055.tar.gz binaryen-8d4bcd6e02bb0df3ac87e4850896ba733525b055.tar.bz2 binaryen-8d4bcd6e02bb0df3ac87e4850896ba733525b055.zip |
wasm2js: run full optimizations during the pipeline (#2071)
We flatten for the i64 lowering etc. passes, and it is worth optimizing afterwards, to clean up stuff they created. That is run if the user ran wasm2js with an optimization level (like wasm2js -O3).
Split the test files to check both optimized and unoptimized code.
Diffstat (limited to 'test/wasm2js/tee_local.2asm.js')
-rw-r--r-- | test/wasm2js/tee_local.2asm.js | 118 |
1 files changed, 69 insertions, 49 deletions
diff --git a/test/wasm2js/tee_local.2asm.js b/test/wasm2js/tee_local.2asm.js index 50ed49d10..fa6c70012 100644 --- a/test/wasm2js/tee_local.2asm.js +++ b/test/wasm2js/tee_local.2asm.js @@ -40,7 +40,7 @@ function asmFunc(global, env, buffer) { } function $3() { - return 0.0; + return +(0.0); } function $4($0_1) { @@ -64,7 +64,7 @@ function asmFunc(global, env, buffer) { function $7($0_1) { $0_1 = +$0_1; - return 12.2; + return +(12.2); } function $8($0_1, $0$hi, $1_1, $2_1, $3_1, $4_1) { @@ -144,31 +144,33 @@ function asmFunc(global, env, buffer) { function legalstub$1() { var i64toi32_i32$0 = 0, i64toi32_i32$4 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $7_1 = 0, $0_1 = 0, $0$hi = 0, i64toi32_i32$2 = 0; - i64toi32_i32$0 = $1(); + i64toi32_i32$0 = $1() | 0; i64toi32_i32$1 = i64toi32_i32$HIGH_BITS; $0_1 = i64toi32_i32$0; $0$hi = i64toi32_i32$1; i64toi32_i32$2 = i64toi32_i32$0; i64toi32_i32$0 = 0; i64toi32_i32$3 = 32; - i64toi32_i32$4 = i64toi32_i32$3 & 31; - if (32 >>> 0 <= (i64toi32_i32$3 & 63) >>> 0) { + i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; + if (32 >>> 0 <= (i64toi32_i32$3 & 63 | 0) >>> 0) { { i64toi32_i32$0 = 0; - $7_1 = i64toi32_i32$1 >>> i64toi32_i32$4; + $7_1 = i64toi32_i32$1 >>> i64toi32_i32$4 | 0; } } else { { - i64toi32_i32$0 = i64toi32_i32$1 >>> i64toi32_i32$4; - $7_1 = ((1 << i64toi32_i32$4) - 1 & i64toi32_i32$1) << 32 - i64toi32_i32$4 | i64toi32_i32$2 >>> i64toi32_i32$4; + i64toi32_i32$0 = i64toi32_i32$1 >>> i64toi32_i32$4 | 0; + $7_1 = (((1 << i64toi32_i32$4 | 0) - 1 | 0) & i64toi32_i32$1 | 0) << (32 - i64toi32_i32$4 | 0) | 0 | (i64toi32_i32$2 >>> i64toi32_i32$4 | 0) | 0; } } setTempRet0($7_1 | 0); i64toi32_i32$0 = $0$hi; - return $0_1; + return $0_1 | 0; } function legalstub$5($0_1, $1_1) { + $0_1 = $0_1 | 0; + $1_1 = $1_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$4 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $12 = 0, $13 = 0, $4_1 = 0, $4$hi = 0, $7$hi = 0, $2_1 = 0, $2$hi = 0; i64toi32_i32$0 = 0; $4_1 = $0_1; @@ -177,16 +179,16 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $1_1; i64toi32_i32$1 = 0; i64toi32_i32$3 = 32; - i64toi32_i32$4 = i64toi32_i32$3 & 31; - if (32 >>> 0 <= (i64toi32_i32$3 & 63) >>> 0) { + i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; + if (32 >>> 0 <= (i64toi32_i32$3 & 63 | 0) >>> 0) { { - i64toi32_i32$1 = i64toi32_i32$2 << i64toi32_i32$4; + i64toi32_i32$1 = i64toi32_i32$2 << i64toi32_i32$4 | 0; $12 = 0; } } else { { - i64toi32_i32$1 = (1 << i64toi32_i32$4) - 1 & i64toi32_i32$2 >>> 32 - i64toi32_i32$4 | i64toi32_i32$0 << i64toi32_i32$4; - $12 = i64toi32_i32$2 << i64toi32_i32$4; + i64toi32_i32$1 = ((1 << i64toi32_i32$4 | 0) - 1 | 0) & (i64toi32_i32$2 >>> (32 - i64toi32_i32$4 | 0) | 0) | 0 | (i64toi32_i32$0 << i64toi32_i32$4 | 0) | 0; + $12 = i64toi32_i32$2 << i64toi32_i32$4 | 0; } } $7$hi = i64toi32_i32$1; @@ -194,32 +196,38 @@ function asmFunc(global, env, buffer) { i64toi32_i32$0 = $4_1; i64toi32_i32$2 = $7$hi; i64toi32_i32$3 = $12; - i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - i64toi32_i32$2 = $5(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2); + i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2 | 0; + i64toi32_i32$2 = $5(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0) | 0; i64toi32_i32$0 = i64toi32_i32$HIGH_BITS; $2_1 = i64toi32_i32$2; $2$hi = i64toi32_i32$0; i64toi32_i32$1 = i64toi32_i32$2; i64toi32_i32$2 = 0; i64toi32_i32$3 = 32; - i64toi32_i32$4 = i64toi32_i32$3 & 31; - if (32 >>> 0 <= (i64toi32_i32$3 & 63) >>> 0) { + i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; + if (32 >>> 0 <= (i64toi32_i32$3 & 63 | 0) >>> 0) { { i64toi32_i32$2 = 0; - $13 = i64toi32_i32$0 >>> i64toi32_i32$4; + $13 = i64toi32_i32$0 >>> i64toi32_i32$4 | 0; } } else { { - i64toi32_i32$2 = i64toi32_i32$0 >>> i64toi32_i32$4; - $13 = ((1 << i64toi32_i32$4) - 1 & i64toi32_i32$0) << 32 - i64toi32_i32$4 | i64toi32_i32$1 >>> i64toi32_i32$4; + i64toi32_i32$2 = i64toi32_i32$0 >>> i64toi32_i32$4 | 0; + $13 = (((1 << i64toi32_i32$4 | 0) - 1 | 0) & i64toi32_i32$0 | 0) << (32 - i64toi32_i32$4 | 0) | 0 | (i64toi32_i32$1 >>> i64toi32_i32$4 | 0) | 0; } } setTempRet0($13 | 0); i64toi32_i32$2 = $2$hi; - return $2_1; + return $2_1 | 0; } function legalstub$8($0_1, $1_1, $2_1, $3_1, $4_1, $5_1) { + $0_1 = $0_1 | 0; + $1_1 = $1_1 | 0; + $2_1 = Math_fround($2_1); + $3_1 = +$3_1; + $4_1 = $4_1 | 0; + $5_1 = $5_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, i64toi32_i32$3 = 0, $14 = 0, $7_1 = 0, $7$hi = 0, $10$hi = 0; i64toi32_i32$0 = 0; $7_1 = $0_1; @@ -228,16 +236,16 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $1_1; i64toi32_i32$1 = 0; i64toi32_i32$3 = 32; - i64toi32_i32$4 = i64toi32_i32$3 & 31; - if (32 >>> 0 <= (i64toi32_i32$3 & 63) >>> 0) { + i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; + if (32 >>> 0 <= (i64toi32_i32$3 & 63 | 0) >>> 0) { { - i64toi32_i32$1 = i64toi32_i32$2 << i64toi32_i32$4; + i64toi32_i32$1 = i64toi32_i32$2 << i64toi32_i32$4 | 0; $14 = 0; } } else { { - i64toi32_i32$1 = (1 << i64toi32_i32$4) - 1 & i64toi32_i32$2 >>> 32 - i64toi32_i32$4 | i64toi32_i32$0 << i64toi32_i32$4; - $14 = i64toi32_i32$2 << i64toi32_i32$4; + i64toi32_i32$1 = ((1 << i64toi32_i32$4 | 0) - 1 | 0) & (i64toi32_i32$2 >>> (32 - i64toi32_i32$4 | 0) | 0) | 0 | (i64toi32_i32$0 << i64toi32_i32$4 | 0) | 0; + $14 = i64toi32_i32$2 << i64toi32_i32$4 | 0; } } $10$hi = i64toi32_i32$1; @@ -245,11 +253,17 @@ function asmFunc(global, env, buffer) { i64toi32_i32$0 = $7_1; i64toi32_i32$2 = $10$hi; i64toi32_i32$3 = $14; - i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - $8(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2, $2_1, $3_1, $4_1, $5_1); + i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2 | 0; + $8(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0, Math_fround($2_1), +$3_1, $4_1 | 0, $5_1 | 0); } function legalstub$9($0_1, $1_1, $2_1, $3_1, $4_1, $5_1) { + $0_1 = $0_1 | 0; + $1_1 = $1_1 | 0; + $2_1 = Math_fround($2_1); + $3_1 = +$3_1; + $4_1 = $4_1 | 0; + $5_1 = $5_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$4 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$3 = 0, $16 = 0, $17 = 0, $8_1 = 0, $8$hi = 0, $11$hi = 0, $6_1 = 0, $6$hi = 0; i64toi32_i32$0 = 0; $8_1 = $0_1; @@ -258,16 +272,16 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $1_1; i64toi32_i32$1 = 0; i64toi32_i32$3 = 32; - i64toi32_i32$4 = i64toi32_i32$3 & 31; - if (32 >>> 0 <= (i64toi32_i32$3 & 63) >>> 0) { + i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; + if (32 >>> 0 <= (i64toi32_i32$3 & 63 | 0) >>> 0) { { - i64toi32_i32$1 = i64toi32_i32$2 << i64toi32_i32$4; + i64toi32_i32$1 = i64toi32_i32$2 << i64toi32_i32$4 | 0; $16 = 0; } } else { { - i64toi32_i32$1 = (1 << i64toi32_i32$4) - 1 & i64toi32_i32$2 >>> 32 - i64toi32_i32$4 | i64toi32_i32$0 << i64toi32_i32$4; - $16 = i64toi32_i32$2 << i64toi32_i32$4; + i64toi32_i32$1 = ((1 << i64toi32_i32$4 | 0) - 1 | 0) & (i64toi32_i32$2 >>> (32 - i64toi32_i32$4 | 0) | 0) | 0 | (i64toi32_i32$0 << i64toi32_i32$4 | 0) | 0; + $16 = i64toi32_i32$2 << i64toi32_i32$4 | 0; } } $11$hi = i64toi32_i32$1; @@ -275,32 +289,38 @@ function asmFunc(global, env, buffer) { i64toi32_i32$0 = $8_1; i64toi32_i32$2 = $11$hi; i64toi32_i32$3 = $16; - i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - i64toi32_i32$2 = $9(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2, $2_1, $3_1, $4_1, $5_1); + i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2 | 0; + i64toi32_i32$2 = $9(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0, Math_fround($2_1), +$3_1, $4_1 | 0, $5_1 | 0) | 0; i64toi32_i32$0 = i64toi32_i32$HIGH_BITS; $6_1 = i64toi32_i32$2; $6$hi = i64toi32_i32$0; i64toi32_i32$1 = i64toi32_i32$2; i64toi32_i32$2 = 0; i64toi32_i32$3 = 32; - i64toi32_i32$4 = i64toi32_i32$3 & 31; - if (32 >>> 0 <= (i64toi32_i32$3 & 63) >>> 0) { + i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; + if (32 >>> 0 <= (i64toi32_i32$3 & 63 | 0) >>> 0) { { i64toi32_i32$2 = 0; - $17 = i64toi32_i32$0 >>> i64toi32_i32$4; + $17 = i64toi32_i32$0 >>> i64toi32_i32$4 | 0; } } else { { - i64toi32_i32$2 = i64toi32_i32$0 >>> i64toi32_i32$4; - $17 = ((1 << i64toi32_i32$4) - 1 & i64toi32_i32$0) << 32 - i64toi32_i32$4 | i64toi32_i32$1 >>> i64toi32_i32$4; + i64toi32_i32$2 = i64toi32_i32$0 >>> i64toi32_i32$4 | 0; + $17 = (((1 << i64toi32_i32$4 | 0) - 1 | 0) & i64toi32_i32$0 | 0) << (32 - i64toi32_i32$4 | 0) | 0 | (i64toi32_i32$1 >>> i64toi32_i32$4 | 0) | 0; } } setTempRet0($17 | 0); i64toi32_i32$2 = $6$hi; - return $6_1; + return $6_1 | 0; } function legalstub$10($0_1, $1_1, $2_1, $3_1, $4_1, $5_1) { + $0_1 = $0_1 | 0; + $1_1 = $1_1 | 0; + $2_1 = Math_fround($2_1); + $3_1 = +$3_1; + $4_1 = $4_1 | 0; + $5_1 = $5_1 | 0; var i64toi32_i32$2 = 0, i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$4 = 0, i64toi32_i32$3 = 0, $14 = 0, $7_1 = 0, $7$hi = 0, $10$hi = 0; i64toi32_i32$0 = 0; $7_1 = $0_1; @@ -309,16 +329,16 @@ function asmFunc(global, env, buffer) { i64toi32_i32$2 = $1_1; i64toi32_i32$1 = 0; i64toi32_i32$3 = 32; - i64toi32_i32$4 = i64toi32_i32$3 & 31; - if (32 >>> 0 <= (i64toi32_i32$3 & 63) >>> 0) { + i64toi32_i32$4 = i64toi32_i32$3 & 31 | 0; + if (32 >>> 0 <= (i64toi32_i32$3 & 63 | 0) >>> 0) { { - i64toi32_i32$1 = i64toi32_i32$2 << i64toi32_i32$4; + i64toi32_i32$1 = i64toi32_i32$2 << i64toi32_i32$4 | 0; $14 = 0; } } else { { - i64toi32_i32$1 = (1 << i64toi32_i32$4) - 1 & i64toi32_i32$2 >>> 32 - i64toi32_i32$4 | i64toi32_i32$0 << i64toi32_i32$4; - $14 = i64toi32_i32$2 << i64toi32_i32$4; + i64toi32_i32$1 = ((1 << i64toi32_i32$4 | 0) - 1 | 0) & (i64toi32_i32$2 >>> (32 - i64toi32_i32$4 | 0) | 0) | 0 | (i64toi32_i32$0 << i64toi32_i32$4 | 0) | 0; + $14 = i64toi32_i32$2 << i64toi32_i32$4 | 0; } } $10$hi = i64toi32_i32$1; @@ -326,8 +346,8 @@ function asmFunc(global, env, buffer) { i64toi32_i32$0 = $7_1; i64toi32_i32$2 = $10$hi; i64toi32_i32$3 = $14; - i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2; - return $10(i64toi32_i32$0 | i64toi32_i32$3, i64toi32_i32$2, $2_1, $3_1, $4_1, $5_1); + i64toi32_i32$2 = i64toi32_i32$1 | i64toi32_i32$2 | 0; + return +(+$10(i64toi32_i32$0 | i64toi32_i32$3 | 0 | 0, i64toi32_i32$2 | 0, Math_fround($2_1), +$3_1, $4_1 | 0, $5_1 | 0)); } var FUNCTION_TABLE = []; |