OLD | NEW |
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/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/graph-inl.h" | 10 #include "src/compiler/graph-inl.h" |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 case IrOpcode::kNumberMultiply: | 495 case IrOpcode::kNumberMultiply: |
496 case IrOpcode::kNumberDivide: | 496 case IrOpcode::kNumberDivide: |
497 case IrOpcode::kNumberModulus: { | 497 case IrOpcode::kNumberModulus: { |
498 // Float64Mul/Div/Mod | 498 // Float64Mul/Div/Mod |
499 VisitFloat64Binop(node); | 499 VisitFloat64Binop(node); |
500 if (lower()) node->set_op(Float64Op(node)); | 500 if (lower()) node->set_op(Float64Op(node)); |
501 break; | 501 break; |
502 } | 502 } |
503 case IrOpcode::kNumberToInt32: { | 503 case IrOpcode::kNumberToInt32: { |
504 MachineTypeUnion use_rep = use & kRepMask; | 504 MachineTypeUnion use_rep = use & kRepMask; |
505 if (lower()) { | 505 Node* input = node->InputAt(0); |
506 MachineTypeUnion in = GetInfo(node->InputAt(0))->output; | 506 MachineTypeUnion in = GetInfo(input)->output; |
507 if ((in & kTypeMask) == kTypeInt32 || (in & kRepMask) == kRepWord32) { | 507 if (NodeProperties::GetBounds(input).upper->Is(Type::Signed32()) || |
508 // If the input has type int32, or is already a word32, just change | 508 (in & kTypeMask) == kTypeInt32 || (in & kRepMask) == kRepWord32) { |
509 // representation if necessary. | 509 // If the input has type int32, or is already a word32, just change |
510 VisitUnop(node, kTypeInt32 | use_rep, kTypeInt32 | use_rep); | 510 // representation if necessary. |
511 DeferReplacement(node, node->InputAt(0)); | 511 VisitUnop(node, kTypeInt32 | use_rep, kTypeInt32 | use_rep); |
512 } else { | 512 if (lower()) DeferReplacement(node, node->InputAt(0)); |
513 // Require the input in float64 format and perform truncation. | 513 } else { |
514 // TODO(turbofan): avoid a truncation with a smi check. | 514 // Require the input in float64 format and perform truncation. |
515 VisitUnop(node, kTypeInt32 | kRepFloat64, kTypeInt32 | kRepWord32); | 515 // TODO(turbofan): avoid a truncation with a smi check. |
| 516 VisitUnop(node, kTypeInt32 | kRepFloat64, kTypeInt32 | kRepWord32); |
| 517 if (lower()) |
516 node->set_op(lowering->machine()->TruncateFloat64ToInt32()); | 518 node->set_op(lowering->machine()->TruncateFloat64ToInt32()); |
517 } | |
518 } else { | |
519 // Propagate a type to the input, but pass through representation. | |
520 VisitUnop(node, kTypeInt32, kTypeInt32 | use_rep); | |
521 } | 519 } |
522 break; | 520 break; |
523 } | 521 } |
524 case IrOpcode::kNumberToUint32: { | 522 case IrOpcode::kNumberToUint32: { |
525 MachineTypeUnion use_rep = use & kRepMask; | 523 MachineTypeUnion use_rep = use & kRepMask; |
526 if (lower()) { | 524 Node* input = node->InputAt(0); |
527 MachineTypeUnion in = GetInfo(node->InputAt(0))->output; | 525 MachineTypeUnion in = GetInfo(input)->output; |
528 if ((in & kTypeMask) == kTypeUint32 || | 526 if (NodeProperties::GetBounds(input).upper->Is(Type::Unsigned32()) || |
529 (in & kRepMask) == kRepWord32) { | 527 (in & kTypeMask) == kTypeUint32) { |
530 // The input has type int32, just change representation. | 528 // If the input has type uint32, just change representation. |
531 VisitUnop(node, kTypeUint32 | use_rep, kTypeUint32 | use_rep); | 529 VisitUnop(node, kTypeUint32 | use_rep, kTypeUint32 | use_rep); |
532 DeferReplacement(node, node->InputAt(0)); | 530 if (lower()) DeferReplacement(node, node->InputAt(0)); |
533 } else { | 531 } else { |
534 // Require the input in float64 format to perform truncation. | 532 // Require the input in float64 format and perform truncation. |
535 // TODO(turbofan): avoid the truncation with a smi check. | 533 // TODO(turbofan): avoid a truncation with a smi check. |
536 VisitUnop(node, kTypeUint32 | kRepFloat64, | 534 VisitUnop(node, kTypeUint32 | kRepFloat64, kTypeUint32 | kRepWord32); |
537 kTypeUint32 | kRepWord32); | 535 if (lower()) |
538 node->set_op(lowering->machine()->TruncateFloat64ToInt32()); | 536 node->set_op(lowering->machine()->TruncateFloat64ToInt32()); |
539 } | |
540 } else { | |
541 // Propagate a type to the input, but pass through representation. | |
542 VisitUnop(node, kTypeUint32, kTypeUint32 | use_rep); | |
543 } | 537 } |
544 break; | 538 break; |
545 } | 539 } |
546 case IrOpcode::kReferenceEqual: { | 540 case IrOpcode::kReferenceEqual: { |
547 VisitBinop(node, kMachAnyTagged, kRepBit); | 541 VisitBinop(node, kMachAnyTagged, kRepBit); |
548 if (lower()) node->set_op(lowering->machine()->WordEqual()); | 542 if (lower()) node->set_op(lowering->machine()->WordEqual()); |
549 break; | 543 break; |
550 } | 544 } |
551 case IrOpcode::kStringEqual: { | 545 case IrOpcode::kStringEqual: { |
552 VisitBinop(node, kMachAnyTagged, kRepBit); | 546 VisitBinop(node, kMachAnyTagged, kRepBit); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 964 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
971 node->set_op(machine()->IntLessThanOrEqual()); | 965 node->set_op(machine()->IntLessThanOrEqual()); |
972 node->ReplaceInput(0, StringComparison(node, true)); | 966 node->ReplaceInput(0, StringComparison(node, true)); |
973 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 967 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
974 } | 968 } |
975 | 969 |
976 | 970 |
977 } // namespace compiler | 971 } // namespace compiler |
978 } // namespace internal | 972 } // namespace internal |
979 } // namespace v8 | 973 } // namespace v8 |
OLD | NEW |