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/stack-modified.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/stack-modified.2asm.js.opt')
-rw-r--r-- | test/wasm2js/stack-modified.2asm.js.opt | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/test/wasm2js/stack-modified.2asm.js.opt b/test/wasm2js/stack-modified.2asm.js.opt index b31f4f147..baabfe868 100644 --- a/test/wasm2js/stack-modified.2asm.js.opt +++ b/test/wasm2js/stack-modified.2asm.js.opt @@ -45,53 +45,53 @@ function asmFunc(global, env, buffer) { } function legalstub$0($0_1, $1) { - var $2 = 0, $3 = 0, $4 = 0, $5 = 0; - $4 = $0_1; - $3 = 32; - $0_1 = $3 & 31; - if (32 >>> 0 <= $3 >>> 0) { + var $2 = 0, $3 = 0; + $3 = $0_1; + $2 = 32; + $0_1 = $2 & 31; + if (32 >>> 0 <= $2 >>> 0) { $2 = $1 << $0_1; $0_1 = 0; } else { - $2 = (1 << $0_1) - 1 & $1 >>> 32 - $0_1 | $2 << $0_1; + $2 = (1 << $0_1) - 1 & $1 >>> 32 - $0_1; $0_1 = $1 << $0_1; } - $1 = $0($4 | $0_1, $2 | $5); - $2 = i64toi32_i32$HIGH_BITS; - $0_1 = 32 & 31; - setTempRet0((32 >>> 0 <= $3 >>> 0 ? $2 >>> $0_1 : ((1 << $0_1) - 1 & $2) << 32 - $0_1 | $1 >>> $0_1) | 0); - return $1; + $0_1 = $0($3 | $0_1, $2); + $1 = i64toi32_i32$HIGH_BITS; + $3 = 32; + $2 = $3 & 31; + setTempRet0((32 >>> 0 <= $3 >>> 0 ? $1 >>> $2 : ((1 << $2) - 1 & $1) << 32 - $2 | $0_1 >>> $2) | 0); + return $0_1; } function _ZN17compiler_builtins3int3mul3Mul3mul17h070e9a1c69faec5bE($0_1, $1, $2, $3) { var $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $10 = 0; - $5 = $2 >>> 16; - $6 = $0_1 >>> 16; - $4 = Math_imul($5, $6); - $8 = $2 & 65535; - $7 = $0_1 & 65535; - $9 = Math_imul($8, $7); - $6 = ($9 >>> 16) + Math_imul($6, $8) | 0; - $5 = ($6 & 65535) + Math_imul($5, $7) | 0; - $8 = 0; - $10 = $4; - $7 = $0_1; - $4 = 32; - $0_1 = $4 & 31; - $4 = $10 + Math_imul(32 >>> 0 <= $4 >>> 0 ? $1 >>> $0_1 : ((1 << $0_1) - 1 & $1) << 32 - $0_1 | $7 >>> $0_1, $2) | 0; + $6 = $2 >>> 16; + $10 = $0_1; + $7 = $0_1 >>> 16; + $5 = Math_imul($6, $7); + $4 = $2 & 65535; + $8 = $0_1 & 65535; + $9 = Math_imul($4, $8); + $7 = ($9 >>> 16) + Math_imul($4, $7) | 0; + $6 = ($7 & 65535) + Math_imul($6, $8) | 0; + $8 = $5; + $5 = 32; + $4 = $5 & 31; + $5 = $8 + Math_imul(32 >>> 0 <= $5 >>> 0 ? $1 >>> $4 : ((1 << $4) - 1 & $1) << 32 - $4 | $0_1 >>> $4, $2) | 0; $1 = $2; $2 = 32; $0_1 = $2 & 31; - $1 = (($4 + Math_imul($7, 32 >>> 0 <= $2 >>> 0 ? $3 >>> $0_1 : ((1 << $0_1) - 1 & $3) << 32 - $0_1 | $1 >>> $0_1) | 0) + ($6 >>> 16) | 0) + ($5 >>> 16) | 0; + $1 = (($5 + Math_imul($10, 32 >>> 0 <= $2 >>> 0 ? $3 >>> $0_1 : ((1 << $0_1) - 1 & $3) << 32 - $0_1 | $1 >>> $0_1) | 0) + ($7 >>> 16) | 0) + ($6 >>> 16) | 0; $0_1 = 32 & 31; if (32 >>> 0 <= $2 >>> 0) { $2 = $1 << $0_1; $0_1 = 0; } else { - $2 = (1 << $0_1) - 1 & $1 >>> 32 - $0_1 | $8 << $0_1; + $2 = (1 << $0_1) - 1 & $1 >>> 32 - $0_1; $0_1 = $1 << $0_1; } - $0_1 = $0_1 | ($9 & 65535 | $5 << 16); + $0_1 = $0_1 | ($9 & 65535 | $6 << 16); i64toi32_i32$HIGH_BITS = $2; return $0_1; } |