diff --git a/src/compiler.ts b/src/compiler.ts index 99de950cd2..1a112611c1 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -3682,7 +3682,7 @@ export class Compiler extends DiagnosticEmitter { // f32 to int if (fromType.kind == TypeKind.F32) { if (toType.isBooleanValue) { - expr = module.binary(BinaryOp.NeF32, expr, module.f32(0)); + expr = this.makeIsTrueish(expr, Type.f32, reportNode); wrap = false; } else if (toType.isSignedIntegerValue) { if (toType.isLongIntegerValue) { @@ -3701,7 +3701,7 @@ export class Compiler extends DiagnosticEmitter { // f64 to int } else { if (toType.isBooleanValue) { - expr = module.binary(BinaryOp.NeF64, expr, module.f64(0)); + expr = this.makeIsTrueish(expr, Type.f64, reportNode); wrap = false; } else if (toType.isSignedIntegerValue) { if (toType.isLongIntegerValue) { @@ -10790,32 +10790,38 @@ export class Compiler extends DiagnosticEmitter { : expr; } case TypeKind.F32: { - // (x != 0.0) & (x == x) - let flow = this.currentFlow; - let temp = flow.getTempLocal(Type.f32); - let ret = module.binary(BinaryOp.AndI32, - module.binary(BinaryOp.NeF32, module.local_tee(temp.index, expr), module.f32(0)), - module.binary(BinaryOp.EqF32, - module.local_get(temp.index, NativeType.F32), - module.local_get(temp.index, NativeType.F32) - ) + // 0 < abs(bitCast(x)) <= bitCast(Infinity) or + // (reinterpret(x) & 0x7FFFFFFF) - 1 <= 0x7F800000 - 1 + // + // and finally: + // (reinterpret(x) << 1) - (1 << 1) <= ((0x7F800000 - 1) << 1) + return module.binary(BinaryOp.LeU32, + module.binary(BinaryOp.SubI32, + module.binary(BinaryOp.ShlI32, + module.unary(UnaryOp.ReinterpretF32, expr), + module.i32(1) + ), + module.i32(2) // 1 << 1 + ), + module.i32(0xFEFFFFFE) // (0x7F800000 - 1) << 1 ); - flow.freeTempLocal(temp); - return ret; } case TypeKind.F64: { - // (x != 0.0) & (x == x) - let flow = this.currentFlow; - let temp = flow.getTempLocal(Type.f64); - let ret = module.binary(BinaryOp.AndI32, - module.binary(BinaryOp.NeF64, module.local_tee(temp.index, expr), module.f64(0)), - module.binary(BinaryOp.EqF64, - module.local_get(temp.index, NativeType.F64), - module.local_get(temp.index, NativeType.F64) - ) + // 0 < abs(bitCast(x)) <= bitCast(Infinity) or + // (reinterpret(x) & 0x7FFFFFFFFFFFFFFF) - 1 <= 0x7FF0000000000000 - 1 + // + // and finally: + // (reinterpret(x) << 1) - (1 << 1) <= ((0x7FF0000000000000 - 1) << 1) + return module.binary(BinaryOp.LeU64, + module.binary(BinaryOp.SubI64, + module.binary(BinaryOp.ShlI64, + module.unary(UnaryOp.ReinterpretF64, expr), + module.i64(1) + ), + module.i64(2) // 1 << 1 + ), + module.i64(0xFFFFFFFE, 0xFFDFFFFF) // (0x7FF0000000000000 - 1) << 1 ); - flow.freeTempLocal(temp); - return ret; } case TypeKind.EXTERNREF: { // TODO: non-null object might still be considered falseish diff --git a/tests/compiler/bool.ts b/tests/compiler/bool.ts index e1052f6a5c..626f58076c 100644 --- a/tests/compiler/bool.ts +++ b/tests/compiler/bool.ts @@ -6,9 +6,68 @@ var u = 2; assert(u == true); var U = 2; assert(U == true); + var f = 2; assert(f == true); +var f0 = +0.0; +assert(f0 == false); +var f1 = -0.0; +assert(f1 == false); +var f2 = +NaN; +assert(f2 == false); +var f3 = -NaN; +assert(f3 == false); +var f4 = +f32.MAX_VALUE; +assert(f4 == true); +var f5 = -f32.MAX_VALUE; +assert(f5 == true); +var f6 = +Infinity; +assert(f6 == true); +var f7 = -Infinity; +assert(f7 == true); +var f8 = +f32.MIN_VALUE; +assert(f8 == true); +var f9 = -f32.MIN_VALUE; +assert(f9 == true); +var f10 = reinterpret(1); +assert(f10 == true); +var f11 = reinterpret(0x7F800000 - 1); +assert(f11 == true); +var f12 = reinterpret(0x7F800000 + 1); +assert(f12 == false); +var f13 = reinterpret(0xFF800000 + 1); +assert(f13 == false); + var F = 2; assert(F == true); +var F0 = +0.0; +assert(F0 == false); +var F1 = -0.0; +assert(F1 == false); +var F2 = +NaN; +assert(F2 == false); +var F3 = -NaN; +assert(F3 == false); +var F4 = +f64.MAX_VALUE; +assert(F4 == true); +var F5 = -f64.MAX_VALUE; +assert(F5 == true); +var F6 = +Infinity; +assert(F6 == true); +var F7 = -Infinity; +assert(F7 == true); +var F8 = +f64.MIN_VALUE; +assert(F8 == true); +var F9 = -f64.MIN_VALUE; +assert(F9 == true); +var F10 = reinterpret(1); +assert(F10 == true); +var F11 = reinterpret(0x7FF0000000000000 - 1); +assert(F11 == true); +var F12 = reinterpret(0x7FF0000000000000 + 1); +assert(F12 == false); +var F13 = reinterpret(0xFFF0000000000000 + 1); +assert(F13 == false); + var uu = 2; assert(uu == true); diff --git a/tests/compiler/bool.untouched.wat b/tests/compiler/bool.untouched.wat index 8889b9859d..0e8c20c19e 100644 --- a/tests/compiler/bool.untouched.wat +++ b/tests/compiler/bool.untouched.wat @@ -10,7 +10,39 @@ (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/f0 (mut f32) (f32.const 0)) + (global $bool/f1 (mut f32) (f32.const -0)) + (global $bool/f2 (mut f32) (f32.const nan:0x400000)) + (global $bool/f3 (mut f32) (f32.const 0)) + (global $~lib/builtins/f32.MAX_VALUE f32 (f32.const 3402823466385288598117041e14)) + (global $bool/f4 (mut f32) (f32.const 0)) + (global $bool/f5 (mut f32) (f32.const 0)) + (global $bool/f6 (mut f32) (f32.const inf)) + (global $bool/f7 (mut f32) (f32.const 0)) + (global $~lib/builtins/f32.MIN_VALUE f32 (f32.const 1.401298464324817e-45)) + (global $bool/f8 (mut f32) (f32.const 0)) + (global $bool/f9 (mut f32) (f32.const 0)) + (global $bool/f10 (mut f32) (f32.const 0)) + (global $bool/f11 (mut f32) (f32.const 0)) + (global $bool/f12 (mut f32) (f32.const 0)) + (global $bool/f13 (mut f32) (f32.const 0)) (global $bool/F (mut f64) (f64.const 2)) + (global $bool/F0 (mut f64) (f64.const 0)) + (global $bool/F1 (mut f64) (f64.const -0)) + (global $bool/F2 (mut f64) (f64.const nan:0x8000000000000)) + (global $bool/F3 (mut f64) (f64.const 0)) + (global $~lib/builtins/f64.MAX_VALUE f64 (f64.const 1797693134862315708145274e284)) + (global $bool/F4 (mut f64) (f64.const 0)) + (global $bool/F5 (mut f64) (f64.const 0)) + (global $bool/F6 (mut f64) (f64.const inf)) + (global $bool/F7 (mut f64) (f64.const 0)) + (global $~lib/builtins/f64.MIN_VALUE f64 (f64.const 5e-324)) + (global $bool/F8 (mut f64) (f64.const 0)) + (global $bool/F9 (mut f64) (f64.const 0)) + (global $bool/F10 (mut f64) (f64.const 0)) + (global $bool/F11 (mut f64) (f64.const 0)) + (global $bool/F12 (mut f64) (f64.const 0)) + (global $bool/F13 (mut f64) (f64.const 0)) (global $bool/uu (mut i32) (i32.const 2)) (export "memory" (memory $0)) (start $~start) @@ -72,29 +104,639 @@ unreachable end global.get $bool/f - f32.const 0 - f32.ne + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 11 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $bool/f0 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 13 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $bool/f1 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 15 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $bool/f2 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 17 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + f32.const nan:0x400000 + f32.neg + global.set $bool/f3 + global.get $bool/f3 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 19 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/builtins/f32.MAX_VALUE + global.set $bool/f4 + global.get $bool/f4 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 21 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/builtins/f32.MAX_VALUE + f32.neg + global.set $bool/f5 + global.get $bool/f5 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 23 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $bool/f6 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 25 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + f32.const inf + f32.neg + global.set $bool/f7 + global.get $bool/f7 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 27 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/builtins/f32.MIN_VALUE + global.set $bool/f8 + global.get $bool/f8 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u i32.const 1 i32.eq i32.eqz if i32.const 0 i32.const 32 - i32.const 10 + i32.const 29 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/builtins/f32.MIN_VALUE + f32.neg + global.set $bool/f9 + global.get $bool/f9 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 31 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + i32.const 1 + f32.reinterpret_i32 + global.set $bool/f10 + global.get $bool/f10 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 33 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + i32.const 2139095040 + i32.const 1 + i32.sub + f32.reinterpret_i32 + global.set $bool/f11 + global.get $bool/f11 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 35 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + i32.const 2139095040 + i32.const 1 + i32.add + f32.reinterpret_i32 + global.set $bool/f12 + global.get $bool/f12 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 37 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + i32.const -8388608 + i32.const 1 + i32.add + f32.reinterpret_i32 + global.set $bool/f13 + global.get $bool/f13 + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 39 i32.const 1 call $~lib/builtins/abort unreachable end global.get $bool/F - f64.const 0 - f64.ne + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u i32.const 1 i32.eq i32.eqz if i32.const 0 i32.const 32 - i32.const 12 + i32.const 42 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $bool/F0 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 44 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $bool/F1 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 46 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $bool/F2 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 48 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + f64.const nan:0x8000000000000 + f64.neg + global.set $bool/F3 + global.get $bool/F3 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 50 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/builtins/f64.MAX_VALUE + global.set $bool/F4 + global.get $bool/F4 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 52 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/builtins/f64.MAX_VALUE + f64.neg + global.set $bool/F5 + global.get $bool/F5 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 54 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $bool/F6 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 56 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + f64.const inf + f64.neg + global.set $bool/F7 + global.get $bool/F7 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 58 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/builtins/f64.MIN_VALUE + global.set $bool/F8 + global.get $bool/F8 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 60 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + global.get $~lib/builtins/f64.MIN_VALUE + f64.neg + global.set $bool/F9 + global.get $bool/F9 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 62 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + i64.const 1 + f64.reinterpret_i64 + global.set $bool/F10 + global.get $bool/F10 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 64 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + i64.const 9218868437227405312 + i64.const 1 + i64.sub + f64.reinterpret_i64 + global.set $bool/F11 + global.get $bool/F11 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 66 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + i64.const 9218868437227405312 + i64.const 1 + i64.add + f64.reinterpret_i64 + global.set $bool/F12 + global.get $bool/F12 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 68 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + i64.const -4503599627370496 + i64.const 1 + i64.add + f64.reinterpret_i64 + global.set $bool/F13 + global.get $bool/F13 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 32 + i32.const 70 i32.const 1 call $~lib/builtins/abort unreachable @@ -108,7 +750,7 @@ if i32.const 0 i32.const 32 - i32.const 14 + i32.const 73 i32.const 1 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/logical.untouched.wat b/tests/compiler/logical.untouched.wat index c2dcfa73ee..5ce7daa94c 100644 --- a/tests/compiler/logical.untouched.wat +++ b/tests/compiler/logical.untouched.wat @@ -1600,8 +1600,8 @@ local.get $2 ) (func $start:logical - (local $0 f64) - (local $1 f32) + (local $0 f32) + (local $1 f64) (local $2 i32) (local $3 i32) i32.const 0 @@ -1612,13 +1612,13 @@ end drop f64.const 0 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result i32) unreachable else @@ -1633,13 +1633,13 @@ end drop f64.const 1 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result i32) i32.const 1 else @@ -1659,25 +1659,25 @@ end drop f64.const 1 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result f64) f64.const 2 else f64.const 1 end - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result i32) i32.const 1 else @@ -1765,13 +1765,13 @@ unreachable end f32.const 1 - local.tee $1 - f32.const 0 - f32.ne - local.get $1 - local.get $1 - f32.eq - i32.and + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u if (result f32) f32.const 2 else @@ -1791,13 +1791,13 @@ unreachable end f32.const 0 - local.tee $1 - f32.const 0 - f32.ne - local.get $1 - local.get $1 - f32.eq - i32.and + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u if (result f32) f32.const 0 else @@ -1817,13 +1817,13 @@ unreachable end f64.const 1 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result f64) f64.const 2 else @@ -1843,13 +1843,13 @@ unreachable end f64.const 0 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result f64) f64.const 0 else @@ -1869,13 +1869,13 @@ unreachable end f32.const nan:0x400000 - local.tee $1 - f32.const 0 - f32.ne - local.get $1 - local.get $1 - f32.eq - i32.and + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u if (result f32) f32.const nan:0x400000 else @@ -1895,13 +1895,13 @@ unreachable end f32.const 1 - local.tee $1 - f32.const 0 - f32.ne - local.get $1 - local.get $1 - f32.eq - i32.and + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u if (result f32) f32.const 1 else @@ -1921,13 +1921,13 @@ unreachable end f64.const nan:0x8000000000000 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result f64) f64.const nan:0x8000000000000 else @@ -1947,13 +1947,13 @@ unreachable end f64.const 1 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result f64) f64.const 1 else @@ -1973,13 +1973,13 @@ unreachable end f32.const 1 - local.tee $1 - f32.const 0 - f32.ne - local.get $1 - local.get $1 - f32.eq - i32.and + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u if (result f32) f32.const nan:0x400000 else @@ -1987,8 +1987,8 @@ end global.set $logical/f global.get $logical/f - local.tee $1 - local.get $1 + local.tee $0 + local.get $0 f32.ne i32.eqz if @@ -2000,13 +2000,13 @@ unreachable end f32.const nan:0x400000 - local.tee $1 - f32.const 0 - f32.ne - local.get $1 - local.get $1 - f32.eq - i32.and + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u if (result f32) f32.const 1 else @@ -2014,8 +2014,8 @@ end global.set $logical/f global.get $logical/f - local.tee $1 - local.get $1 + local.tee $0 + local.get $0 f32.ne i32.eqz if @@ -2027,13 +2027,13 @@ unreachable end f64.const 1 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result f64) f64.const nan:0x8000000000000 else @@ -2041,8 +2041,8 @@ end global.set $logical/F global.get $logical/F - local.tee $0 - local.get $0 + local.tee $1 + local.get $1 f64.ne i32.eqz if @@ -2054,13 +2054,13 @@ unreachable end f64.const nan:0x8000000000000 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u if (result f64) f64.const 1 else @@ -2068,8 +2068,8 @@ end global.set $logical/F global.get $logical/F - local.tee $0 - local.get $0 + local.tee $1 + local.get $1 f64.ne i32.eqz if diff --git a/tests/compiler/portable-conversions.untouched.wat b/tests/compiler/portable-conversions.untouched.wat index c719567b1c..6d00acc97a 100644 --- a/tests/compiler/portable-conversions.untouched.wat +++ b/tests/compiler/portable-conversions.untouched.wat @@ -515,8 +515,13 @@ unreachable end global.get $portable-conversions/f - f32.const 0 - f32.ne + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u i32.eqz if i32.const 0 @@ -527,8 +532,13 @@ unreachable end global.get $portable-conversions/F - f64.const 0 - f64.ne + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u i32.eqz if i32.const 0 diff --git a/tests/compiler/std/string.optimized.wat b/tests/compiler/std/string.optimized.wat index 16f5f05b5c..c156b0630c 100644 --- a/tests/compiler/std/string.optimized.wat +++ b/tests/compiler/std/string.optimized.wat @@ -2653,7 +2653,7 @@ end end f64.const 1 - local.set $5 + local.set $6 i32.const 1 local.get $2 i32.const 43 @@ -2675,7 +2675,7 @@ i32.const 45 i32.eq select - local.set $5 + local.set $6 local.get $4 i32.const 2 i32.add @@ -2845,25 +2845,25 @@ local.get $1 i32.ge_u if - local.get $6 - local.get $6 - f64.eq - local.get $6 - f64.const 0 - f64.ne - i32.and - i32.eqz + local.get $5 + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.gt_u br_if $folding-inner0 br $while-break|2 end - local.get $6 + local.get $5 local.get $1 f64.convert_i32_s f64.mul local.get $2 f64.convert_i32_u f64.add - local.set $6 + local.set $5 local.get $4 i32.const 2 i32.add @@ -2874,8 +2874,8 @@ end local.get $3 call $~lib/rt/pure/__release - local.get $5 local.get $6 + local.get $5 f64.mul return end diff --git a/tests/compiler/std/string.untouched.wat b/tests/compiler/std/string.untouched.wat index f5b19d53cf..2859ec44de 100644 --- a/tests/compiler/std/string.untouched.wat +++ b/tests/compiler/std/string.untouched.wat @@ -4828,13 +4828,13 @@ i32.ge_u if local.get $8 - local.tee $3 - f64.const 0 - f64.ne - local.get $3 - local.get $3 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u i32.eqz if i32.const 1 diff --git a/tests/compiler/unary.untouched.wat b/tests/compiler/unary.untouched.wat index 3a8879bbb3..30b1e390ab 100644 --- a/tests/compiler/unary.untouched.wat +++ b/tests/compiler/unary.untouched.wat @@ -9,10 +9,10 @@ (export "memory" (memory $0)) (start $~start) (func $start:unary - (local $0 f64) - (local $1 i32) - (local $2 i64) - (local $3 f32) + (local $0 i32) + (local $1 i64) + (local $2 f32) + (local $3 f64) i32.const 1 drop i32.const -1 @@ -29,13 +29,13 @@ f64.const -1.25 drop f64.const 1.25 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u i32.eqz drop global.get $unary/i @@ -104,18 +104,18 @@ global.get $unary/i global.set $unary/i global.get $unary/i - local.tee $1 + local.tee $0 i32.const 1 i32.add global.set $unary/i - local.get $1 + local.get $0 global.set $unary/i global.get $unary/i - local.tee $1 + local.tee $0 i32.const 1 i32.sub global.set $unary/i - local.get $1 + local.get $0 global.set $unary/i global.get $unary/I drop @@ -191,18 +191,18 @@ global.get $unary/I global.set $unary/I global.get $unary/I - local.tee $2 + local.tee $1 i64.const 1 i64.add global.set $unary/I - local.get $2 + local.get $1 global.set $unary/I global.get $unary/I - local.tee $2 + local.tee $1 i64.const 1 i64.sub global.set $unary/I - local.get $2 + local.get $1 global.set $unary/I global.get $unary/f drop @@ -210,13 +210,13 @@ f32.neg drop global.get $unary/f - local.tee $3 - f32.const 0 - f32.ne - local.get $3 - local.get $3 - f32.eq - i32.and + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u i32.eqz drop global.get $unary/f @@ -240,13 +240,13 @@ f32.const -1.25 global.set $unary/f f64.const 1.25 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u i32.eqz global.set $unary/i global.get $unary/f @@ -255,13 +255,13 @@ f32.neg global.set $unary/f global.get $unary/f - local.tee $3 - f32.const 0 - f32.ne - local.get $3 - local.get $3 - f32.eq - i32.and + i32.reinterpret_f32 + i32.const 1 + i32.shl + i32.const 2 + i32.sub + i32.const -16777218 + i32.le_u i32.eqz global.set $unary/i global.get $unary/f @@ -277,18 +277,18 @@ global.get $unary/f global.set $unary/f global.get $unary/f - local.tee $3 + local.tee $2 f32.const 1 f32.add global.set $unary/f - local.get $3 + local.get $2 global.set $unary/f global.get $unary/f - local.tee $3 + local.tee $2 f32.const 1 f32.sub global.set $unary/f - local.get $3 + local.get $2 global.set $unary/f global.get $unary/F drop @@ -296,13 +296,13 @@ f64.neg drop global.get $unary/F - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u i32.eqz drop global.get $unary/F @@ -326,13 +326,13 @@ f64.const -1.25 global.set $unary/F f64.const 1.25 - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u i32.eqz i64.extend_i32_u global.set $unary/I @@ -342,13 +342,13 @@ f64.neg global.set $unary/F global.get $unary/F - local.tee $0 - f64.const 0 - f64.ne - local.get $0 - local.get $0 - f64.eq - i32.and + i64.reinterpret_f64 + i64.const 1 + i64.shl + i64.const 2 + i64.sub + i64.const -9007199254740994 + i64.le_u i32.eqz i64.extend_i32_u global.set $unary/I @@ -365,18 +365,18 @@ global.get $unary/F global.set $unary/F global.get $unary/F - local.tee $0 + local.tee $3 f64.const 1 f64.add global.set $unary/F - local.get $0 + local.get $3 global.set $unary/F global.get $unary/F - local.tee $0 + local.tee $3 f64.const 1 f64.sub global.set $unary/F - local.get $0 + local.get $3 global.set $unary/F ) (func $~start