diff options
author | Alon Zakai <azakai@google.com> | 2019-04-24 15:27:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-24 15:27:05 -0700 |
commit | c3ed0f176b36a502ef2e1fd915550a808b8d8f0b (patch) | |
tree | 6abff96331025a74e18cfa4f173a997d3c800559 /test/wasm2js/f32.2asm.js | |
parent | bc0a605e8864324d40aafbd00e8de0e50240ce26 (diff) | |
download | binaryen-c3ed0f176b36a502ef2e1fd915550a808b8d8f0b.tar.gz binaryen-c3ed0f176b36a502ef2e1fd915550a808b8d8f0b.tar.bz2 binaryen-c3ed0f176b36a502ef2e1fd915550a808b8d8f0b.zip |
wasm2js: more js optimization (#2050)
* Emit ints as signed, so -1 isn't a big unsigned number.
* x - -c (where c is a constant) is larger than x + c in js (but not wasm)
* +(+x) => +x
* Avoid unnecessary coercions on calls, return, load, etc. - we just need coercions when entering or exiting "wasm" (not internally), and on actual operations that need them.
Diffstat (limited to 'test/wasm2js/f32.2asm.js')
-rw-r--r-- | test/wasm2js/f32.2asm.js | 63 |
1 files changed, 20 insertions, 43 deletions
diff --git a/test/wasm2js/f32.2asm.js b/test/wasm2js/f32.2asm.js index 62ea4db91..a6c7d182b 100644 --- a/test/wasm2js/f32.2asm.js +++ b/test/wasm2js/f32.2asm.js @@ -96,12 +96,12 @@ function asmFunc(global, env, buffer) { function $9(x) { x = Math_fround(x); - return Math_fround(Math_fround(__wasm_trunc_f32(Math_fround(x)))); + return Math_fround(__wasm_trunc_f32(x)); } function $10(x) { x = Math_fround(x); - return Math_fround(Math_fround(__wasm_nearest_f32(Math_fround(x)))); + return Math_fround(__wasm_nearest_f32(x)); } function $11(x) { @@ -117,88 +117,66 @@ function asmFunc(global, env, buffer) { function $13(x, y) { x = Math_fround(x); y = Math_fround(y); - return Math_fround((wasm2js_scratch_store_i32(0, (wasm2js_scratch_store_f32(x), wasm2js_scratch_load_i32(0)) & 2147483647 | (wasm2js_scratch_store_f32(y), wasm2js_scratch_load_i32(0)) & 2147483648), wasm2js_scratch_load_f32())); + return Math_fround((wasm2js_scratch_store_i32(0, (wasm2js_scratch_store_f32(x), wasm2js_scratch_load_i32(0)) & 2147483647 | (wasm2js_scratch_store_f32(y), wasm2js_scratch_load_i32(0)) & -2147483648), wasm2js_scratch_load_f32())); } function legalstub$0($0_1, $1_1) { - $0_1 = +$0_1; - $1_1 = +$1_1; - return +(+Math_fround($0(Math_fround(Math_fround($0_1)), Math_fround(Math_fround($1_1))))); + return +$0(Math_fround($0_1), Math_fround($1_1)); } function legalstub$1($0_1, $1_1) { - $0_1 = +$0_1; - $1_1 = +$1_1; - return +(+Math_fround($1(Math_fround(Math_fround($0_1)), Math_fround(Math_fround($1_1))))); + return +$1(Math_fround($0_1), Math_fround($1_1)); } function legalstub$2($0_1, $1_1) { - $0_1 = +$0_1; - $1_1 = +$1_1; - return +(+Math_fround($2(Math_fround(Math_fround($0_1)), Math_fround(Math_fround($1_1))))); + return +$2(Math_fround($0_1), Math_fround($1_1)); } function legalstub$3($0_1, $1_1) { - $0_1 = +$0_1; - $1_1 = +$1_1; - return +(+Math_fround($3(Math_fround(Math_fround($0_1)), Math_fround(Math_fround($1_1))))); + return +$3(Math_fround($0_1), Math_fround($1_1)); } function legalstub$4($0_1) { - $0_1 = +$0_1; - return +(+Math_fround($4(Math_fround(Math_fround($0_1))))); + return +$4(Math_fround($0_1)); } function legalstub$5($0_1, $1_1) { - $0_1 = +$0_1; - $1_1 = +$1_1; - return +(+Math_fround($5(Math_fround(Math_fround($0_1)), Math_fround(Math_fround($1_1))))); + return +$5(Math_fround($0_1), Math_fround($1_1)); } function legalstub$6($0_1, $1_1) { - $0_1 = +$0_1; - $1_1 = +$1_1; - return +(+Math_fround($6(Math_fround(Math_fround($0_1)), Math_fround(Math_fround($1_1))))); + return +$6(Math_fround($0_1), Math_fround($1_1)); } function legalstub$7($0_1) { - $0_1 = +$0_1; - return +(+Math_fround($7(Math_fround(Math_fround($0_1))))); + return +$7(Math_fround($0_1)); } function legalstub$8($0_1) { - $0_1 = +$0_1; - return +(+Math_fround($8(Math_fround(Math_fround($0_1))))); + return +$8(Math_fround($0_1)); } function legalstub$9($0_1) { - $0_1 = +$0_1; - return +(+Math_fround($9(Math_fround(Math_fround($0_1))))); + return +$9(Math_fround($0_1)); } function legalstub$10($0_1) { - $0_1 = +$0_1; - return +(+Math_fround($10(Math_fround(Math_fround($0_1))))); + return +$10(Math_fround($0_1)); } function legalstub$11($0_1) { - $0_1 = +$0_1; - return +(+Math_fround($11(Math_fround(Math_fround($0_1))))); + return +$11(Math_fround($0_1)); } function legalstub$12($0_1) { - $0_1 = +$0_1; - return +(+Math_fround($12(Math_fround(Math_fround($0_1))))); + return +$12(Math_fround($0_1)); } function legalstub$13($0_1, $1_1) { - $0_1 = +$0_1; - $1_1 = +$1_1; - return +(+Math_fround($13(Math_fround(Math_fround($0_1)), Math_fround(Math_fround($1_1))))); + return +$13(Math_fround($0_1), Math_fround($1_1)); } function __wasm_nearest_f32(var$0) { - var$0 = Math_fround(var$0); var var$1 = Math_fround(0), var$2 = Math_fround(0), wasm2js_f32$0 = Math_fround(0), wasm2js_f32$1 = Math_fround(0), wasm2js_i32$0 = 0; var$1 = Math_fround(Math_floor(var$0)); var$2 = Math_fround(var$0 - var$1); @@ -206,19 +184,18 @@ function asmFunc(global, env, buffer) { { var$0 = Math_fround(Math_ceil(var$0)); if (var$2 > Math_fround(.5)) { - return Math_fround(var$0) + return var$0 } var$2 = Math_fround(var$1 * Math_fround(.5)); var$1 = (wasm2js_f32$0 = var$1, wasm2js_f32$1 = var$0, wasm2js_i32$0 = Math_fround(var$2 - Math_fround(Math_floor(var$2))) == Math_fround(0.0), wasm2js_i32$0 ? wasm2js_f32$0 : wasm2js_f32$1); } } - return Math_fround(var$1); + return var$1; } function __wasm_trunc_f32(var$0) { - var$0 = Math_fround(var$0); var wasm2js_f32$0 = Math_fround(0), wasm2js_f32$1 = Math_fround(0), wasm2js_i32$0 = 0; - return Math_fround((wasm2js_f32$0 = Math_fround(Math_ceil(var$0)), wasm2js_f32$1 = Math_fround(Math_floor(var$0)), wasm2js_i32$0 = var$0 < Math_fround(0.0), wasm2js_i32$0 ? wasm2js_f32$0 : wasm2js_f32$1)); + return wasm2js_f32$0 = Math_fround(Math_ceil(var$0)), wasm2js_f32$1 = Math_fround(Math_floor(var$0)), wasm2js_i32$0 = var$0 < Math_fround(0.0), wasm2js_i32$0 ? wasm2js_f32$0 : wasm2js_f32$1; } var FUNCTION_TABLE = []; |