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

Side by Side Diff: src/compiler/wasm-compiler.cc

Issue 1519823002: [wasm] Fixed FxxMin and FxxMax for cases where one operand is 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/change-lowering.h" 7 #include "src/compiler/change-lowering.h"
8 #include "src/compiler/common-operator.h" 8 #include "src/compiler/common-operator.h"
9 #include "src/compiler/diamond.h" 9 #include "src/compiler/diamond.h"
10 #include "src/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 op = m->Float64LessThanOrEqual(); 608 op = m->Float64LessThanOrEqual();
609 break; 609 break;
610 case wasm::kExprF64Gt: 610 case wasm::kExprF64Gt:
611 op = m->Float64LessThan(); 611 op = m->Float64LessThan();
612 std::swap(left, right); 612 std::swap(left, right);
613 break; 613 break;
614 case wasm::kExprF64Ge: 614 case wasm::kExprF64Ge:
615 op = m->Float64LessThanOrEqual(); 615 op = m->Float64LessThanOrEqual();
616 std::swap(left, right); 616 std::swap(left, right);
617 break; 617 break;
618 case wasm::kExprF32Min: { 618 case wasm::kExprF32Min:
619 if (m->Float32Min().IsSupported()) { 619 return BuildF32Min(left, right);
620 op = m->Float32Min().op(); 620 case wasm::kExprF64Min:
621 break; 621 return BuildF64Min(left, right);
622 } else { 622 case wasm::kExprF32Max:
623 op = UnsupportedOpcode(opcode); 623 return BuildF32Max(left, right);
624 break; 624 case wasm::kExprF64Max:
625 } 625 return BuildF64Max(left, right);
626 }
627 case wasm::kExprF64Min: {
628 if (m->Float64Min().IsSupported()) {
629 op = m->Float64Min().op();
630 break;
631 } else {
632 op = UnsupportedOpcode(opcode);
633 break;
634 }
635 }
636 case wasm::kExprF32Max: {
637 if (m->Float32Max().IsSupported()) {
638 op = m->Float32Max().op();
639 break;
640 } else {
641 op = UnsupportedOpcode(opcode);
642 break;
643 }
644 }
645 case wasm::kExprF64Max: {
646 if (m->Float64Max().IsSupported()) {
647 op = m->Float64Max().op();
648 break;
649 } else {
650 op = UnsupportedOpcode(opcode);
651 break;
652 }
653 }
654 default: 626 default:
655 op = UnsupportedOpcode(opcode); 627 op = UnsupportedOpcode(opcode);
656 } 628 }
657 return graph()->NewNode(op, left, right); 629 return graph()->NewNode(op, left, right);
658 } 630 }
659 631
660 632
661 Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) { 633 Node* WasmGraphBuilder::Unop(wasm::WasmOpcode opcode, Node* input) {
662 const Operator* op; 634 const Operator* op;
663 MachineOperatorBuilder* m = jsgraph()->machine(); 635 MachineOperatorBuilder* m = jsgraph()->machine();
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 Binop(wasm::kExprI32Ior, Binop(wasm::kExprI32And, high_word_left, 956 Binop(wasm::kExprI32Ior, Binop(wasm::kExprI32And, high_word_left,
985 jsgraph()->Int32Constant(0x7fffffff)), 957 jsgraph()->Int32Constant(0x7fffffff)),
986 Binop(wasm::kExprI32And, high_word_right, 958 Binop(wasm::kExprI32And, high_word_right,
987 jsgraph()->Int32Constant(0x80000000))); 959 jsgraph()->Int32Constant(0x80000000)));
988 960
989 return graph()->NewNode(m->Float64InsertHighWord32(), left, new_high_word); 961 return graph()->NewNode(m->Float64InsertHighWord32(), left, new_high_word);
990 #endif 962 #endif
991 } 963 }
992 964
993 965
966 Node* WasmGraphBuilder::BuildF32Min(Node* left, Node* right) {
967 Diamond left_le_right(graph(), jsgraph()->common(),
968 Binop(wasm::kExprF32Le, left, right));
969
970 Diamond right_lt_left(graph(), jsgraph()->common(),
971 Binop(wasm::kExprF32Lt, right, left));
972
973 Diamond left_is_not_nan(graph(), jsgraph()->common(),
974 Binop(wasm::kExprF32Eq, left, left));
975
976 return left_le_right.Phi(
977 wasm::kAstF32, left,
978 right_lt_left.Phi(wasm::kAstF32, right,
979 left_is_not_nan.Phi(wasm::kAstF32, right, left)));
980 }
981
982
983 Node* WasmGraphBuilder::BuildF32Max(Node* left, Node* right) {
984 Diamond left_ge_right(graph(), jsgraph()->common(),
985 Binop(wasm::kExprF32Ge, left, right));
986
987 Diamond right_gt_left(graph(), jsgraph()->common(),
988 Binop(wasm::kExprF32Gt, right, left));
989
990 Diamond left_is_not_nan(graph(), jsgraph()->common(),
991 Binop(wasm::kExprF32Eq, left, left));
992
993 return left_ge_right.Phi(
994 wasm::kAstF32, left,
995 right_gt_left.Phi(wasm::kAstF32, right,
996 left_is_not_nan.Phi(wasm::kAstF32, right, left)));
997 }
998
999
1000 Node* WasmGraphBuilder::BuildF64Min(Node* left, Node* right) {
1001 Diamond left_le_right(graph(), jsgraph()->common(),
1002 Binop(wasm::kExprF64Le, left, right));
1003
1004 Diamond right_lt_left(graph(), jsgraph()->common(),
1005 Binop(wasm::kExprF64Lt, right, left));
1006
1007 Diamond left_is_not_nan(graph(), jsgraph()->common(),
1008 Binop(wasm::kExprF64Eq, left, left));
1009
1010 return left_le_right.Phi(
1011 wasm::kAstF64, left,
1012 right_lt_left.Phi(wasm::kAstF64, right,
1013 left_is_not_nan.Phi(wasm::kAstF64, right, left)));
1014 }
1015
1016
1017 Node* WasmGraphBuilder::BuildF64Max(Node* left, Node* right) {
1018 Diamond left_ge_right(graph(), jsgraph()->common(),
1019 Binop(wasm::kExprF64Ge, left, right));
1020
1021 Diamond right_gt_left(graph(), jsgraph()->common(),
1022 Binop(wasm::kExprF64Lt, right, left));
1023
1024 Diamond left_is_not_nan(graph(), jsgraph()->common(),
1025 Binop(wasm::kExprF64Eq, left, left));
1026
1027 return left_ge_right.Phi(
1028 wasm::kAstF64, left,
1029 right_gt_left.Phi(wasm::kAstF64, right,
1030 left_is_not_nan.Phi(wasm::kAstF64, right, left)));
1031 }
1032
1033
994 Node* WasmGraphBuilder::BuildI32Ctz(Node* input) { 1034 Node* WasmGraphBuilder::BuildI32Ctz(Node* input) {
995 //// Implement the following code as TF graph. 1035 //// Implement the following code as TF graph.
996 // value = value | (value << 1); 1036 // value = value | (value << 1);
997 // value = value | (value << 2); 1037 // value = value | (value << 2);
998 // value = value | (value << 4); 1038 // value = value | (value << 4);
999 // value = value | (value << 8); 1039 // value = value | (value << 8);
1000 // value = value | (value << 16); 1040 // value = value | (value << 16);
1001 // return CountPopulation32(0xffffffff XOR value); 1041 // return CountPopulation32(0xffffffff XOR value);
1002 1042
1003 Node* result = 1043 Node* result =
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 code->Disassemble(buffer, os); 1870 code->Disassemble(buffer, os);
1831 } 1871 }
1832 #endif 1872 #endif
1833 return code; 1873 return code;
1834 } 1874 }
1835 1875
1836 1876
1837 } // namespace compiler 1877 } // namespace compiler
1838 } // namespace internal 1878 } // namespace internal
1839 } // namespace v8 1879 } // namespace v8
OLDNEW
« 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