diff options
author | Alon Zakai <azakai@google.com> | 2022-11-01 16:20:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-01 16:20:06 -0700 |
commit | a030cc7f69a00dc0e699b8b580224126650c738b (patch) | |
tree | 6e3bee6e6cdf0aca66ecf26406ef66760ba908a6 /test/wasm2js | |
parent | 0db7b571b23a09f96810c9d65d5f88d8eae4ba52 (diff) | |
download | binaryen-a030cc7f69a00dc0e699b8b580224126650c738b.tar.gz binaryen-a030cc7f69a00dc0e699b8b580224126650c738b.tar.bz2 binaryen-a030cc7f69a00dc0e699b8b580224126650c738b.zip |
[Wasm GC] SimplifyLocals: Switch local.get to use a more refined type when possible (#5194)
(local.set $refined (cast (local.get $plain)))
..
.. (local.get $plain) .. ;; we can change this to read from $refined
By using the more refined type we may be able to eliminate casts later.
To do this, look at the fallthrough value (so we can look through a cast or a block
value - this is the reason for the small wasm2js improvements in tests), and also
extend the code that picks which local index to read to look at types (previously
we just ignored any pairs of locals with different types).
Diffstat (limited to 'test/wasm2js')
-rw-r--r-- | test/wasm2js/conversions-modified.2asm.js.opt | 3 | ||||
-rw-r--r-- | test/wasm2js/float_literals-modified.2asm.js.opt | 54 | ||||
-rw-r--r-- | test/wasm2js/i64-ctz.2asm.js.opt | 5 | ||||
-rw-r--r-- | test/wasm2js/stack-modified.2asm.js.opt | 19 | ||||
-rw-r--r-- | test/wasm2js/unary-ops.2asm.js.opt | 2 |
5 files changed, 30 insertions, 53 deletions
diff --git a/test/wasm2js/conversions-modified.2asm.js.opt b/test/wasm2js/conversions-modified.2asm.js.opt index 36bfda8cb..4c2b6d1ae 100644 --- a/test/wasm2js/conversions-modified.2asm.js.opt +++ b/test/wasm2js/conversions-modified.2asm.js.opt @@ -162,9 +162,8 @@ function asmFunc(imports) { $1 = wasm2js_scratch_load_i32(1) | 0; $2 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $1; - $1 = $2; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $1; + return $2; } return { diff --git a/test/wasm2js/float_literals-modified.2asm.js.opt b/test/wasm2js/float_literals-modified.2asm.js.opt index 1e69b6304..613e52a40 100644 --- a/test/wasm2js/float_literals-modified.2asm.js.opt +++ b/test/wasm2js/float_literals-modified.2asm.js.opt @@ -108,9 +108,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$32() { @@ -119,9 +118,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$34() { @@ -130,9 +128,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$35() { @@ -141,9 +138,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$36() { @@ -152,9 +148,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$37() { @@ -163,9 +158,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$38() { @@ -174,9 +168,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$39() { @@ -185,9 +178,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$41() { @@ -196,9 +188,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$42() { @@ -207,9 +198,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$44() { @@ -218,9 +208,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$45() { @@ -229,9 +218,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$46() { @@ -240,9 +228,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$47() { @@ -251,9 +238,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$48() { @@ -262,9 +248,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$49() { @@ -273,9 +258,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$50() { @@ -284,9 +268,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } function legalstub$59() { @@ -295,9 +278,8 @@ function asmFunc(imports) { $0_1 = wasm2js_scratch_load_i32(1) | 0; $1 = wasm2js_scratch_load_i32(0) | 0; i64toi32_i32$HIGH_BITS = $0_1; - $0_1 = $1; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0_1; + return $1; } return { diff --git a/test/wasm2js/i64-ctz.2asm.js.opt b/test/wasm2js/i64-ctz.2asm.js.opt index c232bef7c..0d6ffd697 100644 --- a/test/wasm2js/i64-ctz.2asm.js.opt +++ b/test/wasm2js/i64-ctz.2asm.js.opt @@ -22,7 +22,7 @@ function asmFunc(imports) { while (1) { if ($0 | $2) { $1 = $0; - $0 = $0 - 1 & $0; + $0 = $1 & $1 - 1; $2 = $2 - !$1 & $2; $3 = $3 + 1 | 0; $4 = $3 ? $4 : $4 + 1 | 0; @@ -31,9 +31,8 @@ function asmFunc(imports) { break; }; i64toi32_i32$HIGH_BITS = $4; - $0 = $3; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0; + return $3; } function legalstub$ctz64($0, $1) { diff --git a/test/wasm2js/stack-modified.2asm.js.opt b/test/wasm2js/stack-modified.2asm.js.opt index c3d9d7d57..45203a50e 100644 --- a/test/wasm2js/stack-modified.2asm.js.opt +++ b/test/wasm2js/stack-modified.2asm.js.opt @@ -17,24 +17,21 @@ function asmFunc(imports) { var setTempRet0 = env.setTempRet0; var i64toi32_i32$HIGH_BITS = 0; function legalstub$0($0, $1) { - var $2 = 0, $3 = 0, $4 = 0; - $2 = $1; - $3 = 1; + var $2 = 0, $3 = 0; + $2 = 1; while (1) { - if ($0 | $2) { - $3 = __wasm_i64_mul($0, $2, $3, $4); - $4 = i64toi32_i32$HIGH_BITS; - $1 = $0; + if ($0 | $1) { + $2 = __wasm_i64_mul($0, $1, $2, $3); + $3 = i64toi32_i32$HIGH_BITS; + $1 = $1 - !$0 | 0; $0 = $0 - 1 | 0; - $2 = $2 - !$1 | 0; continue; } break; }; - i64toi32_i32$HIGH_BITS = $4; - $0 = $3; + i64toi32_i32$HIGH_BITS = $3; setTempRet0(i64toi32_i32$HIGH_BITS | 0); - return $0; + return $2; } function __wasm_i64_mul($0, $1, $2, $3) { diff --git a/test/wasm2js/unary-ops.2asm.js.opt b/test/wasm2js/unary-ops.2asm.js.opt index 4da12af66..bca65089b 100644 --- a/test/wasm2js/unary-ops.2asm.js.opt +++ b/test/wasm2js/unary-ops.2asm.js.opt @@ -48,7 +48,7 @@ function asmFunc(imports) { while (1) { if ($1_1 | $4) { $0 = $4; - $4 = $4 - 1 & $4; + $4 = $0 & $0 - 1; $1_1 = $1_1 - !$0 & $1_1; $5 = $5 + 1 | 0; $6_1 = $5 ? $6_1 : $6_1 + 1 | 0; |