diff options
author | Alon Zakai <azakai@google.com> | 2019-05-10 10:23:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-10 10:23:58 -0700 |
commit | d216f8742ba0663fffb035c577a5449bbc8a33a2 (patch) | |
tree | d01bc76ad836d0874e22f27fde6df8aff4ff06d8 /test/wasm2js/reinterpret.2asm.js.opt | |
parent | bdfdbfbbac4a0f47d8b789167697d6dd70a39720 (diff) | |
download | binaryen-d216f8742ba0663fffb035c577a5449bbc8a33a2.tar.gz binaryen-d216f8742ba0663fffb035c577a5449bbc8a33a2.tar.bz2 binaryen-d216f8742ba0663fffb035c577a5449bbc8a33a2.zip |
wasm2js: avoid reinterprets (#2094)
In JS a reinterpret is especially expensive, as we implement it as a write to a temp buffer and a read using another view. This finds places where we load a value from memory, then reinterpret it later - in that case, we can load it using another view, at the cost of another load and another local.
This is helpful on things like Box2D, where there are many reinterprets due to the main 2D vector class being an union over two floats/ints, and LLVM likes to do a single i64 load of them.
Diffstat (limited to 'test/wasm2js/reinterpret.2asm.js.opt')
-rw-r--r-- | test/wasm2js/reinterpret.2asm.js.opt | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/test/wasm2js/reinterpret.2asm.js.opt b/test/wasm2js/reinterpret.2asm.js.opt index 0088be0be..4c9856ca0 100644 --- a/test/wasm2js/reinterpret.2asm.js.opt +++ b/test/wasm2js/reinterpret.2asm.js.opt @@ -52,7 +52,7 @@ function asmFunc(global, env, buffer) { var infinity = global.Infinity; function $1($0) { $0 = $0 | 0; - return ($0 | 0) == ((wasm2js_scratch_store_f32((wasm2js_scratch_store_i32(0, $0), wasm2js_scratch_load_f32())), wasm2js_scratch_load_i32(0)) | 0) | 0; + return ((wasm2js_scratch_store_f32((wasm2js_scratch_store_i32(0, $0), wasm2js_scratch_load_f32())), wasm2js_scratch_load_i32(0)) | 0) == ($0 | 0) | 0; } function $2($0, $1_1) { @@ -67,18 +67,18 @@ function asmFunc(global, env, buffer) { } function legalstub$2($0, $1_1) { - var $2_1 = 0, $3 = 0, $4 = 0, $5 = 0; - $4 = $0; - $3 = 32; - $0 = $3 & 31; - if (32 >>> 0 <= $3 >>> 0) { + var $2_1 = 0, $3 = 0; + $3 = $0; + $2_1 = 32; + $0 = $2_1 & 31; + if (32 >>> 0 <= $2_1 >>> 0) { $2_1 = $1_1 << $0; $0 = 0; } else { - $2_1 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $2_1 << $0; + $2_1 = (1 << $0) - 1 & $1_1 >>> 32 - $0; $0 = $1_1 << $0; } - return $2($4 | $0, $2_1 | $5); + return $2($3 | $0, $2_1); } var FUNCTION_TABLE = []; |