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

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

Issue 1919513002: [turbofan] Introduce TruncateTaggedToWord32 simplified operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 case IrOpcode::kChangeUint32ToFloat64: { 412 case IrOpcode::kChangeUint32ToFloat64: {
413 Uint32Matcher m(node->InputAt(0)); 413 Uint32Matcher m(node->InputAt(0));
414 if (m.HasValue()) return ReplaceFloat64(FastUI2D(m.Value())); 414 if (m.HasValue()) return ReplaceFloat64(FastUI2D(m.Value()));
415 break; 415 break;
416 } 416 }
417 case IrOpcode::kChangeUint32ToUint64: { 417 case IrOpcode::kChangeUint32ToUint64: {
418 Uint32Matcher m(node->InputAt(0)); 418 Uint32Matcher m(node->InputAt(0));
419 if (m.HasValue()) return ReplaceInt64(static_cast<uint64_t>(m.Value())); 419 if (m.HasValue()) return ReplaceInt64(static_cast<uint64_t>(m.Value()));
420 break; 420 break;
421 } 421 }
422 case IrOpcode::kTruncateFloat64ToInt32: 422 case IrOpcode::kTruncateFloat64ToWord32: {
423 return ReduceTruncateFloat64ToInt32(node); 423 Float64Matcher m(node->InputAt(0));
424 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
425 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
426 return NoChange();
427 }
424 case IrOpcode::kTruncateInt64ToInt32: { 428 case IrOpcode::kTruncateInt64ToInt32: {
425 Int64Matcher m(node->InputAt(0)); 429 Int64Matcher m(node->InputAt(0));
426 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value())); 430 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value()));
427 if (m.IsChangeInt32ToInt64()) return Replace(m.node()->InputAt(0)); 431 if (m.IsChangeInt32ToInt64()) return Replace(m.node()->InputAt(0));
428 break; 432 break;
429 } 433 }
430 case IrOpcode::kTruncateFloat64ToFloat32: { 434 case IrOpcode::kTruncateFloat64ToFloat32: {
431 Float64Matcher m(node->InputAt(0)); 435 Float64Matcher m(node->InputAt(0));
432 if (m.HasValue()) return ReplaceFloat32(DoubleToFloat32(m.Value())); 436 if (m.HasValue()) return ReplaceFloat32(DoubleToFloat32(m.Value()));
433 if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0)); 437 if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0));
434 break; 438 break;
435 } 439 }
440 case IrOpcode::kRoundFloat64ToInt32: {
441 Float64Matcher m(node->InputAt(0));
442 if (m.HasValue()) return ReplaceInt32(static_cast<int32_t>(m.Value()));
443 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
444 break;
445 }
436 case IrOpcode::kFloat64InsertLowWord32: 446 case IrOpcode::kFloat64InsertLowWord32:
437 return ReduceFloat64InsertLowWord32(node); 447 return ReduceFloat64InsertLowWord32(node);
438 case IrOpcode::kFloat64InsertHighWord32: 448 case IrOpcode::kFloat64InsertHighWord32:
439 return ReduceFloat64InsertHighWord32(node); 449 return ReduceFloat64InsertHighWord32(node);
440 case IrOpcode::kStore: 450 case IrOpcode::kStore:
441 return ReduceStore(node); 451 return ReduceStore(node);
442 case IrOpcode::kFloat64Equal: 452 case IrOpcode::kFloat64Equal:
443 case IrOpcode::kFloat64LessThan: 453 case IrOpcode::kFloat64LessThan:
444 case IrOpcode::kFloat64LessThanOrEqual: 454 case IrOpcode::kFloat64LessThanOrEqual:
445 return ReduceFloat64Compare(node); 455 return ReduceFloat64Compare(node);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 node->ReplaceInput(1, Int32Mul(quotient, Uint32Constant(divisor))); 648 node->ReplaceInput(1, Int32Mul(quotient, Uint32Constant(divisor)));
639 node->TrimInputCount(2); 649 node->TrimInputCount(2);
640 NodeProperties::ChangeOp(node, machine()->Int32Sub()); 650 NodeProperties::ChangeOp(node, machine()->Int32Sub());
641 } 651 }
642 return Changed(node); 652 return Changed(node);
643 } 653 }
644 return NoChange(); 654 return NoChange();
645 } 655 }
646 656
647 657
648 Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) {
649 Float64Matcher m(node->InputAt(0));
650 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
651 if (m.IsChangeInt32ToFloat64()) return Replace(m.node()->InputAt(0));
652 if (m.IsPhi()) {
653 Node* const phi = m.node();
654 DCHECK_EQ(MachineRepresentation::kFloat64, PhiRepresentationOf(phi->op()));
655 if (phi->OwnedBy(node)) {
656 // TruncateFloat64ToInt32[mode](Phi[Float64](x1,...,xn))
657 // => Phi[Int32](TruncateFloat64ToInt32[mode](x1),
658 // ...,
659 // TruncateFloat64ToInt32[mode](xn))
660 const int value_input_count = phi->InputCount() - 1;
661 for (int i = 0; i < value_input_count; ++i) {
662 Node* input = graph()->NewNode(node->op(), phi->InputAt(i));
663 // TODO(bmeurer): Reschedule input for reduction once we have Revisit()
664 // instead of recursing into ReduceTruncateFloat64ToInt32() here.
665 Reduction reduction = ReduceTruncateFloat64ToInt32(input);
666 if (reduction.Changed()) input = reduction.replacement();
667 phi->ReplaceInput(i, input);
668 }
669 NodeProperties::ChangeOp(
670 phi,
671 common()->Phi(MachineRepresentation::kWord32, value_input_count));
672 return Replace(phi);
673 }
674 }
675 return NoChange();
676 }
677
678
679 Reduction MachineOperatorReducer::ReduceStore(Node* node) { 658 Reduction MachineOperatorReducer::ReduceStore(Node* node) {
680 MachineRepresentation const rep = 659 MachineRepresentation const rep =
681 StoreRepresentationOf(node->op()).representation(); 660 StoreRepresentationOf(node->op()).representation();
682 Node* const value = node->InputAt(2); 661 Node* const value = node->InputAt(2);
683 switch (value->opcode()) { 662 switch (value->opcode()) {
684 case IrOpcode::kWord32And: { 663 case IrOpcode::kWord32And: {
685 Uint32BinopMatcher m(value); 664 Uint32BinopMatcher m(value);
686 if (m.right().HasValue() && ((rep == MachineRepresentation::kWord8 && 665 if (m.right().HasValue() && ((rep == MachineRepresentation::kWord8 &&
687 (m.right().Value() & 0xff) == 0xff) || 666 (m.right().Value() & 0xff) == 0xff) ||
688 (rep == MachineRepresentation::kWord16 && 667 (rep == MachineRepresentation::kWord16 &&
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 1061 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
1083 return jsgraph()->machine(); 1062 return jsgraph()->machine();
1084 } 1063 }
1085 1064
1086 1065
1087 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 1066 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
1088 1067
1089 } // namespace compiler 1068 } // namespace compiler
1090 } // namespace internal 1069 } // namespace internal
1091 } // namespace v8 1070 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698