[wasm] Fixed F32Neg and F64Neg for -0.0.
R=titzer@chromium.org Review URL: https://codereview.chromium.org/1516143004 Cr-Commit-Position: refs/heads/master@{#32802}
This commit is contained in:
parent
df2a92972b
commit
3ee4c36089
@ -692,8 +692,8 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) {
|
||||
op = m->Float32Abs();
|
||||
break;
|
||||
case wasm::kExprF32Neg:
|
||||
op = m->Float32Sub();
|
||||
return graph()->NewNode(op, jsgraph()->Float32Constant(0), input);
|
||||
op = m->Float32Mul();
|
||||
return graph()->NewNode(op, jsgraph()->Float32Constant(-1), input);
|
||||
case wasm::kExprF32Sqrt:
|
||||
op = m->Float32Sqrt();
|
||||
break;
|
||||
@ -701,8 +701,8 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) {
|
||||
op = m->Float64Abs();
|
||||
break;
|
||||
case wasm::kExprF64Neg:
|
||||
op = m->Float64Sub();
|
||||
return graph()->NewNode(op, jsgraph()->Float64Constant(0), input);
|
||||
op = m->Float64Mul();
|
||||
return graph()->NewNode(op, jsgraph()->Float64Constant(-1), input);
|
||||
case wasm::kExprF64Sqrt:
|
||||
op = m->Float64Sqrt();
|
||||
break;
|
||||
|
@ -1153,6 +1153,30 @@ TEST(Run_WasmFloat64Unops) {
|
||||
}
|
||||
|
||||
|
||||
TEST(Run_WasmFloat32Neg) {
|
||||
WasmRunner<float> r(MachineType::Float32());
|
||||
BUILD(r, WASM_F32_NEG(WASM_GET_LOCAL(0)));
|
||||
|
||||
FOR_FLOAT32_INPUTS(i) { CheckFloatEq(-(*i), r.Call(*i)); }
|
||||
|
||||
// The difference between +0 and -0 matters here.
|
||||
CHECK_EQ(bit_cast<uint32_t>(-0.0f), bit_cast<uint32_t>(r.Call(0.0f)));
|
||||
CHECK_EQ(bit_cast<uint32_t>(0.0f), bit_cast<uint32_t>(r.Call(-0.0f)));
|
||||
}
|
||||
|
||||
|
||||
TEST(Run_WasmFloat64Neg) {
|
||||
WasmRunner<double> r(MachineType::Float64());
|
||||
BUILD(r, WASM_F64_NEG(WASM_GET_LOCAL(0)));
|
||||
|
||||
FOR_FLOAT64_INPUTS(i) { CheckDoubleEq(-(*i), r.Call(*i)); }
|
||||
|
||||
// The difference between +0 and -0 matters here.
|
||||
CHECK_EQ(bit_cast<uint64_t>(-0.0), bit_cast<uint64_t>(r.Call(0.0)));
|
||||
CHECK_EQ(bit_cast<uint64_t>(0.0), bit_cast<uint64_t>(r.Call(-0.0)));
|
||||
}
|
||||
|
||||
|
||||
TEST(Run_Wasm_IfElse_P) {
|
||||
WasmRunner<int32_t> r(MachineType::Int32());
|
||||
// if (p0) return 11; else return 22;
|
||||
|
Loading…
Reference in New Issue
Block a user