From c30c62e383a98729d1c256d42748eec804f6e710 Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Fri, 23 Nov 2018 15:20:52 +0100 Subject: [PATCH] Cast to bool by comparing to zero (#343) --- src/compiler.ts | 5 +- src/module.ts | 4 + src/program.ts | 20 +- tests/compiler/abi.untouched.wat | 8 +- tests/compiler/binary.optimized.wat | 82 ++-- tests/compiler/binary.untouched.wat | 8 +- tests/compiler/bool.optimized.wat | 119 ++++++ tests/compiler/bool.ts | 14 + tests/compiler/bool.untouched.wat | 126 ++++++ tests/compiler/builtins.untouched.wat | 352 +++++++-------- .../class-with-boolean-field.optimized.wat | 2 + .../class-with-boolean-field.untouched.wat | 2 + tests/compiler/for.optimized.wat | 28 +- tests/compiler/infer-type.optimized.wat | 14 +- tests/compiler/mandelbrot.optimized.wat | 41 +- tests/compiler/scoped.optimized.wat | 14 +- tests/compiler/std/array.optimized.wat | 401 ++++++++---------- tests/compiler/std/array.untouched.wat | 108 ++--- tests/compiler/std/arraybuffer.untouched.wat | 4 +- tests/compiler/std/dataview.optimized.wat | 24 -- tests/compiler/std/dataview.untouched.wat | 64 +-- tests/compiler/std/gc-array.optimized.wat | 11 +- tests/compiler/std/gc-basics.optimized.wat | 11 +- tests/compiler/std/gc-object.optimized.wat | 11 +- tests/compiler/std/libm.optimized.wat | 44 +- tests/compiler/std/map.optimized.wat | 134 +++--- tests/compiler/std/map.untouched.wat | 4 +- tests/compiler/std/math.optimized.wat | 98 ++--- tests/compiler/std/math.untouched.wat | 88 ++-- tests/compiler/std/mod.optimized.wat | 2 - tests/compiler/std/mod.untouched.wat | 8 +- tests/compiler/std/set.optimized.wat | 134 +++--- tests/compiler/std/set.untouched.wat | 4 +- tests/compiler/std/string.optimized.wat | 59 ++- tests/compiler/std/string.untouched.wat | 4 +- tests/compiler/std/symbol.optimized.wat | 13 +- tests/compiler/std/symbol.untouched.wat | 4 +- tests/compiler/std/typedarray.optimized.wat | 26 +- 38 files changed, 1072 insertions(+), 1023 deletions(-) create mode 100644 tests/compiler/bool.optimized.wat create mode 100644 tests/compiler/bool.ts create mode 100644 tests/compiler/bool.untouched.wat diff --git a/src/compiler.ts b/src/compiler.ts index ecaaa177..48e30442 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -7516,9 +7516,10 @@ export class Compiler extends DiagnosticEmitter { } case TypeKind.BOOL: { if (flow.canOverflow(expr, type)) { - expr = module.createBinary(BinaryOp.AndI32, + // bool is special in that it compares to 0 instead of masking with 0x1 + expr = module.createBinary(BinaryOp.NeI32, expr, - module.createI32(0x1) + module.createI32(0) ); } break; diff --git a/src/module.ts b/src/module.ts index e45c38dc..7c7a1c4f 100644 --- a/src/module.ts +++ b/src/module.ts @@ -1169,6 +1169,10 @@ export function isTeeLocal(expr: ExpressionRef): bool { return _BinaryenSetLocalIsTee(expr); } +export function getGetGlobalName(expr: ExpressionRef): string | null { + return readString(_BinaryenGetGlobalGetName(expr)); +} + export function getBinaryOp(expr: ExpressionRef): BinaryOp { return _BinaryenBinaryGetOp(expr); } diff --git a/src/program.ts b/src/program.ts index fad25d74..26b6e735 100644 --- a/src/program.ts +++ b/src/program.ts @@ -101,7 +101,8 @@ import { getBlockName, getConstValueF32, getConstValueF64, - getConstValueI64Low + getConstValueI64Low, + getGetGlobalName } from "./module"; import { @@ -3314,7 +3315,7 @@ export class Flow { /** * Tests if an expression can possibly overflow in the context of this flow. Assumes that the * expression might already have overflown and returns `false` only if the operation neglects - * any possibly combination of garbage bits being present. + * any possible combination of garbage bits being present. */ canOverflow(expr: ExpressionRef, type: Type): bool { // TODO: the following catches most common and a few uncommon cases, but there are additional @@ -3336,13 +3337,18 @@ export class Flow { } // overflows if the value does - case ExpressionId.SetLocal: { + case ExpressionId.SetLocal: { // tee assert(isTeeLocal(expr)); return this.canOverflow(getSetLocalValue(expr), type); } - // never overflows because globals are wrapped on set - case ExpressionId.GetGlobal: return false; + // overflows if the conversion does (globals are wrapped on set) + case ExpressionId.GetGlobal: { + // TODO: this is inefficient because it has to read a string + let global = assert(this.currentFunction.program.elementsLookup.get(assert(getGetGlobalName(expr)))); + assert(global.kind == ElementKind.GLOBAL); + return canConversionOverflow(assert((global).type), type); + } case ExpressionId.Binary: { switch (getBinaryOp(expr)) { @@ -3567,9 +3573,7 @@ export class Flow { /** Tests if a conversion from one type to another can technically overflow. */ function canConversionOverflow(fromType: Type, toType: Type): bool { - var fromSize = fromType.byteSize; - var toSize = toType.byteSize; return !fromType.is(TypeFlags.INTEGER) // non-i32 locals or returns - || fromSize > toSize + || fromType.size > toType.size || fromType.is(TypeFlags.SIGNED) != toType.is(TypeFlags.SIGNED); } diff --git a/tests/compiler/abi.untouched.wat b/tests/compiler/abi.untouched.wat index cfdff844..5b716484 100644 --- a/tests/compiler/abi.untouched.wat +++ b/tests/compiler/abi.untouched.wat @@ -157,8 +157,8 @@ i32.ctz set_local $0 get_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 @@ -172,8 +172,8 @@ i32.clz set_local $0 get_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 diff --git a/tests/compiler/binary.optimized.wat b/tests/compiler/binary.optimized.wat index 265b62c8..82ba2719 100644 --- a/tests/compiler/binary.optimized.wat +++ b/tests/compiler/binary.optimized.wat @@ -97,8 +97,6 @@ set_local $3 end get_local $3 - i32.const 1 - i32.and if get_local $0 get_local $0 @@ -655,27 +653,25 @@ get_global $binary/f call $~lib/math/NativeMathf.mod set_global $binary/f - block $__inlined_func$~lib/math/NativeMathf.pow0 - get_global $binary/f - tee_local $0 - i32.reinterpret/f32 - i32.const 2147483647 - i32.and - i32.const 2139095040 - i32.gt_s - tee_local $1 - i32.eqz - if - i32.const 0 - set_local $1 - end - get_local $1 - if - get_local $0 - f32.const 1 - f32.add - set_local $0 - end + get_global $binary/f + tee_local $0 + i32.reinterpret/f32 + i32.const 2147483647 + i32.and + i32.const 2139095040 + i32.gt_s + tee_local $1 + i32.eqz + if + i32.const 0 + set_local $1 + end + get_local $1 + if + get_local $0 + f32.const 1 + f32.add + set_local $0 end get_local $0 set_global $binary/f @@ -690,27 +686,25 @@ get_global $binary/f call $~lib/math/NativeMathf.mod set_global $binary/f - block $__inlined_func$~lib/math/NativeMathf.pow2 - get_global $binary/f - tee_local $0 - i32.reinterpret/f32 - i32.const 2147483647 - i32.and - i32.const 2139095040 - i32.gt_s - tee_local $1 - i32.eqz - if - i32.const 0 - set_local $1 - end - get_local $1 - if - get_local $0 - f32.const 1 - f32.add - set_local $0 - end + get_global $binary/f + tee_local $0 + i32.reinterpret/f32 + i32.const 2147483647 + i32.and + i32.const 2139095040 + i32.gt_s + tee_local $1 + i32.eqz + if + i32.const 0 + set_local $1 + end + get_local $1 + if + get_local $0 + f32.const 1 + f32.add + set_local $0 end get_local $0 set_global $binary/f diff --git a/tests/compiler/binary.untouched.wat b/tests/compiler/binary.untouched.wat index 343e5211..6443b507 100644 --- a/tests/compiler/binary.untouched.wat +++ b/tests/compiler/binary.untouched.wat @@ -1250,8 +1250,8 @@ get_local $1 f32.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $0 get_local $1 @@ -2531,8 +2531,8 @@ get_local $1 f64.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $0 get_local $1 diff --git a/tests/compiler/bool.optimized.wat b/tests/compiler/bool.optimized.wat new file mode 100644 index 00000000..8c94fa02 --- /dev/null +++ b/tests/compiler/bool.optimized.wat @@ -0,0 +1,119 @@ +(module + (type $iiiiv (func (param i32 i32 i32 i32))) + (type $v (func)) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (memory $0 1) + (data (i32.const 8) "\07\00\00\00b\00o\00o\00l\00.\00t\00s") + (table $0 1 anyfunc) + (elem (i32.const 0) $null) + (global $bool/i (mut i32) (i32.const 2)) + (global $bool/I (mut i64) (i64.const 2)) + (global $bool/u (mut i32) (i32.const 2)) + (global $bool/U (mut i64) (i64.const 2)) + (global $bool/f (mut f32) (f32.const 2)) + (global $bool/F (mut f64) (f64.const 2)) + (global $bool/uu (mut i32) (i32.const 2)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (start $start) + (func $start (; 1 ;) (type $v) + get_global $bool/i + i32.const 0 + i32.ne + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 2 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/I + i32.wrap/i64 + i32.const 0 + i32.ne + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 4 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/u + i32.const 0 + i32.ne + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 6 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/U + i32.wrap/i64 + i32.const 0 + i32.ne + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 8 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/f + i32.trunc_u/f32 + i32.const 0 + i32.ne + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 10 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/F + i32.trunc_u/f64 + i32.const 0 + i32.ne + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/uu + i32.const 0 + i32.ne + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 14 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $null (; 2 ;) (type $v) + nop + ) +) diff --git a/tests/compiler/bool.ts b/tests/compiler/bool.ts new file mode 100644 index 00000000..e1052f6a --- /dev/null +++ b/tests/compiler/bool.ts @@ -0,0 +1,14 @@ +var i = 2; +assert(i == true); +var I = 2; +assert(I == true); +var u = 2; +assert(u == true); +var U = 2; +assert(U == true); +var f = 2; +assert(f == true); +var F = 2; +assert(F == true); +var uu = 2; +assert(uu == true); diff --git a/tests/compiler/bool.untouched.wat b/tests/compiler/bool.untouched.wat new file mode 100644 index 00000000..07b18d42 --- /dev/null +++ b/tests/compiler/bool.untouched.wat @@ -0,0 +1,126 @@ +(module + (type $iiiiv (func (param i32 i32 i32 i32))) + (type $v (func)) + (import "env" "abort" (func $~lib/env/abort (param i32 i32 i32 i32))) + (memory $0 1) + (data (i32.const 8) "\07\00\00\00b\00o\00o\00l\00.\00t\00s\00") + (table $0 1 anyfunc) + (elem (i32.const 0) $null) + (global $bool/i (mut i32) (i32.const 2)) + (global $bool/I (mut i64) (i64.const 2)) + (global $bool/u (mut i32) (i32.const 2)) + (global $bool/U (mut i64) (i64.const 2)) + (global $bool/f (mut f32) (f32.const 2)) + (global $bool/F (mut f64) (f64.const 2)) + (global $bool/uu (mut i32) (i32.const 2)) + (global $HEAP_BASE i32 (i32.const 28)) + (export "memory" (memory $0)) + (export "table" (table $0)) + (start $start) + (func $start (; 1 ;) (type $v) + get_global $bool/i + i32.const 0 + i32.ne + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 2 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/I + i32.wrap/i64 + i32.const 0 + i32.ne + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 4 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/u + i32.const 0 + i32.ne + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 6 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/U + i32.wrap/i64 + i32.const 0 + i32.ne + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 8 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/f + i32.trunc_u/f32 + i32.const 0 + i32.ne + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 10 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/F + i32.trunc_u/f64 + i32.const 0 + i32.ne + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 12 + i32.const 0 + call $~lib/env/abort + unreachable + end + get_global $bool/uu + i32.const 0 + i32.ne + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 14 + i32.const 0 + call $~lib/env/abort + unreachable + end + ) + (func $null (; 2 ;) (type $v) + ) +) diff --git a/tests/compiler/builtins.untouched.wat b/tests/compiler/builtins.untouched.wat index 99659b2f..2f97179d 100644 --- a/tests/compiler/builtins.untouched.wat +++ b/tests/compiler/builtins.untouched.wat @@ -576,8 +576,8 @@ get_local $4 f32.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -596,8 +596,8 @@ get_local $4 f32.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -618,8 +618,8 @@ f32.const 0 f32.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -640,8 +640,8 @@ f32.const 0 f32.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -663,8 +663,8 @@ f32.const 0 f32.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -685,8 +685,8 @@ f32.const 0 f32.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -739,8 +739,8 @@ get_local $4 f32.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $builtins/b block $~lib/builtins/isFinite|inlined.4 (result i32) f32.const 1.25 @@ -751,8 +751,8 @@ f32.const 0 f32.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $builtins/b f64.const nan:0x8000000000000 drop @@ -799,8 +799,8 @@ get_local $5 f64.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -819,8 +819,8 @@ get_local $5 f64.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -841,8 +841,8 @@ f64.const 0 f64.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -863,8 +863,8 @@ f64.const 0 f64.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -886,8 +886,8 @@ f64.const 0 f64.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -908,8 +908,8 @@ f64.const 0 f64.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -962,8 +962,8 @@ get_local $5 f64.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $builtins/b block $~lib/builtins/isFinite|inlined.4 (result i32) f64.const 1.25 @@ -974,8 +974,8 @@ f64.const 0 f64.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $builtins/b i32.const 8 i32.load @@ -1452,8 +1452,8 @@ get_local $4 f32.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 @@ -1470,8 +1470,8 @@ get_local $5 f64.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 @@ -1490,8 +1490,8 @@ f32.const 0 f32.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz i32.eqz if @@ -1511,8 +1511,8 @@ f32.const 0 f32.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz i32.eqz if @@ -1532,8 +1532,8 @@ f64.const 0 f64.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz i32.eqz if @@ -1553,8 +1553,8 @@ f64.const 0 f64.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz i32.eqz if @@ -1574,8 +1574,8 @@ f32.const 0 f32.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 @@ -1594,8 +1594,8 @@ f64.const 0 f64.eq end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 @@ -1932,8 +1932,8 @@ get_local $4 f32.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 @@ -1962,8 +1962,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -1992,8 +1992,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2022,8 +2022,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2052,8 +2052,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2082,8 +2082,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2112,8 +2112,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2142,8 +2142,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2174,8 +2174,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2204,8 +2204,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2228,8 +2228,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2239,8 +2239,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2263,8 +2263,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2274,8 +2274,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2298,8 +2298,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2309,8 +2309,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2333,8 +2333,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2344,8 +2344,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2368,8 +2368,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2379,8 +2379,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2403,8 +2403,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2414,8 +2414,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2438,8 +2438,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2449,8 +2449,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2473,8 +2473,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2484,8 +2484,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2508,8 +2508,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2519,8 +2519,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2543,8 +2543,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2554,8 +2554,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2578,8 +2578,8 @@ f32.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $4 f32.trunc @@ -2589,8 +2589,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2681,8 +2681,8 @@ get_local $5 f64.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 @@ -2711,8 +2711,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2741,8 +2741,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2771,8 +2771,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2801,8 +2801,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2831,8 +2831,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2861,8 +2861,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2891,8 +2891,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -2923,8 +2923,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2953,8 +2953,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -2977,8 +2977,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -2988,8 +2988,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -3012,8 +3012,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3023,8 +3023,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -3047,8 +3047,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3058,8 +3058,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -3082,8 +3082,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3093,8 +3093,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -3117,8 +3117,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3128,8 +3128,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -3152,8 +3152,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3163,8 +3163,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -3187,8 +3187,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3198,8 +3198,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -3222,8 +3222,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3233,8 +3233,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -3257,8 +3257,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3268,8 +3268,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -3292,8 +3292,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3303,8 +3303,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -3327,8 +3327,8 @@ f64.eq end tee_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $5 f64.trunc @@ -3338,8 +3338,8 @@ get_local $0 end end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz diff --git a/tests/compiler/class-with-boolean-field.optimized.wat b/tests/compiler/class-with-boolean-field.optimized.wat index 1441bc3d..3c7b8550 100644 --- a/tests/compiler/class-with-boolean-field.optimized.wat +++ b/tests/compiler/class-with-boolean-field.optimized.wat @@ -13,6 +13,8 @@ i32.store8 i32.const 0 i32.load8_u + i32.const 0 + i32.ne ) (func $null (; 1 ;) (type $v) nop diff --git a/tests/compiler/class-with-boolean-field.untouched.wat b/tests/compiler/class-with-boolean-field.untouched.wat index 01ac114c..2954e085 100644 --- a/tests/compiler/class-with-boolean-field.untouched.wat +++ b/tests/compiler/class-with-boolean-field.untouched.wat @@ -15,6 +15,8 @@ i32.store8 get_local $0 i32.load8_u + i32.const 0 + i32.ne ) (func $null (; 1 ;) (type $v) ) diff --git a/tests/compiler/for.optimized.wat b/tests/compiler/for.optimized.wat index 75fd9a94..fb3a5b73 100644 --- a/tests/compiler/for.optimized.wat +++ b/tests/compiler/for.optimized.wat @@ -56,20 +56,18 @@ end unreachable end - block $break|2 - loop $repeat|2 - get_global $for/i - i32.const 0 - i32.le_s - br_if $break|2 + loop $repeat|2 + get_global $for/i + i32.const 0 + i32.le_s + i32.eqz + if get_global $for/i i32.const 1 i32.sub set_global $for/i br $repeat|2 - unreachable end - unreachable end get_global $for/i if @@ -80,20 +78,18 @@ call $~lib/env/abort unreachable end - block $break|3 - loop $repeat|3 - get_global $for/i - i32.const 10 - i32.eq - br_if $break|3 + loop $repeat|3 + get_global $for/i + i32.const 10 + i32.eq + i32.eqz + if get_global $for/i i32.const 1 i32.add set_global $for/i br $repeat|3 - unreachable end - unreachable end loop $repeat|4 get_global $for/i diff --git a/tests/compiler/infer-type.optimized.wat b/tests/compiler/infer-type.optimized.wat index 9a453559..e0087b93 100644 --- a/tests/compiler/infer-type.optimized.wat +++ b/tests/compiler/infer-type.optimized.wat @@ -21,20 +21,18 @@ set_global $infer-type/rf f64.const 0 set_global $infer-type/rF - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 10 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 10 + i32.ge_s + i32.eqz + if get_local $0 i32.const 1 i32.add set_local $0 br $repeat|0 - unreachable end - unreachable end ) (func $null (; 1 ;) (type $v) diff --git a/tests/compiler/mandelbrot.optimized.wat b/tests/compiler/mandelbrot.optimized.wat index 9cec1fc0..d259edc1 100644 --- a/tests/compiler/mandelbrot.optimized.wat +++ b/tests/compiler/mandelbrot.optimized.wat @@ -223,12 +223,11 @@ tee_local $12 f64.mul set_local $9 - block $break|0 - loop $repeat|0 - get_local $8 - get_local $1 - i32.ge_u - br_if $break|0 + loop $repeat|0 + get_local $8 + get_local $1 + i32.lt_u + if get_local $8 f64.convert_u/i32 get_local $11 @@ -242,20 +241,20 @@ set_local $5 i32.const 0 set_local $2 - block $break|1 - loop $continue|1 - get_local $4 - get_local $4 - f64.mul - tee_local $6 - get_local $5 - get_local $5 - f64.mul - tee_local $7 - f64.add - f64.const 4 - f64.le - if + loop $continue|1 + get_local $4 + get_local $4 + f64.mul + tee_local $6 + get_local $5 + get_local $5 + f64.mul + tee_local $7 + f64.add + f64.const 4 + f64.le + if + block $break|1 f64.const 2 get_local $4 f64.mul @@ -375,9 +374,7 @@ i32.add set_local $8 br $repeat|0 - unreachable end - unreachable end ) (func $null (; 2 ;) (type $v) diff --git a/tests/compiler/scoped.optimized.wat b/tests/compiler/scoped.optimized.wat index 112e5df7..ab3085b3 100644 --- a/tests/compiler/scoped.optimized.wat +++ b/tests/compiler/scoped.optimized.wat @@ -8,20 +8,18 @@ (start $start) (func $start (; 0 ;) (type $v) (local $0 i32) - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 1 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 1 + i32.ge_s + i32.eqz + if get_local $0 i32.const 1 i32.add set_local $0 br $repeat|0 - unreachable end - unreachable end block $break|1 i32.const 0 diff --git a/tests/compiler/std/array.optimized.wat b/tests/compiler/std/array.optimized.wat index dccba55a..c4a94bdc 100644 --- a/tests/compiler/std/array.optimized.wat +++ b/tests/compiler/std/array.optimized.wat @@ -783,12 +783,11 @@ i32.const 1 return end - block $break|0 - loop $repeat|0 - get_local $2 - get_local $4 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $2 + get_local $4 + i32.lt_s + if get_local $2 get_local $0 i32.load @@ -839,9 +838,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end i32.const 1 ) @@ -926,12 +923,12 @@ select end set_local $3 - block $break|0 - loop $repeat|0 - get_local $2 - get_local $3 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $2 + get_local $3 + i32.ge_s + i32.eqz + if get_local $6 get_local $2 i32.const 2 @@ -944,9 +941,7 @@ i32.add set_local $2 br $repeat|0 - unreachable end - unreachable end get_local $0 ) @@ -975,12 +970,11 @@ return end end - block $break|0 - loop $repeat|0 - get_local $3 - get_local $2 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $3 + get_local $2 + i32.lt_s + if get_local $3 get_local $0 i32.load @@ -1035,9 +1029,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end i32.const 1 ) @@ -2966,8 +2958,6 @@ get_local $0 get_local $1 call_indirect (type $iiii) - i32.const 1 - i32.and if get_local $2 return @@ -3056,8 +3046,6 @@ get_local $0 get_local $1 call_indirect (type $iiii) - i32.const 1 - i32.and if get_local $2 i32.const 1 @@ -3146,8 +3134,6 @@ get_local $0 get_local $1 call_indirect (type $iiii) - i32.const 1 - i32.and if i32.const 1 return @@ -3287,22 +3273,20 @@ tee_local $5 i32.load set_local $6 - block $break|0 - loop $repeat|0 + loop $repeat|0 + get_local $1 + get_local $4 + i32.lt_s + tee_local $2 + if get_local $1 - get_local $4 + get_local $0 + i32.load offset=4 i32.lt_s - tee_local $2 - if - get_local $1 - get_local $0 - i32.load offset=4 - i32.lt_s - set_local $2 - end - get_local $2 - i32.eqz - br_if $break|0 + set_local $2 + end + get_local $2 + if i32.const 3 set_global $~argc get_local $6 @@ -3325,9 +3309,7 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end get_local $5 ) @@ -3471,8 +3453,6 @@ get_local $0 get_local $1 call_indirect (type $iiii) - i32.const 1 - i32.and if get_local $4 get_local $3 @@ -3583,8 +3563,6 @@ ) (func $start~anonymous|31 (; 61 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) get_local $0 - i32.const 1 - i32.and if (result i32) get_local $0 else @@ -3595,8 +3573,6 @@ ) (func $start~anonymous|32 (; 62 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) get_local $0 - i32.const 1 - i32.and if (result i32) get_local $0 else @@ -3767,12 +3743,12 @@ (local $5 f32) (local $6 f32) (local $7 i32) - block $break|0 - loop $repeat|0 - get_local $4 - get_local $1 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $4 + get_local $1 + i32.ge_s + i32.eqz + if get_local $0 get_local $4 i32.const 2 @@ -3784,12 +3760,12 @@ i32.const 1 i32.sub set_local $3 - block $break|1 - loop $continue|1 - get_local $3 - i32.const 0 - i32.ge_s - if + loop $continue|1 + get_local $3 + i32.const 0 + i32.ge_s + if + block $break|1 get_local $0 get_local $3 i32.const 2 @@ -3838,9 +3814,7 @@ i32.add set_local $4 br $repeat|0 - unreachable end - unreachable end ) (func $~lib/internal/array/weakHeapSort (; 69 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) @@ -4238,8 +4212,8 @@ i32.const 1 return end - block $break|0 - loop $repeat|0 + loop $repeat|0 + block $break|0 block $continue|0 get_local $1 get_local $5 @@ -4345,9 +4319,7 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end i32.const 1 ) @@ -4357,12 +4329,12 @@ (local $5 f64) (local $6 f64) (local $7 i32) - block $break|0 - loop $repeat|0 - get_local $4 - get_local $1 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $4 + get_local $1 + i32.ge_s + i32.eqz + if get_local $0 get_local $4 i32.const 3 @@ -4374,12 +4346,12 @@ i32.const 1 i32.sub set_local $3 - block $break|1 - loop $continue|1 - get_local $3 - i32.const 0 - i32.ge_s - if + loop $continue|1 + get_local $3 + i32.const 0 + i32.ge_s + if + block $break|1 get_local $0 get_local $3 i32.const 3 @@ -4428,9 +4400,7 @@ i32.add set_local $4 br $repeat|0 - unreachable end - unreachable end ) (func $~lib/internal/array/weakHeapSort (; 74 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) @@ -4828,8 +4798,8 @@ i32.const 1 return end - block $break|0 - loop $repeat|0 + loop $repeat|0 + block $break|0 block $continue|0 get_local $1 get_local $5 @@ -4935,9 +4905,7 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end i32.const 1 ) @@ -4947,12 +4915,12 @@ (local $5 i32) (local $6 i32) (local $7 i32) - block $break|0 - loop $repeat|0 - get_local $4 - get_local $1 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $4 + get_local $1 + i32.ge_s + i32.eqz + if get_local $0 get_local $4 i32.const 2 @@ -4964,12 +4932,12 @@ i32.const 1 i32.sub set_local $3 - block $break|1 - loop $continue|1 - get_local $3 - i32.const 0 - i32.ge_s - if + loop $continue|1 + get_local $3 + i32.const 0 + i32.ge_s + if + block $break|1 get_local $0 get_local $3 i32.const 2 @@ -5020,9 +4988,7 @@ i32.add set_local $4 br $repeat|0 - unreachable end - unreachable end ) (func $~lib/internal/array/weakHeapSort (; 79 ;) (type $FUNCSIG$viii) (param $0 i32) (param $1 i32) (param $2 i32) @@ -5609,13 +5575,12 @@ i32.const 512 call $~lib/array/Array#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - get_local $1 - i32.load offset=4 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + get_local $1 + i32.load offset=4 + i32.lt_s + if get_local $1 get_local $0 i32.const 1 @@ -5653,9 +5618,7 @@ i32.add set_local $0 br $repeat|0 - unreachable end - unreachable end get_local $1 ) @@ -5785,13 +5748,13 @@ i32.const 512 call $~lib/array/Array#constructor set_local $0 - block $break|0 - loop $repeat|0 - get_local $1 - get_local $0 - i32.load offset=4 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $1 + get_local $0 + i32.load offset=4 + i32.ge_s + i32.eqz + if get_local $0 i32.load offset=4 i32.const 1 @@ -5813,9 +5776,7 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end get_local $0 ) @@ -6041,12 +6002,11 @@ i32.const 1 return end - block $break|0 - loop $repeat|0 - get_local $2 - get_local $4 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $2 + get_local $4 + i32.lt_s + if get_local $2 get_local $0 i32.load @@ -6101,9 +6061,7 @@ return end unreachable - unreachable end - unreachable end i32.const 1 ) @@ -6427,8 +6385,6 @@ i32.const 2816 get_local $5 i32.load8_u offset=8 - i32.const 1 - i32.and select return end @@ -6442,18 +6398,17 @@ tee_local $8 call $~lib/internal/string/allocateUnsafe set_local $2 - block $break|0 - loop $repeat|0 - get_local $1 - get_local $4 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $1 + get_local $4 + i32.lt_s + if get_local $5 get_local $1 i32.add i32.load8_u offset=8 - i32.const 1 - i32.and + i32.const 0 + i32.ne tee_local $9 i32.eqz i32.const 4 @@ -6490,16 +6445,14 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end get_local $5 get_local $4 i32.add i32.load8_u offset=8 - i32.const 1 - i32.and + i32.const 0 + i32.ne tee_local $1 i32.eqz i32.const 4 @@ -6830,12 +6783,11 @@ tee_local $8 call $~lib/internal/string/allocateUnsafe set_local $0 - block $break|0 - loop $repeat|0 - get_local $3 - get_local $4 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $3 + get_local $4 + i32.lt_s + if get_local $2 get_local $0 get_local $2 @@ -6866,9 +6818,7 @@ i32.add set_local $3 br $repeat|0 - unreachable end - unreachable end get_local $0 set_local $3 @@ -6994,12 +6944,11 @@ tee_local $8 call $~lib/internal/string/allocateUnsafe set_local $0 - block $break|0 - loop $repeat|0 - get_local $3 - get_local $4 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $3 + get_local $4 + i32.lt_s + if get_local $2 get_local $0 get_local $2 @@ -7030,9 +6979,7 @@ i32.add set_local $3 br $repeat|0 - unreachable end - unreachable end get_local $0 set_local $3 @@ -7127,13 +7074,10 @@ i32.const 10 i32.ne if - block $tablify|0 - get_local $2 - i32.const 1 - i32.sub - br_table $case9|1 $case8|1 $case7|1 $case6|1 $case5|1 $case4|1 $case3|1 $case2|1 $case1|1 $tablify|0 - end - br $case10|1 + get_local $2 + i32.const 1 + i32.sub + br_table $case9|1 $case8|1 $case7|1 $case6|1 $case5|1 $case4|1 $case3|1 $case2|1 $case1|1 $case10|1 end get_local $7 i32.const 1000000000 @@ -8247,12 +8191,11 @@ tee_local $7 call $~lib/internal/string/allocateUnsafe set_local $2 - block $break|0 - loop $repeat|0 - get_local $1 - get_local $3 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $1 + get_local $3 + i32.lt_s + if get_local $0 get_local $2 get_local $0 @@ -8283,9 +8226,7 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end get_local $7 get_local $0 @@ -8508,12 +8449,11 @@ tee_local $7 call $~lib/internal/string/allocateUnsafe set_local $0 - block $break|0 - loop $repeat|0 - get_local $2 - get_local $3 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $2 + get_local $3 + i32.lt_s + if get_local $5 get_local $2 i32.const 2 @@ -8550,9 +8490,7 @@ i32.add set_local $2 br $repeat|0 - unreachable end - unreachable end get_local $5 get_local $3 @@ -8697,12 +8635,11 @@ tee_local $7 call $~lib/internal/string/allocateUnsafe set_local $2 - block $break|0 - loop $repeat|0 - get_local $1 - get_local $3 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $1 + get_local $3 + i32.lt_s + if get_local $0 get_local $2 get_local $0 @@ -8731,9 +8668,7 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end get_local $7 get_local $0 @@ -8843,12 +8778,11 @@ tee_local $7 call $~lib/internal/string/allocateUnsafe set_local $2 - block $break|0 - loop $repeat|0 - get_local $1 - get_local $3 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $1 + get_local $3 + i32.lt_s + if get_local $0 get_local $2 get_local $0 @@ -8879,9 +8813,7 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end get_local $7 get_local $0 @@ -9190,12 +9122,11 @@ tee_local $7 call $~lib/internal/string/allocateUnsafe set_local $2 - block $break|0 - loop $repeat|0 - get_local $1 - get_local $3 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $1 + get_local $3 + i32.lt_s + if get_local $0 get_local $2 get_local $0 @@ -9226,9 +9157,7 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end get_local $7 get_local $0 @@ -9428,12 +9357,11 @@ tee_local $7 call $~lib/internal/string/allocateUnsafe set_local $2 - block $break|0 - loop $repeat|0 - get_local $1 - get_local $3 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $1 + get_local $3 + i32.lt_s + if get_local $0 get_local $2 get_local $0 @@ -9464,9 +9392,7 @@ i32.add set_local $1 br $repeat|0 - unreachable end - unreachable end get_local $7 get_local $0 @@ -9676,12 +9602,11 @@ tee_local $8 call $~lib/internal/string/allocateUnsafe set_local $0 - block $break|0 - loop $repeat|0 - get_local $3 - get_local $4 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $3 + get_local $4 + i32.lt_s + if get_local $2 get_local $0 get_local $2 @@ -9710,9 +9635,7 @@ i32.add set_local $3 br $repeat|0 - unreachable end - unreachable end get_local $0 set_local $3 @@ -12140,6 +12063,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -12158,6 +12083,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -12176,6 +12103,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes if @@ -12192,6 +12121,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes if @@ -12208,6 +12139,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -12226,6 +12159,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -12244,6 +12179,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -12262,6 +12199,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -12280,6 +12219,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -12298,6 +12239,8 @@ call $~lib/array/Array#indexOf i32.const 0 i32.ge_s + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -13174,8 +13117,8 @@ i32.const 31 i32.const 0 call $~lib/array/Array#reduce - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/boolVal get_global $std/array/boolVal i32.const 1 @@ -13192,8 +13135,8 @@ i32.const 32 i32.const 0 call $~lib/array/Array#reduce - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/boolVal get_global $std/array/boolVal if @@ -13332,8 +13275,8 @@ i32.const 38 i32.const 0 call $~lib/array/Array#reduceRight - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/boolVal get_global $std/array/boolVal i32.const 1 @@ -13350,8 +13293,8 @@ i32.const 39 i32.const 0 call $~lib/array/Array#reduceRight - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/boolVal get_global $std/array/boolVal if diff --git a/tests/compiler/std/array.untouched.wat b/tests/compiler/std/array.untouched.wat index c7b9ad26..5d810d10 100644 --- a/tests/compiler/std/array.untouched.wat +++ b/tests/compiler/std/array.untouched.wat @@ -3743,8 +3743,8 @@ get_local $1 call_indirect (type $iiii) end - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $3 return @@ -3844,8 +3844,8 @@ get_local $1 call_indirect (type $iiii) end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 @@ -3941,8 +3941,8 @@ get_local $1 call_indirect (type $iiii) end - i32.const 1 - i32.and + i32.const 0 + i32.ne if i32.const 1 return @@ -4395,8 +4395,8 @@ get_local $1 call_indirect (type $iiii) end - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $4 get_local $6 @@ -4524,8 +4524,8 @@ ) (func $start~anonymous|31 (; 77 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) get_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $0 else @@ -4599,8 +4599,8 @@ ) (func $start~anonymous|32 (; 79 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) get_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $0 else @@ -4693,8 +4693,8 @@ ) (func $start~anonymous|38 (; 86 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) get_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $0 else @@ -4755,8 +4755,8 @@ ) (func $start~anonymous|39 (; 88 ;) (type $iiiii) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) get_local $0 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $0 else @@ -10058,8 +10058,8 @@ i32.add i32.load8_u offset=8 end - i32.const 1 - i32.and + i32.const 0 + i32.ne select return end @@ -10099,8 +10099,8 @@ set_local $4 i32.const 4 get_local $4 - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz i32.add set_local $8 @@ -10109,8 +10109,8 @@ i32.const 2800 i32.const 2816 get_local $4 - i32.const 1 - i32.and + i32.const 0 + i32.ne select i32.const 0 get_local $8 @@ -10153,8 +10153,8 @@ set_local $4 i32.const 4 get_local $4 - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz i32.add set_local $8 @@ -10163,8 +10163,8 @@ i32.const 2800 i32.const 2816 get_local $4 - i32.const 1 - i32.and + i32.const 0 + i32.ne select i32.const 0 get_local $8 @@ -16724,8 +16724,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -16753,8 +16753,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -16782,8 +16782,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 0 @@ -16811,8 +16811,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 0 @@ -16840,8 +16840,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -16869,8 +16869,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -16898,8 +16898,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -16927,8 +16927,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -16956,8 +16956,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -16985,8 +16985,8 @@ i32.const 0 i32.ge_s end - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/includes get_global $std/array/includes i32.const 1 @@ -17931,8 +17931,8 @@ i32.const 31 i32.const 0 call $~lib/array/Array#reduce - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/boolVal get_global $std/array/boolVal i32.const 1 @@ -17950,8 +17950,8 @@ i32.const 32 i32.const 0 call $~lib/array/Array#reduce - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/boolVal get_global $std/array/boolVal i32.const 0 @@ -18108,8 +18108,8 @@ i32.const 38 i32.const 0 call $~lib/array/Array#reduceRight - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/boolVal get_global $std/array/boolVal i32.const 1 @@ -18127,8 +18127,8 @@ i32.const 39 i32.const 0 call $~lib/array/Array#reduceRight - i32.const 1 - i32.and + i32.const 0 + i32.ne set_global $std/array/boolVal get_global $std/array/boolVal i32.const 0 diff --git a/tests/compiler/std/arraybuffer.untouched.wat b/tests/compiler/std/arraybuffer.untouched.wat index c225962f..f74e1ee5 100644 --- a/tests/compiler/std/arraybuffer.untouched.wat +++ b/tests/compiler/std/arraybuffer.untouched.wat @@ -419,8 +419,8 @@ call $~lib/internal/arraybuffer/allocateUnsafe set_local $3 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if get_local $3 diff --git a/tests/compiler/std/dataview.optimized.wat b/tests/compiler/std/dataview.optimized.wat index b986bd8e..45e697b0 100644 --- a/tests/compiler/std/dataview.optimized.wat +++ b/tests/compiler/std/dataview.optimized.wat @@ -484,8 +484,6 @@ unreachable end get_local $2 - i32.const 1 - i32.and if (result f32) get_local $0 i32.load @@ -559,8 +557,6 @@ unreachable end get_local $1 - i32.const 1 - i32.and if (result f64) get_local $0 i32.load @@ -654,8 +650,6 @@ i32.load16_s offset=8 set_local $0 get_local $2 - i32.const 1 - i32.and i32.eqz if get_local $0 @@ -711,8 +705,6 @@ i32.load offset=8 set_local $0 get_local $2 - i32.const 1 - i32.and i32.eqz if get_local $0 @@ -752,8 +744,6 @@ i64.load offset=8 set_local $2 get_local $1 - i32.const 1 - i32.and i32.eqz if get_local $2 @@ -837,8 +827,6 @@ i32.load16_u offset=8 set_local $0 get_local $2 - i32.const 1 - i32.and i32.eqz if get_local $0 @@ -869,8 +857,6 @@ unreachable end get_local $2 - i32.const 1 - i32.and if get_local $0 i32.load @@ -915,8 +901,6 @@ unreachable end get_local $2 - i32.const 1 - i32.and if get_local $0 i32.load @@ -978,8 +962,6 @@ i32.add set_local $0 get_local $2 - i32.const 1 - i32.and i32.eqz if get_local $1 @@ -1019,8 +1001,6 @@ i32.add set_local $0 get_local $2 - i32.const 1 - i32.and i32.eqz if get_local $1 @@ -1060,8 +1040,6 @@ i32.add set_local $0 get_local $2 - i32.const 1 - i32.and i32.eqz if get_local $1 @@ -1092,8 +1070,6 @@ i32.add set_local $0 get_local $2 - i32.const 1 - i32.and i32.eqz if get_local $1 diff --git a/tests/compiler/std/dataview.untouched.wat b/tests/compiler/std/dataview.untouched.wat index 5a0f8145..109ac035 100644 --- a/tests/compiler/std/dataview.untouched.wat +++ b/tests/compiler/std/dataview.untouched.wat @@ -629,8 +629,8 @@ unreachable end get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result f32) get_local $0 i32.load @@ -723,8 +723,8 @@ unreachable end get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result f64) get_local $0 i32.load @@ -843,8 +843,8 @@ i32.load16_s offset=8 set_local $6 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $6 else @@ -907,8 +907,8 @@ i32.load offset=8 set_local $6 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $6 else @@ -996,8 +996,8 @@ i64.load offset=8 set_local $6 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i64) get_local $6 else @@ -1099,8 +1099,8 @@ i32.load16_u offset=8 set_local $6 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $6 else @@ -1149,8 +1149,8 @@ i32.load offset=8 set_local $6 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $6 else @@ -1199,8 +1199,8 @@ i64.load offset=8 set_local $6 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i64) get_local $6 else @@ -1239,8 +1239,8 @@ unreachable end get_local $3 - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $0 i32.load @@ -1296,8 +1296,8 @@ unreachable end get_local $3 - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $0 i32.load @@ -1400,8 +1400,8 @@ get_local $1 i32.add get_local $3 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $2 else @@ -1448,8 +1448,8 @@ get_local $1 i32.add get_local $3 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $2 else @@ -1496,8 +1496,8 @@ get_local $1 i32.add get_local $3 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i64) get_local $2 else @@ -1584,8 +1584,8 @@ get_local $1 i32.add get_local $3 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $2 else @@ -1632,8 +1632,8 @@ get_local $1 i32.add get_local $3 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i32) get_local $2 else @@ -1680,8 +1680,8 @@ get_local $1 i32.add get_local $3 - i32.const 1 - i32.and + i32.const 0 + i32.ne if (result i64) get_local $2 else diff --git a/tests/compiler/std/gc-array.optimized.wat b/tests/compiler/std/gc-array.optimized.wat index 5ba55e34..5998a907 100644 --- a/tests/compiler/std/gc-array.optimized.wat +++ b/tests/compiler/std/gc-array.optimized.wat @@ -229,13 +229,10 @@ get_global $~lib/collector/itcm/state tee_local $0 if - block $tablify|0 - get_local $0 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $tablify|0 - end - br $break|0 + get_local $0 + i32.const 1 + i32.sub + br_table $case1|0 $case2|0 $case3|0 $break|0 end i32.const 16 call $~lib/allocator/arena/__memory_allocate diff --git a/tests/compiler/std/gc-basics.optimized.wat b/tests/compiler/std/gc-basics.optimized.wat index b719e9a4..a282029e 100644 --- a/tests/compiler/std/gc-basics.optimized.wat +++ b/tests/compiler/std/gc-basics.optimized.wat @@ -186,13 +186,10 @@ get_global $~lib/collector/itcm/state tee_local $0 if - block $tablify|0 - get_local $0 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $tablify|0 - end - br $break|0 + get_local $0 + i32.const 1 + i32.sub + br_table $case1|0 $case2|0 $case3|0 $break|0 end i32.const 16 call $~lib/allocator/arena/__memory_allocate diff --git a/tests/compiler/std/gc-object.optimized.wat b/tests/compiler/std/gc-object.optimized.wat index 801fade4..a188b7ea 100644 --- a/tests/compiler/std/gc-object.optimized.wat +++ b/tests/compiler/std/gc-object.optimized.wat @@ -178,13 +178,10 @@ get_global $~lib/collector/itcm/state tee_local $0 if - block $tablify|0 - get_local $0 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $tablify|0 - end - br $break|0 + get_local $0 + i32.const 1 + i32.sub + br_table $case1|0 $case2|0 $case3|0 $break|0 end i32.const 16 call $~lib/allocator/arena/__memory_allocate diff --git a/tests/compiler/std/libm.optimized.wat b/tests/compiler/std/libm.optimized.wat index e96fecdd..8c5547f2 100644 --- a/tests/compiler/std/libm.optimized.wat +++ b/tests/compiler/std/libm.optimized.wat @@ -1072,13 +1072,10 @@ block $case1|0 get_local $2 if - block $tablify|0 - get_local $2 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $tablify|0 - end - br $case4|0 + get_local $2 + i32.const 1 + i32.sub + br_table $case1|0 $case2|0 $case3|0 $case4|0 end f64.const 0.4636476090008061 get_local $1 @@ -1317,13 +1314,10 @@ block $case1|1 get_local $3 if - block $tablify|00 - get_local $3 - i32.const 1 - i32.sub - br_table $case1|1 $case2|1 $case3|1 $tablify|00 - end - br $break|1 + get_local $3 + i32.const 1 + i32.sub + br_table $case1|1 $case2|1 $case3|1 $break|1 end f64.const 0.7853981633974483 return @@ -1344,13 +1338,10 @@ block $case1|2 get_local $3 if - block $tablify|01 - get_local $3 - i32.const 1 - i32.sub - br_table $case1|2 $case2|2 $case3|2 $tablify|01 - end - br $break|2 + get_local $3 + i32.const 1 + i32.sub + br_table $case1|2 $case2|2 $case3|2 $break|2 end f64.const 0 return @@ -1411,13 +1402,10 @@ get_local $3 tee_local $2 if - block $tablify|02 - get_local $2 - i32.const 1 - i32.sub - br_table $case1|3 $case2|3 $case3|3 $tablify|02 - end - br $break|3 + get_local $2 + i32.const 1 + i32.sub + br_table $case1|3 $case2|3 $case3|3 $break|3 end get_local $0 return diff --git a/tests/compiler/std/map.optimized.wat b/tests/compiler/std/map.optimized.wat index 7b278c08..631729f9 100644 --- a/tests/compiler/std/map.optimized.wat +++ b/tests/compiler/std/map.optimized.wat @@ -357,8 +357,6 @@ call $~lib/internal/arraybuffer/allocateUnsafe set_local $2 get_local $1 - i32.const 1 - i32.and i32.eqz if get_local $2 @@ -787,12 +785,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_s + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -852,9 +849,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -1455,12 +1450,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_u - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_u + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -1516,9 +1510,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -2209,12 +2201,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_s + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -2274,9 +2265,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -2924,12 +2913,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_u - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_u + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -2985,9 +2973,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -3628,12 +3614,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_s + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -3685,9 +3670,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -3958,12 +3941,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_u - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_u + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -4015,9 +3997,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -4734,12 +4714,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i64.const 100 - i64.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i64.const 100 + i64.lt_s + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -4793,9 +4772,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -5071,12 +5048,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i64.const 100 - i64.ge_u - br_if $break|0 + loop $repeat|0 + get_local $0 + i64.const 100 + i64.lt_u + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -5130,9 +5106,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -5743,13 +5717,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - f32.const 100 - f32.lt - i32.eqz - br_if $break|0 + loop $repeat|0 + get_local $0 + f32.const 100 + f32.lt + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -5803,9 +5775,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -6419,13 +6389,11 @@ (local $1 i32) call $~lib/map/Map#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - f64.const 100 - f64.lt - i32.eqz - br_if $break|0 + loop $repeat|0 + get_local $0 + f64.const 100 + f64.lt + if get_local $1 get_local $0 call $~lib/map/Map#has @@ -6479,9 +6447,7 @@ br $repeat|0 end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 diff --git a/tests/compiler/std/map.untouched.wat b/tests/compiler/std/map.untouched.wat index 1f20ea28..6c470afb 100644 --- a/tests/compiler/std/map.untouched.wat +++ b/tests/compiler/std/map.untouched.wat @@ -441,8 +441,8 @@ call $~lib/internal/arraybuffer/allocateUnsafe set_local $3 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if get_local $3 diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index 76ae033e..eb6393e1 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -185,6 +185,8 @@ get_local $0 f64.eq i32.and + i32.const 0 + i32.ne get_local $1 i64.reinterpret/f64 i64.const 63 @@ -194,6 +196,8 @@ get_local $1 f64.eq i32.and + i32.const 0 + i32.ne i32.eq if get_local $2 @@ -381,6 +385,8 @@ get_local $0 f32.eq i32.and + i32.const 0 + i32.ne get_local $1 i32.reinterpret/f32 i32.const 31 @@ -389,6 +395,8 @@ get_local $1 f32.eq i32.and + i32.const 0 + i32.ne i32.eq if get_local $2 @@ -2326,13 +2334,10 @@ block $case1|0 get_local $2 if - block $tablify|0 - get_local $2 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $tablify|0 - end - br $case4|0 + get_local $2 + i32.const 1 + i32.sub + br_table $case1|0 $case2|0 $case3|0 $case4|0 end f64.const 0.4636476090008061 get_local $1 @@ -2544,13 +2549,10 @@ block $case1|0 get_local $1 if - block $tablify|0 - get_local $1 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $tablify|0 - end - br $case4|0 + get_local $1 + i32.const 1 + i32.sub + br_table $case1|0 $case2|0 $case3|0 $case4|0 end f32.const 0.46364760398864746 get_local $2 @@ -2865,13 +2867,10 @@ block $case1|1 get_local $3 if - block $tablify|00 - get_local $3 - i32.const 1 - i32.sub - br_table $case1|1 $case2|1 $case3|1 $tablify|00 - end - br $break|1 + get_local $3 + i32.const 1 + i32.sub + br_table $case1|1 $case2|1 $case3|1 $break|1 end f64.const 0.7853981633974483 return @@ -2892,13 +2891,10 @@ block $case1|2 get_local $3 if - block $tablify|01 - get_local $3 - i32.const 1 - i32.sub - br_table $case1|2 $case2|2 $case3|2 $tablify|01 - end - br $break|2 + get_local $3 + i32.const 1 + i32.sub + br_table $case1|2 $case2|2 $case3|2 $break|2 end f64.const 0 return @@ -2959,13 +2955,10 @@ get_local $3 tee_local $2 if - block $tablify|02 - get_local $2 - i32.const 1 - i32.sub - br_table $case1|3 $case2|3 $case3|3 $tablify|02 - end - br $break|3 + get_local $2 + i32.const 1 + i32.sub + br_table $case1|3 $case2|3 $case3|3 $break|3 end get_local $0 return @@ -3120,13 +3113,10 @@ block $case1|1 get_local $3 if - block $tablify|00 - get_local $3 - i32.const 1 - i32.sub - br_table $case1|1 $case2|1 $case3|1 $tablify|00 - end - br $break|1 + get_local $3 + i32.const 1 + i32.sub + br_table $case1|1 $case2|1 $case3|1 $break|1 end f32.const 0.7853981852531433 return @@ -3147,13 +3137,10 @@ block $case1|2 get_local $3 if - block $tablify|01 - get_local $3 - i32.const 1 - i32.sub - br_table $case1|2 $case2|2 $case3|2 $tablify|01 - end - br $break|2 + get_local $3 + i32.const 1 + i32.sub + br_table $case1|2 $case2|2 $case3|2 $break|2 end f32.const 0 return @@ -3214,13 +3201,10 @@ get_local $3 tee_local $2 if - block $tablify|02 - get_local $2 - i32.const 1 - i32.sub - br_table $case1|3 $case2|3 $case3|3 $tablify|02 - end - br $break|3 + get_local $2 + i32.const 1 + i32.sub + br_table $case1|3 $case2|3 $case3|3 $break|3 end get_local $0 return @@ -6089,8 +6073,6 @@ set_local $5 end get_local $5 - i32.const 1 - i32.and if get_local $0 get_local $1 diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index 711d7453..8eeaaf96 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -258,8 +258,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne block $~lib/math/NativeMath.signbit|inlined.3 (result i32) get_local $1 i64.reinterpret/f64 @@ -271,8 +271,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eq if get_local $2 @@ -493,8 +493,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne block $~lib/math/NativeMathf.signbit|inlined.3 (result i32) get_local $1 i32.reinterpret/f32 @@ -505,8 +505,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eq if get_local $2 @@ -7089,8 +7089,8 @@ get_local $1 f64.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $0 get_local $1 @@ -7373,8 +7373,8 @@ get_local $1 f32.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $0 get_local $1 @@ -35810,8 +35810,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -35836,8 +35836,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -35862,8 +35862,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -35888,8 +35888,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -35914,8 +35914,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -35941,8 +35941,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -35967,8 +35967,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -35994,8 +35994,8 @@ f64.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -36019,8 +36019,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -36044,8 +36044,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -36069,8 +36069,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -36094,8 +36094,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz @@ -36119,8 +36119,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -36145,8 +36145,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -36170,8 +36170,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 0 i32.eq i32.eqz @@ -36196,8 +36196,8 @@ f32.eq i32.and end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.const 1 i32.eq i32.eqz diff --git a/tests/compiler/std/mod.optimized.wat b/tests/compiler/std/mod.optimized.wat index 7345721c..c584c0f7 100644 --- a/tests/compiler/std/mod.optimized.wat +++ b/tests/compiler/std/mod.optimized.wat @@ -322,8 +322,6 @@ set_local $5 end get_local $5 - i32.const 1 - i32.and if get_local $0 get_local $1 diff --git a/tests/compiler/std/mod.untouched.wat b/tests/compiler/std/mod.untouched.wat index 2471617f..d1e68472 100644 --- a/tests/compiler/std/mod.untouched.wat +++ b/tests/compiler/std/mod.untouched.wat @@ -78,8 +78,8 @@ get_local $1 f64.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $0 get_local $1 @@ -389,8 +389,8 @@ get_local $1 f32.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne if get_local $0 get_local $1 diff --git a/tests/compiler/std/set.optimized.wat b/tests/compiler/std/set.optimized.wat index 1670373f..495c53c7 100644 --- a/tests/compiler/std/set.optimized.wat +++ b/tests/compiler/std/set.optimized.wat @@ -358,8 +358,6 @@ call $~lib/internal/arraybuffer/allocateUnsafe set_local $2 get_local $1 - i32.const 1 - i32.and i32.eqz if get_local $2 @@ -756,12 +754,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_s + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -794,9 +791,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -1295,12 +1290,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_u - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_u + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -1333,9 +1327,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -1922,12 +1914,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_s + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -1960,9 +1951,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -2498,12 +2487,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_u - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_u + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -2536,9 +2524,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -3093,12 +3079,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_s + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -3131,9 +3116,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -3352,12 +3335,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i32.const 100 - i32.ge_u - br_if $break|0 + loop $repeat|0 + get_local $0 + i32.const 100 + i32.lt_u + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -3390,9 +3372,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -4033,12 +4013,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i64.const 100 - i64.ge_s - br_if $break|0 + loop $repeat|0 + get_local $0 + i64.const 100 + i64.lt_s + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -4071,9 +4050,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -4292,12 +4269,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - i64.const 100 - i64.ge_u - br_if $break|0 + loop $repeat|0 + get_local $0 + i64.const 100 + i64.lt_u + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -4330,9 +4306,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -4862,13 +4836,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - f32.const 100 - f32.lt - i32.eqz - br_if $break|0 + loop $repeat|0 + get_local $0 + f32.const 100 + f32.lt + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -4901,9 +4873,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 @@ -5436,13 +5406,11 @@ (local $1 i32) call $~lib/set/Set#constructor set_local $1 - block $break|0 - loop $repeat|0 - get_local $0 - f64.const 100 - f64.lt - i32.eqz - br_if $break|0 + loop $repeat|0 + get_local $0 + f64.const 100 + f64.lt + if get_local $1 get_local $0 call $~lib/set/Set#has @@ -5475,9 +5443,7 @@ unreachable end unreachable - unreachable end - unreachable end get_local $1 i32.load offset=20 diff --git a/tests/compiler/std/set.untouched.wat b/tests/compiler/std/set.untouched.wat index ff47e5eb..457a7517 100644 --- a/tests/compiler/std/set.untouched.wat +++ b/tests/compiler/std/set.untouched.wat @@ -443,8 +443,8 @@ call $~lib/internal/arraybuffer/allocateUnsafe set_local $3 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if get_local $3 diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index d1d57a09..e6f6bfdd 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -593,8 +593,8 @@ get_local $4 i32.sub set_local $3 - block $break|0 - loop $repeat|0 + loop $repeat|0 + block $break|0 get_local $2 get_local $3 i32.gt_s @@ -615,9 +615,7 @@ return end unreachable - unreachable end - unreachable end i32.const -1 ) @@ -1736,24 +1734,20 @@ block $case3|0 block $case2|0 block $case1|0 - block $case0|0 - get_local $2 - i32.load - tee_local $6 - set_local $5 - get_local $6 - i32.eqz - br_if $break|0 - block $tablify|0 - get_local $5 - i32.const 1 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $case4|0 $tablify|0 - end - br $case5|0 - unreachable + get_local $2 + i32.load + tee_local $6 + set_local $5 + get_local $6 + i32.eqz + br_if $break|0 + block $tablify|0 + get_local $5 + i32.const 1 + i32.sub + br_table $case1|0 $case2|0 $case3|0 $case4|0 $tablify|0 end - unreachable + br $case5|0 end get_local $2 i32.load16_u offset=4 @@ -2460,8 +2454,8 @@ end set_local $1 end - block $break|1 - loop $continue|1 + loop $continue|1 + block $break|1 get_local $4 tee_local $0 i32.const 1 @@ -2612,8 +2606,8 @@ f64.const 1 end set_local $6 - block $break|0 - loop $continue|0 + loop $continue|0 + block $break|0 get_local $3 tee_local $0 i32.const 1 @@ -2633,8 +2627,8 @@ set_local $1 f64.const 0.1 set_local $5 - block $break|1 - loop $continue|1 + loop $continue|1 + block $break|1 get_local $3 tee_local $0 i32.const 1 @@ -4252,13 +4246,10 @@ i32.const 10 i32.ne if - block $tablify|0 - get_local $2 - i32.const 1 - i32.sub - br_table $case9|1 $case8|1 $case7|1 $case6|1 $case5|1 $case4|1 $case3|1 $case2|1 $case1|1 $tablify|0 - end - br $case10|1 + get_local $2 + i32.const 1 + i32.sub + br_table $case9|1 $case8|1 $case7|1 $case6|1 $case5|1 $case4|1 $case3|1 $case2|1 $case1|1 $case10|1 end get_local $7 i32.const 1000000000 diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index 0d768a78..ef756096 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -6905,8 +6905,8 @@ i32.const -1 i32.ne end - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if i32.const 0 diff --git a/tests/compiler/std/symbol.optimized.wat b/tests/compiler/std/symbol.optimized.wat index 3dc725ba..6b5db84d 100644 --- a/tests/compiler/std/symbol.optimized.wat +++ b/tests/compiler/std/symbol.optimized.wat @@ -383,8 +383,6 @@ call $~lib/internal/arraybuffer/allocateUnsafe set_local $2 get_local $1 - i32.const 1 - i32.and i32.eqz if get_local $2 @@ -2405,13 +2403,10 @@ i32.const 1 i32.ne if - block $tablify|0 - get_local $2 - i32.const 2 - i32.sub - br_table $case1|0 $case2|0 $case3|0 $case4|0 $case5|0 $case6|0 $case7|0 $case8|0 $case9|0 $case10|0 $tablify|0 - end - br $case11|0 + get_local $2 + i32.const 2 + i32.sub + br_table $case1|0 $case2|0 $case3|0 $case4|0 $case5|0 $case6|0 $case7|0 $case8|0 $case9|0 $case10|0 $case11|0 end i32.const 176 set_local $1 diff --git a/tests/compiler/std/symbol.untouched.wat b/tests/compiler/std/symbol.untouched.wat index 6e258679..537cad0c 100644 --- a/tests/compiler/std/symbol.untouched.wat +++ b/tests/compiler/std/symbol.untouched.wat @@ -491,8 +491,8 @@ call $~lib/internal/arraybuffer/allocateUnsafe set_local $3 get_local $2 - i32.const 1 - i32.and + i32.const 0 + i32.ne i32.eqz if get_local $3 diff --git a/tests/compiler/std/typedarray.optimized.wat b/tests/compiler/std/typedarray.optimized.wat index 01147bfb..f0ec2665 100644 --- a/tests/compiler/std/typedarray.optimized.wat +++ b/tests/compiler/std/typedarray.optimized.wat @@ -1226,12 +1226,12 @@ i32.const 1 i32.sub set_local $5 - block $break|1 - loop $continue|1 - get_local $5 - i32.const 0 - i32.ge_s - if + loop $continue|1 + get_local $5 + i32.const 0 + i32.ge_s + if + block $break|1 get_local $0 get_local $1 i32.add @@ -2086,12 +2086,12 @@ select end set_local $3 - block $break|0 - loop $repeat|0 - get_local $2 - get_local $3 - i32.ge_s - br_if $break|0 + loop $repeat|0 + get_local $2 + get_local $3 + i32.ge_s + i32.eqz + if get_local $6 get_local $7 i32.add @@ -2106,9 +2106,7 @@ i32.add set_local $2 br $repeat|0 - unreachable end - unreachable end get_local $0 )