Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Unified Diff: src/compiler/wasm-compiler.cc

Issue 1532513002: [wasm] Fixed FxxNeg for inputs of NaN. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index fd5b1e28248b87612712047471dfac1ee2ebd675..41e524dda6b77f8725917833897022f4fcf2f7e5 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -664,8 +664,7 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) {
op = m->Float32Abs();
break;
case wasm::kExprF32Neg:
- op = m->Float32Mul();
- return graph()->NewNode(op, jsgraph()->Float32Constant(-1), input);
+ return BuildF32Neg(input);
case wasm::kExprF32Sqrt:
op = m->Float32Sqrt();
break;
@@ -673,8 +672,7 @@ Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) {
op = m->Float64Abs();
break;
case wasm::kExprF64Neg:
- op = m->Float64Mul();
- return graph()->NewNode(op, jsgraph()->Float64Constant(-1), input);
+ return BuildF64Neg(input);
case wasm::kExprF64Sqrt:
op = m->Float64Sqrt();
break;
@@ -980,6 +978,36 @@ Node* WasmGraphBuilder::Unreachable() {
}
+Node* WasmGraphBuilder::BuildF32Neg(Node* input) {
+ Node* result =
+ Unop(wasm::kExprF32ReinterpretI32,
+ Binop(wasm::kExprI32Xor, Unop(wasm::kExprI32ReinterpretF32, input),
+ jsgraph()->Int32Constant(0x80000000)));
+
+ return result;
+}
+
+
+Node* WasmGraphBuilder::BuildF64Neg(Node* input) {
+#if WASM_64
+ Node* result =
+ Unop(wasm::kExprF64ReinterpretI64,
+ Binop(wasm::kExprI64Xor, Unop(wasm::kExprI64ReinterpretF64, input),
+ jsgraph()->Int64Constant(0x8000000000000000)));
+
+ return result;
+#else
+ MachineOperatorBuilder* m = jsgraph()->machine();
+
+ Node* old_high_word = graph()->NewNode(m->Float64ExtractHighWord32(), input);
+ Node* new_high_word = Binop(wasm::kExprI32Xor, old_high_word,
+ jsgraph()->Int32Constant(0x80000000));
+
+ return graph()->NewNode(m->Float64InsertHighWord32(), input, new_high_word);
+#endif
+}
+
+
Node* WasmGraphBuilder::BuildF32CopySign(Node* left, Node* right) {
Node* result = Unop(
wasm::kExprF32ReinterpretI32,
« no previous file with comments | « src/compiler/wasm-compiler.h ('k') | test/cctest/wasm/test-run-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698