Commit f3ae77ff authored by ahaas's avatar ahaas Committed by Commit bot

[wasm] Do not fold f32-to-f64 and f64-to-f32 conversions.

R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2669753002
Cr-Commit-Position: refs/heads/master@{#42920}
parent 082bf306
...@@ -606,7 +606,13 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { ...@@ -606,7 +606,13 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
} }
case IrOpcode::kChangeFloat32ToFloat64: { case IrOpcode::kChangeFloat32ToFloat64: {
Float32Matcher m(node->InputAt(0)); Float32Matcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceFloat64(m.Value()); if (m.HasValue()) {
if (!allow_signalling_nan_ && std::isnan(m.Value())) {
// Do some calculation to make guarantee the value is a quiet NaN.
return ReplaceFloat64(m.Value() + m.Value());
}
return ReplaceFloat64(m.Value());
}
break; break;
} }
case IrOpcode::kChangeFloat64ToInt32: { case IrOpcode::kChangeFloat64ToInt32: {
...@@ -655,8 +661,15 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { ...@@ -655,8 +661,15 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
} }
case IrOpcode::kTruncateFloat64ToFloat32: { case IrOpcode::kTruncateFloat64ToFloat32: {
Float64Matcher m(node->InputAt(0)); Float64Matcher m(node->InputAt(0));
if (m.HasValue()) return ReplaceFloat32(DoubleToFloat32(m.Value())); if (m.HasValue()) {
if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0)); if (!allow_signalling_nan_ && std::isnan(m.Value())) {
// Do some calculation to make guarantee the value is a quiet NaN.
return ReplaceFloat32(DoubleToFloat32(m.Value() + m.Value()));
}
return ReplaceFloat32(DoubleToFloat32(m.Value()));
}
if (allow_signalling_nan_ && m.IsChangeFloat32ToFloat64())
return Replace(m.node()->InputAt(0));
break; break;
} }
case IrOpcode::kRoundFloat64ToInt32: { case IrOpcode::kRoundFloat64ToInt32: {
......
...@@ -10,15 +10,10 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -10,15 +10,10 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F32: sNaN - 0 = qNaN"); print("F32: sNaN - 0 = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F32Sub0", kSig_i_i) builder.addFunction("F32Sub0", kSig_i_i).addBody(
.addBody([ [ kExprGetLocal, 0, kExprF32ReinterpretI32, kExprF32Const, 0x00, 0x00,
kExprGetLocal, 0, 0x00, 0x00, // 0.0
kExprF32ReinterpretI32, kExprF32Sub, kExprI32ReinterpretF32, ]).exportFunc();
kExprF32Const, 0x00, 0x00, 0x00, 0x00, // 0.0
kExprF32Sub,
kExprI32ReinterpretF32,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
// F32Sub0(signalling_NaN) // F32Sub0(signalling_NaN)
assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000)); assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000));
...@@ -27,15 +22,10 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -27,15 +22,10 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F32: -0 sNaN = qNaN"); print("F32: -0 sNaN = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F32Sub0", kSig_i_i) builder.addFunction("F32Sub0", kSig_i_i).addBody(
.addBody([ [ kExprF32Const, 0x00, 0x00, 0x00, 0x80, // 0.0
kExprF32Const, 0x00, 0x00, 0x00, 0x80, // 0.0 kExprGetLocal, 0, kExprF32ReinterpretI32, kExprF32Sub,
kExprGetLocal, 0, kExprI32ReinterpretF32, ]).exportFunc();
kExprF32ReinterpretI32,
kExprF32Sub,
kExprI32ReinterpretF32,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
// F32Sub0(signalling_NaN) // F32Sub0(signalling_NaN)
assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000)); assertEquals(0x7fe00000, module.exports.F32Sub0(0x7fa00000));
...@@ -44,14 +34,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -44,14 +34,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F32: sNaN - X = qNaN"); print("F32: sNaN - X = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F32NaNSubX", kSig_i_i) builder.addFunction("F32NaNSubX", kSig_i_i).addBody(
.addBody([ [ kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, kExprF32Const, 0x12, 0x34, 0x56,
kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, 0x78, kExprF32Sub, kExprI32ReinterpretF32, ]).exportFunc();
kExprF32Const, 0x12, 0x34, 0x56, 0x78,
kExprF32Sub,
kExprI32ReinterpretF32,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7fe00000, module.exports.F32NaNSubX()); assertEquals(0x7fe00000, module.exports.F32NaNSubX());
})(); })();
...@@ -59,14 +44,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -59,14 +44,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F32: X - sNaN = qNaN"); print("F32: X - sNaN = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F32XSubNaN", kSig_i_i) builder.addFunction("F32XSubNaN", kSig_i_i).addBody(
.addBody([ [ kExprF32Const, 0x12, 0x34, 0x56, 0x78, kExprF32Const, 0x00, 0x00, 0xa0,
kExprF32Const, 0x12, 0x34, 0x56, 0x78, 0x7f, kExprF32Sub, kExprI32ReinterpretF32, ]).exportFunc();
kExprF32Const, 0x00, 0x00, 0xa0, 0x7f,
kExprF32Sub,
kExprI32ReinterpretF32,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7fe00000, module.exports.F32XSubNaN()); assertEquals(0x7fe00000, module.exports.F32XSubNaN());
})(); })();
...@@ -74,17 +54,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -74,17 +54,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: X + sNaN = qNaN"); print("F64: X + sNaN = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F32XAddNaN", kSig_i_i) builder.addFunction("F32XAddNaN", kSig_i_i).addBody(
.addBody([ [ kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
kExprF64Add, kExprF64Add, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU,
kExprI64ReinterpretF64, kExprI32ConvertI64, ]).exportFunc();
kExprI64Const, 32,
kExprI64ShrU,
kExprI32ConvertI64,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F32XAddNaN()); assertEquals(0x7ffa0000, module.exports.F32XAddNaN());
})(); })();
...@@ -92,18 +66,12 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -92,18 +66,12 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: sNaN - 0 = qNaN"); print("F64: sNaN - 0 = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F64Sub0", kSig_i_i) builder.addFunction("F64Sub0", kSig_i_i).addBody(
.addBody([ [ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff,
kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, 0x00, kExprF64ReinterpretI64, kExprF64Const, 0x00, 0x00, 0x00, 0x00,
kExprF64ReinterpretI64, 0x00, 0x00, 0x00, 0x00, // 0.0
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0.0 kExprF64Sub, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU,
kExprF64Sub, kExprI32ConvertI64, ]).exportFunc();
kExprI64ReinterpretF64,
kExprI64Const, 32,
kExprI64ShrU,
kExprI32ConvertI64,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64Sub0()); assertEquals(0x7ffa0000, module.exports.F64Sub0());
})(); })();
...@@ -111,18 +79,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -111,18 +79,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: -0 - sNaN = qNaN"); print("F64: -0 - sNaN = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F64Sub0", kSig_i_i) builder.addFunction("F64Sub0", kSig_i_i).addBody(
.addBody([ [ kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, // 0.0
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, // 0.0 kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff,
kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, 0x00, kExprF64ReinterpretI64, kExprF64Sub, kExprI64ReinterpretF64,
kExprF64ReinterpretI64, kExprI64Const, 32, kExprI64ShrU, kExprI32ConvertI64, ]).exportFunc();
kExprF64Sub,
kExprI64ReinterpretF64,
kExprI64Const, 32,
kExprI64ShrU,
kExprI32ConvertI64,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64Sub0()); assertEquals(0x7ffa0000, module.exports.F64Sub0());
})(); })();
...@@ -130,17 +91,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -130,17 +91,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: sNaN - X = qNaN"); print("F64: sNaN - X = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F64NaNSubX", kSig_i_i) builder.addFunction("F64NaNSubX", kSig_i_i).addBody(
.addBody([ [ kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Sub, kExprF64Sub, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU,
kExprI64ReinterpretF64, kExprI32ConvertI64, ]).exportFunc();
kExprI64Const, 32,
kExprI64ShrU,
kExprI32ConvertI64,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64NaNSubX()); assertEquals(0x7ffa0000, module.exports.F64NaNSubX());
})(); })();
...@@ -148,17 +103,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -148,17 +103,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: X - sNaN = qNaN"); print("F64: X - sNaN = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F64XSubNaN", kSig_i_i) builder.addFunction("F64XSubNaN", kSig_i_i).addBody(
.addBody([ [ kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
kExprF64Sub, kExprF64Sub, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU,
kExprI64ReinterpretF64, kExprI32ConvertI64, ]).exportFunc();
kExprI64Const, 32,
kExprI64ShrU,
kExprI32ConvertI64,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64XSubNaN()); assertEquals(0x7ffa0000, module.exports.F64XSubNaN());
})(); })();
...@@ -166,18 +115,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -166,18 +115,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: sNaN * 1 = qNaN"); print("F64: sNaN * 1 = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F64Mul1", kSig_i_i) builder.addFunction("F64Mul1", kSig_i_i).addBody(
.addBody([ [ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff,
kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, 0x00, kExprF64ReinterpretI64, kExprF64Const, 0x00, 0x00, 0x00, 0x00,
kExprF64ReinterpretI64, 0x00, 0x00, 0xf0, 0x3f, kExprF64Mul, kExprI64ReinterpretF64,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, kExprI64Const, 32, kExprI64ShrU, kExprI32ConvertI64, ]).exportFunc();
kExprF64Mul,
kExprI64ReinterpretF64,
kExprI64Const, 32,
kExprI64ShrU,
kExprI32ConvertI64,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64Mul1()); assertEquals(0x7ffa0000, module.exports.F64Mul1());
})(); })();
...@@ -185,17 +127,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -185,17 +127,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: X * sNaN = qNaN"); print("F64: X * sNaN = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F64XMulNaN", kSig_i_i) builder.addFunction("F64XMulNaN", kSig_i_i).addBody(
.addBody([ [ kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
kExprF64Mul, kExprF64Mul, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU,
kExprI64ReinterpretF64, kExprI32ConvertI64, ]).exportFunc();
kExprI64Const, 32,
kExprI64ShrU,
kExprI32ConvertI64,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64XMulNaN()); assertEquals(0x7ffa0000, module.exports.F64XMulNaN());
})(); })();
...@@ -203,18 +139,23 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -203,18 +139,23 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: sNaN / 1 = qNaN"); print("F64: sNaN / 1 = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F64Div1", kSig_i_i) builder.addFunction("F64Div1", kSig_i_i).addBody(
.addBody([ [ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff,
kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff, 0x00, 0x00, kExprF64ReinterpretI64, kExprF64Const, 0x00, 0x00, 0x00, 0x00,
kExprF64ReinterpretI64, 0x00, 0x00, 0xf0, 0x3f, kExprF64Div, kExprI64ReinterpretF64,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3f, kExprI64Const, 32, kExprI64ShrU, kExprI32ConvertI64, ]).exportFunc();
kExprF64Div, var module = builder.instantiate();
kExprI64ReinterpretF64, assertEquals(0x7ffa0000, module.exports.F64Div1());
kExprI64Const, 32, })();
kExprI64ShrU,
kExprI32ConvertI64, (function() {
]) print("F64: sNaN / -1 = qNaN");
.exportFunc(); var builder = new WasmModuleBuilder();
builder.addFunction("F64Div1", kSig_i_i).addBody(
[ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff,
0x00, kExprF64ReinterpretI64, kExprF64Const, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf0, 0xbf, kExprF64Div, kExprI64ReinterpretF64,
kExprI64Const, 32, kExprI64ShrU, kExprI32ConvertI64, ]).exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64Div1()); assertEquals(0x7ffa0000, module.exports.F64Div1());
})(); })();
...@@ -241,17 +182,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -241,17 +182,11 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: X / sNaN = qNaN"); print("F64: X / sNaN = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F64XDivNaN", kSig_i_i) builder.addFunction("F64XDivNaN", kSig_i_i).addBody(
.addBody([ [ kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
kExprF64Div, kExprF64Div, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU,
kExprI64ReinterpretF64, kExprI32ConvertI64, ]).exportFunc();
kExprI64Const, 32,
kExprI64ShrU,
kExprI32ConvertI64,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64XDivNaN()); assertEquals(0x7ffa0000, module.exports.F64XDivNaN());
})(); })();
...@@ -259,17 +194,44 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -259,17 +194,44 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
(function() { (function() {
print("F64: sNaN / X = qNaN"); print("F64: sNaN / X = qNaN");
var builder = new WasmModuleBuilder(); var builder = new WasmModuleBuilder();
builder.addFunction("F64NaNDivX", kSig_i_i) builder.addFunction("F64NaNDivX", kSig_i_i).addBody(
.addBody([ [ kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01, kExprF64Const, 0xde, 0xbc, 0x0a, 0x89, 0x67, 0x45, 0x23, 0x01,
kExprF64Div, kExprF64Div, kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU,
kExprI64ReinterpretF64, kExprI32ConvertI64, ]).exportFunc();
kExprI64Const, 32,
kExprI64ShrU,
kExprI32ConvertI64,
])
.exportFunc();
var module = builder.instantiate(); var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64NaNDivX()); assertEquals(0x7ffa0000, module.exports.F64NaNDivX());
})(); })();
(function() {
print("F32ConvertF64(sNaN) = qNaN");
var builder = new WasmModuleBuilder();
builder.addFunction("F32ConvertF64X", kSig_i_i).addBody(
[ kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f,
kExprF32ConvertF64, kExprI32ReinterpretF32, ]).exportFunc();
var module = builder.instantiate();
assertEquals(0x7fd00000, module.exports.F32ConvertF64X());
})();
(function() {
print("F64ConvertF32(sNaN) = qNaN");
var builder = new WasmModuleBuilder();
builder.addFunction("F64ConvertF32X", kSig_i_i).addBody(
[ kExprF32Const, 0x00, 0x00, 0xa0, 0x7f, kExprF64ConvertF32,
kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU,
kExprI32ConvertI64, ]).exportFunc();
var module = builder.instantiate();
assertEquals(0x7ffc0000, module.exports.F64ConvertF32X());
})();
(function() {
print("F64ConvertF32(F32ConvertF64(sNaN)) = qNaN");
var builder = new WasmModuleBuilder();
builder.addFunction("F64toF32toF64", kSig_i_i).addBody(
[ kExprI64Const, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9, 0xff,
0x00, kExprF64ReinterpretI64, kExprF32ConvertF64, kExprF64ConvertF32,
kExprI64ReinterpretF64, kExprI64Const, 32, kExprI64ShrU,
kExprI32ConvertI64, ]).exportFunc();
var module = builder.instantiate();
assertEquals(0x7ffa0000, module.exports.F64toF32toF64());
})();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment