From cb73700520fa34a58053835d2497c46f1da888c4 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 19 Aug 2021 09:26:09 -0700 Subject: Enable LocalCSE by default (#4089) Enable it in -O3 and -Os and higher. This helps very little on output from LLVM, but also it does not alter compile times much anyhow. On code that has not been run through an optimizing compiler already, this can help quite a lot, e.g., 15% of code size on some wasm GC samples. This will not normally help with speed, as optimizing VMs do such things anyhow. However, this can help baseline compilers and interpreters and so forth. --- test/wasm2js/emscripten.2asm.js.opt | 6 +- test/wasm2js/i64-rotate.2asm.js.opt | 115 ++++++++++++++++++------------------ test/wasm2js/i64-shifts.2asm.js.opt | 18 +++--- test/wasm2js/unary-ops.2asm.js.opt | 22 +++---- 4 files changed, 84 insertions(+), 77 deletions(-) (limited to 'test/wasm2js') diff --git a/test/wasm2js/emscripten.2asm.js.opt b/test/wasm2js/emscripten.2asm.js.opt index 5d14ea4b3..57df79dfc 100644 --- a/test/wasm2js/emscripten.2asm.js.opt +++ b/test/wasm2js/emscripten.2asm.js.opt @@ -185,14 +185,16 @@ function asmFunc(env) { function bools($0) { $0 = $0 | 0; + var $1 = 0; bools(HEAP8[0] & 1); bools(HEAP8[0] & 1); bools(HEAP16[0] & 1); bools(HEAP16[0] & 1); bools(HEAP32[0] & 1); bools(HEAPU8[0] & 2); - bools($0 ^ 1); - if ($0 ^ 1) { + $1 = $0 ^ 1; + bools($1); + if ($1) { bools(2) } if ($0 ^ 2) { diff --git a/test/wasm2js/i64-rotate.2asm.js.opt b/test/wasm2js/i64-rotate.2asm.js.opt index ecffd160a..33c3d5350 100644 --- a/test/wasm2js/i64-rotate.2asm.js.opt +++ b/test/wasm2js/i64-rotate.2asm.js.opt @@ -16,98 +16,101 @@ function asmFunc(env) { var i64toi32_i32$HIGH_BITS = 0; function legalstub$1($0, $1, $2, $3, $4, $5) { var $6 = 0, $7 = 0, $8 = 0; - $3 = $0; - $8 = $2 & 63; - $6 = $8; - $0 = $6 & 31; + $8 = $0; + $0 = 0; + $7 = $2 & 63; + $6 = $7; + $3 = $6 & 31; if ($6 >>> 0 >= 32) { - $0 = -1 >>> $0 | 0 + $3 = -1 >>> $3 | 0 } else { - $7 = -1 >>> $0 | 0; - $0 = (1 << $0) - 1 << 32 - $0 | -1 >>> $0; + $6 = -1 >>> $3 | 0; + $0 = $6; + $3 = $0 | (1 << $3) - 1 << 32 - $3; } - $6 = $0 & $3; - $0 = $1 & $7; - $7 = $8 & 31; - if ($8 >>> 0 >= 32) { - $0 = $6 << $7; - $8 = 0; + $6 = $3 & $8; + $0 = $0 & $1; + $3 = $7 & 31; + if ($7 >>> 0 >= 32) { + $0 = $6 << $3; + $6 = 0; } else { - $0 = (1 << $7) - 1 & $6 >>> 32 - $7 | $0 << $7; - $8 = $6 << $7; + $0 = (1 << $3) - 1 & $6 >>> 32 - $3 | $0 << $3; + $6 = $6 << $3; } - $7 = $0; - $6 = 0 - $2 & 63; - $0 = $6; - $2 = $0 & 31; - if ($0 >>> 0 >= 32) { - $0 = -1 << $2; - $2 = 0; + $3 = $0; + $2 = 0 - $2 & 63; + $7 = $2; + $0 = $7 & 31; + if ($7 >>> 0 >= 32) { + $0 = -1 << $0; + $7 = 0; } else { - $0 = (1 << $2) - 1 & -1 >>> 32 - $2 | -1 << $2; - $2 = -1 << $2; + $7 = -1 << $0; + $0 = $7 | (1 << $0) - 1 & -1 >>> 32 - $0; } - $3 = $2 & $3; + $8 = $7 & $8; $1 = $0 & $1; - $0 = $6 & 31; - if ($6 >>> 0 >= 32) { + $0 = $2 & 31; + if ($2 >>> 0 >= 32) { $2 = 0; $0 = $1 >>> $0 | 0; } else { $2 = $1 >>> $0 | 0; - $0 = ((1 << $0) - 1 & $1) << 32 - $0 | $3 >>> $0; + $0 = ((1 << $0) - 1 & $1) << 32 - $0 | $8 >>> $0; } - $0 = $0 | $8; - i64toi32_i32$HIGH_BITS = $2 | $7; + $0 = $0 | $6; + i64toi32_i32$HIGH_BITS = $2 | $3; return ($0 | 0) == ($4 | 0) & ($5 | 0) == (i64toi32_i32$HIGH_BITS | 0); } function legalstub$2($0, $1, $2, $3, $4, $5) { var $6 = 0, $7 = 0, $8 = 0, $9 = 0; - $3 = $0; - $8 = $2 & 63; - $0 = $8; - $6 = $0 & 31; - if ($0 >>> 0 >= 32) { - $0 = -1 << $6; - $6 = 0; + $9 = $0; + $7 = $2 & 63; + $3 = $7; + $0 = $3 & 31; + if ($3 >>> 0 >= 32) { + $0 = -1 << $0; + $3 = 0; } else { - $0 = (1 << $6) - 1 & -1 >>> 32 - $6 | -1 << $6; - $6 = -1 << $6; + $3 = -1 << $0; + $0 = $3 | (1 << $0) - 1 & -1 >>> 32 - $0; } - $9 = $6 & $3; - $7 = $0 & $1; - $6 = $8 & 31; - if ($8 >>> 0 >= 32) { + $8 = $3 & $9; + $6 = $0 & $1; + $3 = $7 & 31; + if ($7 >>> 0 >= 32) { $0 = 0; - $8 = $7 >>> $6 | 0; + $7 = $6 >>> $3 | 0; } else { - $0 = $7 >>> $6 | 0; - $8 = ((1 << $6) - 1 & $7) << 32 - $6 | $9 >>> $6; + $0 = $6 >>> $3 | 0; + $7 = ((1 << $3) - 1 & $6) << 32 - $3 | $8 >>> $3; } - $6 = $0; - $7 = 0 - $2 & 63; - $0 = $7; + $3 = $0; + $6 = 0 - $2 & 63; + $0 = $6; $2 = $0 & 31; if ($0 >>> 0 >= 32) { $0 = 0; $2 = -1 >>> $2 | 0; } else { - $0 = -1 >>> $2 | 0; - $2 = (1 << $2) - 1 << 32 - $2 | -1 >>> $2; + $8 = -1 >>> $2 | 0; + $0 = $8; + $2 = $0 | (1 << $2) - 1 << 32 - $2; } - $2 = $2 & $3; + $2 = $2 & $9; $1 = $0 & $1; - $0 = $7 & 31; - if ($7 >>> 0 >= 32) { + $0 = $6 & 31; + if ($6 >>> 0 >= 32) { $1 = $2 << $0; $0 = 0; } else { $1 = (1 << $0) - 1 & $2 >>> 32 - $0 | $1 << $0; $0 = $2 << $0; } - $0 = $0 | $8; - i64toi32_i32$HIGH_BITS = $1 | $6; + $0 = $0 | $7; + i64toi32_i32$HIGH_BITS = $1 | $3; return ($0 | 0) == ($4 | 0) & ($5 | 0) == (i64toi32_i32$HIGH_BITS | 0); } diff --git a/test/wasm2js/i64-shifts.2asm.js.opt b/test/wasm2js/i64-shifts.2asm.js.opt index 3bc6cac10..4981ca880 100644 --- a/test/wasm2js/i64-shifts.2asm.js.opt +++ b/test/wasm2js/i64-shifts.2asm.js.opt @@ -14,25 +14,27 @@ function asmFunc(env) { var nan = NaN; var infinity = Infinity; function legalstub$1($0, $1, $2, $3, $4, $5) { - $3 = $2 & 31; + $3 = $0; + $0 = $2 & 31; if (($2 & 63) >>> 0 >= 32) { - $1 = $0 << $3; + $1 = $3 << $0; $0 = 0; } else { - $1 = (1 << $3) - 1 & $0 >>> 32 - $3 | $1 << $3; - $0 = $0 << $3; + $1 = (1 << $0) - 1 & $3 >>> 32 - $0 | $1 << $0; + $0 = $3 << $0; } return ($0 | 0) == ($4 | 0) & ($1 | 0) == ($5 | 0); } function legalstub$2($0, $1, $2, $3, $4, $5) { - $3 = $2 & 31; + $3 = $0; + $0 = $2 & 31; if (($2 & 63) >>> 0 >= 32) { $2 = $1 >> 31; - $0 = $1 >> $3; + $0 = $1 >> $0; } else { - $2 = $1 >> $3; - $0 = ((1 << $3) - 1 & $1) << 32 - $3 | $0 >>> $3; + $2 = $1 >> $0; + $0 = ((1 << $0) - 1 & $1) << 32 - $0 | $3 >>> $0; } return ($0 | 0) == ($4 | 0) & ($2 | 0) == ($5 | 0); } diff --git a/test/wasm2js/unary-ops.2asm.js.opt b/test/wasm2js/unary-ops.2asm.js.opt index 027c9164d..ecf227753 100644 --- a/test/wasm2js/unary-ops.2asm.js.opt +++ b/test/wasm2js/unary-ops.2asm.js.opt @@ -46,23 +46,23 @@ function asmFunc(env) { function legalstub$2($0, $1_1, $2, $3) { var $4 = 0, $5 = 0, $6_1 = 0, $7_1 = 0; - $7_1 = $2; + $5 = $0; $4 = $1_1; while (1) { - $2 = $5; $1_1 = $6_1; - if ($0 | $4) { - $1_1 = $0; - $0 = $1_1 - 1 & $1_1; - $4 = $4 - ($1_1 >>> 0 < 1) & $4; - $5 = $5 + 1 | 0; - $6_1 = $5 >>> 0 < 1 ? $6_1 + 1 | 0 : $6_1; + $0 = $7_1; + if ($5 | $4) { + $0 = $5; + $5 = $0 - 1 & $0; + $4 = $4 - ($0 >>> 0 < 1) & $4; + $6_1 = $6_1 + 1 | 0; + $7_1 = $6_1 >>> 0 < 1 ? $7_1 + 1 | 0 : $7_1; continue; } break; }; - i64toi32_i32$HIGH_BITS = $1_1; - return ($2 | 0) == ($7_1 | 0) & ($3 | 0) == (i64toi32_i32$HIGH_BITS | 0); + i64toi32_i32$HIGH_BITS = $0; + return ($1_1 | 0) == ($2 | 0) & ($3 | 0) == (i64toi32_i32$HIGH_BITS | 0); } function legalstub$3($0, $1_1, $2) { @@ -87,7 +87,7 @@ function asmFunc(env) { function legalstub$9($0, $1_1, $2, $3) { var $4 = 0, $5 = 0, $6_1 = 0, $7_1 = 0; __inlined_func$__wasm_ctz_i64 : { - if ($0 | $1_1) { + if ($1_1 | $0) { $4 = $1_1 - 1 | 0; $5 = $4 + 1 | 0; $6_1 = $4; -- cgit v1.2.3