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

Side by Side Diff: src/compiler/machine-operator-reducer.cc

Issue 1235663002: [turbofan] Reduce Float64 comparison to Float32. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/compiler/machine-operator-reducer.h" 5 #include "src/compiler/machine-operator-reducer.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/base/division-by-constant.h" 8 #include "src/base/division-by-constant.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/compiler/diamond.h" 10 #include "src/compiler/diamond.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (m.HasValue()) return ReplaceFloat32(DoubleToFloat32(m.Value())); 432 if (m.HasValue()) return ReplaceFloat32(DoubleToFloat32(m.Value()));
433 if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0)); 433 if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0));
434 break; 434 break;
435 } 435 }
436 case IrOpcode::kFloat64InsertLowWord32: 436 case IrOpcode::kFloat64InsertLowWord32:
437 return ReduceFloat64InsertLowWord32(node); 437 return ReduceFloat64InsertLowWord32(node);
438 case IrOpcode::kFloat64InsertHighWord32: 438 case IrOpcode::kFloat64InsertHighWord32:
439 return ReduceFloat64InsertHighWord32(node); 439 return ReduceFloat64InsertHighWord32(node);
440 case IrOpcode::kStore: 440 case IrOpcode::kStore:
441 return ReduceStore(node); 441 return ReduceStore(node);
442 case IrOpcode::kFloat64Equal:
443 case IrOpcode::kFloat64LessThan:
444 case IrOpcode::kFloat64LessThanOrEqual:
445 return ReduceFloat64Compare(node);
442 default: 446 default:
443 break; 447 break;
444 } 448 }
445 return NoChange(); 449 return NoChange();
446 } 450 }
447 451
448 452
449 Reduction MachineOperatorReducer::ReduceInt32Add(Node* node) { 453 Reduction MachineOperatorReducer::ReduceInt32Add(Node* node) {
450 DCHECK_EQ(IrOpcode::kInt32Add, node->opcode()); 454 DCHECK_EQ(IrOpcode::kInt32Add, node->opcode());
451 Int32BinopMatcher m(node); 455 Int32BinopMatcher m(node);
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 Uint32Matcher mrhs(node->InputAt(1)); 1001 Uint32Matcher mrhs(node->InputAt(1));
998 if (mlhs.HasValue() && mrhs.HasValue()) { 1002 if (mlhs.HasValue() && mrhs.HasValue()) {
999 return ReplaceFloat64(bit_cast<double>( 1003 return ReplaceFloat64(bit_cast<double>(
1000 (bit_cast<uint64_t>(mlhs.Value()) & V8_UINT64_C(0xFFFFFFFF)) | 1004 (bit_cast<uint64_t>(mlhs.Value()) & V8_UINT64_C(0xFFFFFFFF)) |
1001 (static_cast<uint64_t>(mrhs.Value()) << 32))); 1005 (static_cast<uint64_t>(mrhs.Value()) << 32)));
1002 } 1006 }
1003 return NoChange(); 1007 return NoChange();
1004 } 1008 }
1005 1009
1006 1010
1011 Reduction MachineOperatorReducer::ReduceFloat64Compare(Node* node) {
1012 DCHECK((IrOpcode::kFloat64Equal == node->opcode()) ||
1013 (IrOpcode::kFloat64LessThan == node->opcode()) ||
1014 (IrOpcode::kFloat64LessThanOrEqual == node->opcode()));
1015 // As all Float32 values have an exact representation in Float64, comparing
1016 // two Float64 values both converted from Float32 is equivalent to comparing
1017 // the original Float32s, so we can ignore the conversions.
1018 Float64BinopMatcher m(node);
1019 if (m.left().IsChangeFloat32ToFloat64() &&
1020 m.right().IsChangeFloat32ToFloat64()) {
1021 switch (node->opcode()) {
1022 case IrOpcode::kFloat64Equal:
1023 node->set_op(machine()->Float32Equal());
1024 break;
1025 case IrOpcode::kFloat64LessThan:
1026 node->set_op(machine()->Float32LessThan());
1027 break;
1028 case IrOpcode::kFloat64LessThanOrEqual:
1029 node->set_op(machine()->Float32LessThanOrEqual());
1030 break;
1031 default:
1032 return NoChange();
1033 }
1034 node->ReplaceInput(0, m.left().InputAt(0));
1035 node->ReplaceInput(1, m.right().InputAt(0));
1036 return Changed(node);
1037 }
1038 return NoChange();
1039 }
1040
1041
1007 CommonOperatorBuilder* MachineOperatorReducer::common() const { 1042 CommonOperatorBuilder* MachineOperatorReducer::common() const {
1008 return jsgraph()->common(); 1043 return jsgraph()->common();
1009 } 1044 }
1010 1045
1011 1046
1012 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 1047 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
1013 return jsgraph()->machine(); 1048 return jsgraph()->machine();
1014 } 1049 }
1015 1050
1016 1051
1017 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 1052 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
1018 1053
1019 } // namespace compiler 1054 } // namespace compiler
1020 } // namespace internal 1055 } // namespace internal
1021 } // namespace v8 1056 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/machine-operator-reducer.h ('k') | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698