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

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

Issue 2616613002: [turbofan] Add constant-folding for Float64RoundDown. (Closed)
Patch Set: Created 3 years, 11 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/base/ieee754.h" 9 #include "src/base/ieee754.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 case IrOpcode::kFloat64InsertHighWord32: 657 case IrOpcode::kFloat64InsertHighWord32:
658 return ReduceFloat64InsertHighWord32(node); 658 return ReduceFloat64InsertHighWord32(node);
659 case IrOpcode::kStore: 659 case IrOpcode::kStore:
660 case IrOpcode::kUnalignedStore: 660 case IrOpcode::kUnalignedStore:
661 case IrOpcode::kCheckedStore: 661 case IrOpcode::kCheckedStore:
662 return ReduceStore(node); 662 return ReduceStore(node);
663 case IrOpcode::kFloat64Equal: 663 case IrOpcode::kFloat64Equal:
664 case IrOpcode::kFloat64LessThan: 664 case IrOpcode::kFloat64LessThan:
665 case IrOpcode::kFloat64LessThanOrEqual: 665 case IrOpcode::kFloat64LessThanOrEqual:
666 return ReduceFloat64Compare(node); 666 return ReduceFloat64Compare(node);
667 case IrOpcode::kFloat64RoundDown:
668 return ReduceFloat64RoundDown(node);
667 default: 669 default:
668 break; 670 break;
669 } 671 }
670 return NoChange(); 672 return NoChange();
671 } 673 }
672 674
673 Reduction MachineOperatorReducer::ReduceInt32Add(Node* node) { 675 Reduction MachineOperatorReducer::ReduceInt32Add(Node* node) {
674 DCHECK_EQ(IrOpcode::kInt32Add, node->opcode()); 676 DCHECK_EQ(IrOpcode::kInt32Add, node->opcode());
675 Int32BinopMatcher m(node); 677 Int32BinopMatcher m(node);
676 if (m.right().Is(0)) return Replace(m.left().node()); // x + 0 => x 678 if (m.right().Is(0)) return Replace(m.left().node()); // x + 0 => x
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 : m.left().InputAt(0)); 1386 : m.left().InputAt(0));
1385 node->ReplaceInput( 1387 node->ReplaceInput(
1386 1, m.right().HasValue() 1388 1, m.right().HasValue()
1387 ? Float32Constant(static_cast<float>(m.right().Value())) 1389 ? Float32Constant(static_cast<float>(m.right().Value()))
1388 : m.right().InputAt(0)); 1390 : m.right().InputAt(0));
1389 return Changed(node); 1391 return Changed(node);
1390 } 1392 }
1391 return NoChange(); 1393 return NoChange();
1392 } 1394 }
1393 1395
1396 Reduction MachineOperatorReducer::ReduceFloat64RoundDown(Node* node) {
1397 DCHECK_EQ(IrOpcode::kFloat64RoundDown, node->opcode());
1398 Float64Matcher m(node->InputAt(0));
1399 if (m.HasValue()) {
1400 return ReplaceFloat64(Floor(m.Value()));
1401 }
1402 return NoChange();
1403 }
1394 1404
1395 CommonOperatorBuilder* MachineOperatorReducer::common() const { 1405 CommonOperatorBuilder* MachineOperatorReducer::common() const {
1396 return jsgraph()->common(); 1406 return jsgraph()->common();
1397 } 1407 }
1398 1408
1399 1409
1400 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 1410 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
1401 return jsgraph()->machine(); 1411 return jsgraph()->machine();
1402 } 1412 }
1403 1413
1404 1414
1405 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 1415 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
1406 1416
1407 } // namespace compiler 1417 } // namespace compiler
1408 } // namespace internal 1418 } // namespace internal
1409 } // namespace v8 1419 } // 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