Home | History | Annotate | Download | only in compiler

Lines Matching refs:Node

17 #include "src/compiler/node-matchers.h"
18 #include "src/compiler/node-properties.h"
47 // During this phase, the usage information for a node determines the best
162 void ReplaceEffectControlUses(Node* node, Node* effect, Node* control) {
163 for (Edge edge : node->use_edges()) {
175 void ChangeToPureOp(Node* node, const Operator* new_op) {
177 if (node->op()->EffectInputCount() > 0) {
178 DCHECK_LT(0, node->op()->ControlInputCount());
179 // Disconnect the node from effect and control chains.
180 Node* control = NodeProperties::GetControlInput(node);
181 Node* effect = NodeProperties::GetEffectInput(node);
182 ReplaceEffectControlUses(node, effect, control);
183 node->TrimInputCount(new_op->ValueInputCount());
185 DCHECK_EQ(0, node->op()->ControlInputCount());
187 NodeProperties::ChangeOp(node, new_op);
196 void SetAndCheckInput(Node* node, int index, UseInfo use_info) {
198 input_use_infos_.resize(node->InputCount(), UseInfo::None());
243 // Information for each node tracked during the fixpoint.
246 // Adds new use to the node. Returns true if something has changed
247 // and the node has to be requeued.
322 while (current.input_index < current.node->InputCount()) {
323 Node* input = current.node->InputAt(current.input_index);
336 Node* node = current.node;
338 NodeInfo* info = GetInfo(node);
340 bool updated = UpdateFeedbackType(node);
341 TRACE(" visit #%d: %s\n", node->id(), node->op()->mnemonic());
342 VisitNode(node, info->truncation(), nullptr);
347 for (Node* const user : node->uses()) {
358 Node* node = queue_.front();
360 NodeInfo* info = GetInfo(node);
362 bool updated = UpdateFeedbackType(node);
363 TRACE(" visit #%d: %s\n", node->id(), node->op()->mnemonic());
364 VisitNode(node, info->truncation(), nullptr);
369 for (Node* const user : node->uses()) {
386 Type* TypeOf(Node* node) {
387 Type* type = GetInfo(node)->feedback_type();
388 return type == nullptr ? NodeProperties::GetType(node) : type;
391 Type* FeedbackTypeOf(Node* node) {
392 Type* type = GetInfo(node)->feedback_type();
396 Type* TypePhi(Node* node) {
397 int arity = node->op()->ValueInputCount();
398 Type* type = FeedbackTypeOf(node->InputAt(0));
400 type = op_typer_.Merge(type, FeedbackTypeOf(node->InputAt(i)));
405 Type* TypeSelect(Node* node) {
406 return op_typer_.Merge(FeedbackTypeOf(node->InputAt(1)),
407 FeedbackTypeOf(node->InputAt(2)));
410 bool UpdateFeedbackType(Node* node) {
411 if (node->op()->ValueOutputCount() == 0) return false;
413 NodeInfo* info = GetInfo(node);
417 // For any non-phi node just wait until we get all inputs typed. We only
420 if (node->opcode() != IrOpcode::kPhi) {
421 for (int i = 0; i < node->op()->ValueInputCount(); i++) {
422 if (GetInfo(node->InputAt(i))->feedback_type() == nullptr) {
428 switch (node->opcode()) {
431 new_type = op_typer_.Name(FeedbackTypeOf(node->InputAt(0)), \
432 FeedbackTypeOf(node->InputAt(1))); \
441 Type::Intersect(op_typer_.Name(FeedbackTypeOf(node->InputAt(0)), \
442 FeedbackTypeOf(node->InputAt(1))), \
451 new_type = op_typer_.Name(FeedbackTypeOf(node->InputAt(0))); \
458 new_type = op_typer_.ToNumber(FeedbackTypeOf(node->InputAt(0)));
462 new_type = TypePhi(node);
464 new_type = Weaken(node, type, new_type);
470 node->op(),
471 FeedbackTypeOf(node->InputAt(0)));
476 new_type = TypeSelect(node);
483 GetInfo(node)->set_feedback_type(NodeProperties::GetType(node));
492 new_type = Type::Intersect(GetUpperBound(node), new_type, graph_zone());
495 GetInfo(node)->set_feedback_type(new_type);
497 PrintNodeFeedbackType(node);
502 void PrintNodeFeedbackType(Node* n) {
506 for (Node* const i : n->inputs()) {
525 Type* Weaken(Node* node, Type* previous_type, Type* current_type) {
538 // Once we start weakening a node, we should always weaken.
539 if (!GetInfo(node)->weakened()) {
549 GetInfo(node)->set_weakened();
565 Node* node = queue_.front();
566 NodeInfo* info = GetInfo(node);
569 TRACE(" visit #%d: %s (trunc: %s)\n", node->id(), node->op()->mnemonic(),
571 VisitNode(node, info->truncation(), nullptr);
585 Node* node = *i;
586 NodeInfo* info = GetInfo(node);
587 TRACE(" visit #%d: %s\n", node->id(), node->op()->mnemonic());
590 source_positions_, source_positions_->GetSourcePosition(node));
591 VisitNode(node, info->truncation(), lowering);
597 Node* node = *i;
598 Node* replacement = *(++i);
599 node->ReplaceUses(replacement);
600 node->Kill();
601 // We also need to replace the node in the rest of the vector.
604 if (*j == node) *j = replacement;
609 void EnqueueInitial(Node* node) {
610 NodeInfo* info = GetInfo(node);
612 nodes_.push_back(node);
613 queue_.push(node);
617 // for that input node. Add the input to {nodes_} if this is the first time
619 void EnqueueInput(Node* use_node, int index,
621 Node* node = use_node->InputAt(index);
623 NodeInfo* info = GetInfo(node);
630 // First visit of this node.
632 nodes_.push_back(node);
633 queue_.push(node);
634 TRACE(" initial #%i: ", node->id());
639 TRACE(" queue #%i?: ", node->id());
642 // New usage information for the node is available.
644 queue_.push(node);
658 void SetOutput(Node* node, MachineRepresentation representation,
660 NodeInfo* const info = GetInfo(node);
678 Type* GetUpperBound(Node* node) { return NodeProperties::GetType(node); }
680 bool InputCannotBe(Node* node, Type* type) {
681 DCHECK_EQ(1, node->op()->ValueInputCount());
682 return !GetUpperBound(node->InputAt(0))->Maybe(type);
685 bool InputIs(Node* node, Type* type) {
686 DCHECK_EQ(1, node->op()->ValueInputCount());
687 return GetUpperBound(node->InputAt(0))->Is(type);
690 bool BothInputsAreSigned32(Node* node) {
691 return BothInputsAre(node, Type::Signed32());
694 bool BothInputsAreUnsigned32(Node* node) {
695 return BothInputsAre(node, Type::Unsigned32());
698 bool BothInputsAre(Node* node, Type* type) {
699 DCHECK_EQ(2, node->op()->ValueInputCount());
700 return GetUpperBound(node->InputAt(0))->Is(type) &&
701 GetUpperBound(node->InputAt(1))->Is(type);
704 bool IsNodeRepresentationTagged(Node* node) {
705 MachineRepresentation representation = GetInfo(node)->representation();
709 bool OneInputCannotBe(Node* node, Type* type) {
710 DCHECK_EQ(2, node->op()->ValueInputCount());
711 return !GetUpperBound(node->InputAt(0))->Maybe(type) ||
712 !GetUpperBound(node->InputAt(1))->Maybe(type);
715 void ConvertInput(Node* node, int index, UseInfo use) {
716 Node* input = node->InputAt(index);
726 TRACE(" change: #%d:%s(@%d #%d:%s) ", node->id(), node->op()->mnemonic(),
733 Node* n = changer_->GetRepresentationFor(
734 input, input_info->representation(), TypeOf(input), node, use);
735 node->ReplaceInput(index, n);
739 void ProcessInput(Node* node, int index, UseInfo use) {
742 EnqueueInput(node, index, use);
747 ConvertInput(node, index, use);
752 void ProcessRemainingInputs(Node* node, int index) {
753 DCHECK_GE(index, NodeProperties::PastValueIndex(node));
754 DCHECK_GE(index, NodeProperties::PastContextIndex(node));
755 for (int i = std::max(index, NodeProperties::FirstEffectIndex(node));
756 i < NodeProperties::PastEffectIndex(node); ++i) {
757 EnqueueInput(node, i); // Effect inputs: just visit
759 for (int i = std::max(index, NodeProperties::FirstControlIndex(node));
760 i < NodeProperties::PastControlIndex(node); ++i) {
761 EnqueueInput(node, i); // Control inputs: just visit
765 // The default, most general visitation case. For {node}, process all value,
769 void VisitInputs(Node* node) {
770 int tagged_count = node->op()->ValueInputCount() +
771 OperatorProperties::GetContextInputCount(node->op()) +
772 OperatorProperties::GetFrameStateInputCount(node->op());
775 ProcessInput(node, i, UseInfo::AnyTagged());
778 for (int i = tagged_count; i < node->InputCount(); i++) {
779 EnqueueInput(node, i);
783 void VisitReturn(Node* node) {
784 int tagged_limit = node->op()->ValueInputCount() +
785 OperatorProperties::GetContextInputCount(node->op()) +
786 OperatorProperties::GetFrameStateInputCount(node->op());
788 ProcessInput(node, 0, UseInfo::TruncatingWord32());
792 ProcessInput(node, i, UseInfo::AnyTagged());
795 for (int i = tagged_limit; i < node->InputCount(); i++) {
796 EnqueueInput(node, i);
800 // Helper for an unused node.
801 void VisitUnused(Node* node) {
802 int value_count = node->op()->ValueInputCount() +
803 OperatorProperties::GetContextInputCount(node->op()) +
804 OperatorProperties::GetFrameStateInputCount(node->op());
806 ProcessInput(node, i, UseInfo::None());
808 ProcessRemainingInputs(node, value_count);
809 if (lower()) Kill(node);
813 void VisitBinop(Node* node, UseInfo left_use, UseInfo right_use,
816 DCHECK_EQ(2, node->op()->ValueInputCount());
817 ProcessInput(node, 0, left_use);
818 ProcessInput(node, 1, right_use);
819 for (int i = 2; i < node->InputCount(); i++) {
820 EnqueueInput(node, i);
822 SetOutput(node, output, restriction_type);
826 void VisitBinop(Node* node, UseInfo input_use, MachineRepresentation output,
828 VisitBinop(node, input_use, input_use, output, restriction_type);
831 void VisitSpeculativeInt32Binop(Node* node) {
832 DCHECK_EQ(2, node->op()->ValueInputCount());
833 if (BothInputsAre(node, Type::NumberOrOddball())) {
834 return VisitBinop(node, UseInfo::TruncatingWord32(),
837 NumberOperationHint hint = NumberOperationHintOf(node->op());
838 return VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
843 void VisitUnop(Node* node, UseInfo input_use, MachineRepresentation output) {
844 DCHECK_EQ(1, node->op()->ValueInputCount());
845 ProcessInput(node, 0, input_use);
846 ProcessRemainingInputs(node, 1);
847 SetOutput(node, output);
851 void VisitLeaf(Node* node, MachineRepresentation output) {
852 DCHECK_EQ(0, node->InputCount());
853 SetOutput(node, output);
857 void VisitFloat64Binop(Node* node) {
858 VisitBinop(node, UseInfo::TruncatingFloat64(),
861 void VisitWord32TruncatingBinop(Node* node) {
862 VisitBinop(node, UseInfo::TruncatingWord32(),
867 // The {node} parameter is only used to decide on the int64 representation.
868 // Once the type system supports an external pointer type, the {node}
870 MachineRepresentation GetOutputInfoForPhi(Node* node, Type* type,
899 void VisitSelect(Node* node, Truncation truncation,
901 DCHECK(TypeOf(node->InputAt(0))->Is(Type::Boolean()));
902 ProcessInput(node, 0, UseInfo::Bool());
905 GetOutputInfoForPhi(node, TypeOf(node), truncation);
906 SetOutput(node, output);
910 SelectParameters p = SelectParametersOf(node->op());
912 NodeProperties::ChangeOp(node,
919 ProcessInput(node, 1, input_use);
920 ProcessInput(node, 2, input_use);
924 void VisitPhi(Node* node, Truncation truncation,
927 GetOutputInfoForPhi(node, TypeOf(node), truncation);
930 SetOutput(node, output);
932 int values = node->op()->ValueInputCount();
935 if (output != PhiRepresentationOf(node->op())) {
936 NodeProperties::ChangeOp(node, lowering->common()->Phi(output, values));
943 for (int i = 0; i < node->InputCount(); i++) {
944 ProcessInput(node, i, i < values ? input_use : UseInfo::None());
948 void VisitObjectIs(Node* node, Type* type, SimplifiedLowering* lowering) {
949 Type* const input_type = TypeOf(node->InputAt(0));
951 VisitUnop(node, UseInfo::None(), MachineRepresentation::kBit);
953 DeferReplacement(node, lowering->jsgraph()->Int32Constant(1));
956 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit);
958 DeferReplacement(node, lowering->jsgraph()->Int32Constant(0));
963 void VisitCall(Node* node, SimplifiedLowering* lowering) {
964 const CallDescriptor* desc = CallDescriptorOf(node->op());
966 int value_input_count = node->op()->ValueInputCount();
971 ProcessInput(node, i, UseInfo::Any());
973 ProcessInput(node, i, TruncatingUseInfoFromRepresentation(
976 ProcessInput(node, i, UseInfo::AnyTagged());
979 ProcessRemainingInputs(node, value_input_count);
982 SetOutput(node, desc->GetReturnType(0).representation());
984 SetOutput(node, MachineRepresentation::kTagged);
1022 void VisitStateValues(Node* node) {
1024 for (int i = 0; i < node->InputCount(); i++) {
1025 EnqueueInput(node, i, UseInfo::Any());
1031 ZoneVector<MachineType>(node->InputCount(), zone);
1032 for (int i = 0; i < node->InputCount(); i++) {
1033 Node* input = node->InputAt(i);
1037 SparseInputMask mask = SparseInputMaskOf(node->op());
1039 node, jsgraph_->common()->TypedStateValues(types, mask));
1041 SetOutput(node, MachineRepresentation::kTagged);
1044 void VisitObjectState(Node* node) {
1046 for (int i = 0; i < node->InputCount(); i++) {
1047 Node* input = node->InputAt(i);
1060 EnqueueInput(node, i, use_info);
1066 ZoneVector<MachineType>(node->InputCount(), zone);
1067 for (int i = 0; i < node->InputCount(); i++) {
1068 Node* input = node->InputAt(i);
1072 NodeProperties::ChangeOp(node,
1075 SetOutput(node, MachineRepresentation::kTagged);
1078 const Operator* Int32Op(Node* node) {
1079 return changer_->Int32OperatorFor(node->opcode());
1082 const Operator* Int32OverflowOp(Node* node) {
1083 return changer_->Int32OverflowOperatorFor(node->opcode());
1086 const Operator* Uint32Op(Node* node) {
1087 return changer_->Uint32OperatorFor(node->opcode());
1090 const Operator* Uint32OverflowOp(Node* node) {
1091 return changer_->Uint32OverflowOperatorFor(node->opcode());
1094 const Operator* Float64Op(Node* node) {
1095 return changer_->Float64OperatorFor(node->opcode());
1101 MachineRepresentation value_representation, Node* value) {
1150 Node* value) {
1165 void LowerToCheckedInt32Mul(Node* node, Truncation truncation,
1178 NodeProperties::ChangeOp(node, simplified()->CheckedInt32Mul(mz_mode));
1181 void ChangeToInt32OverflowOp(Node* node) {
1182 NodeProperties::ChangeOp(node, Int32OverflowOp(node));
1185 void ChangeToUint32OverflowOp(Node* node) {
1186 NodeProperties::ChangeOp(node, Uint32OverflowOp(node));
1189 void VisitSpeculativeAdditiveOp(Node* node, Truncation truncation,
1198 if (BothInputsAre(node, Type::NumberOrOddball())) {
1199 if (truncation.IsUnused()) return VisitUnused(node);
1202 if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
1203 (GetUpperBound(node)->Is(Type::Signed32()) ||
1204 GetUpperBound(node)->Is(Type::Unsigned32()) ||
1207 VisitWord32TruncatingBinop(node);
1208 if (lower()) ChangeToPureOp(node, Int32Op(node));
1213 NumberOperationHint hint = NumberOperationHintOf(node->op());
1217 Type* left_feedback_type = TypeOf(node->InputAt(0));
1218 Type* right_feedback_type = TypeOf(node->InputAt(1));
1223 if (BothInputsAre(node, Type::Signed32()) ||
1224 (BothInputsAre(node, Type::Signed32OrMinusZero()) &&
1225 GetUpperBound(node)->Is(type_cache_.kSafeInteger))) {
1226 VisitBinop(node, UseInfo::TruncatingWord32(),
1236 VisitBinop(node, left_use, right_use, MachineRepresentation::kWord32,
1240 if (CanOverflowSigned32(node->op(), left_feedback_type,
1242 ChangeToInt32OverflowOp(node);
1244 ChangeToPureOp(node, Int32Op(node));
1251 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1254 ChangeToPureOp(node, Float64Op(node));
1259 void VisitSpeculativeNumberModulus(Node* node, Truncation truncation,
1265 if (BothInputsAre(node, Type::PlainPrimitive())) {
1266 if (truncation.IsUnused()) return VisitUnused(node);
1268 if (BothInputsAre(node, Type::Unsigned32OrMinusZeroOrNaN()) &&
1270 NodeProperties::GetType(node)->Is(Type::Unsigned32()))) {
1272 VisitWord32TruncatingBinop(node);
1273 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
1276 if (BothInputsAre(node, Type::Signed32OrMinusZeroOrNaN()) &&
1278 NodeProperties::GetType(node)->Is(Type::Signed32()))) {
1280 VisitWord32TruncatingBinop(node);
1281 if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
1286 NumberOperationHint hint = NumberOperationHintOf(node->op());
1290 if (BothInputsAreUnsigned32(node)) {
1293 VisitBinop(node, UseInfo::TruncatingWord32(),
1295 if (lower()) ChangeToUint32OverflowOp(node);
1302 if (BothInputsAre(node, Type::Signed32())) {
1306 VisitBinop(node, UseInfo::TruncatingWord32(),
1308 if (lower()) ChangeToInt32OverflowOp(node);
1317 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1319 if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
1320 } else if (BothInputsAre(node
1321 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1323 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
1325 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1327 if (lower()) ChangeToInt32OverflowOp(node);
1332 if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) &&
1333 TypeOf(node->InputAt(1))->Is(Type::Unsigned32()) &&
1335 NodeProperties::GetType(node)->Is(Type::Unsigned32()))) {
1338 VisitBinop(node,
1341 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
1344 if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) &&
1345 TypeOf(node->InputAt(1))->Is(Type::Signed32()) &&
1347 NodeProperties::GetType(node)->Is(Type::Signed32()))) {
1350 VisitBinop(node,
1353 if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
1357 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1359 if (lower()) ChangeToPureOp(node, Float64Op(node));
1363 void VisitOsrGuard(Node* node) {
1364 VisitInputs(node);
1367 switch (OsrGuardTypeOf(node->op())) {
1374 NodeProperties::ChangeOp(node,
1377 return SetOutput(node, MachineRepresentation::kTaggedSigned);
1380 DeferReplacement(node, node->InputAt(0));
1382 return SetOutput(node, MachineRepresentation::kTagged);
1387 // Dispatching routine for visiting the node {node} with the usage {use}.
1389 void VisitNode(Node* node, Truncation truncation,
1395 // would thus kill the cached {node} during lowering (i.e. replace all
1396 // uses with Dead), but at that point some node lowering might have
1397 // already taken the constant {node} from the cache (while it was in
1400 if (node->op()->ValueInputCount() > 0 &&
1401 node->op()->HasProperty(Operator::kPure)) {
1402 if (truncation.IsUnused()) return VisitUnused(node);
1404 switch (node->opcode()) {
1412 return VisitLeaf(node, MachineRepresentation::kTagged);
1415 return VisitUnop(node, UseInfo::None(), MachineRepresentation::kTagged);
1417 return VisitLeaf(node, MachineRepresentation::kWord32);
1419 return VisitLeaf(node, MachineRepresentation::kWord64);
1421 return VisitLeaf(node, MachineType::PointerRepresentation());
1423 return VisitLeaf(node, MachineRepresentation::kTagged);
1425 return VisitLeaf(node, MachineRepresentation::kTaggedPointer);
1427 VisitLeaf(node, MachineType::PointerRepresentation());
1429 intptr_t const value = OpParameter<intptr_t>(node);
1430 DeferReplacement(node, lowering->jsgraph()->IntPtrConstant(value));
1436 DCHECK(TypeOf(node->InputAt(0))->Is(Type::Boolean()));
1437 ProcessInput(node, 0, UseInfo::Bool());
1438 EnqueueInput(node, NodeProperties::FirstControlIndex(node));
1442 ProcessInput(node, 0, UseInfo::TruncatingWord32());
1443 EnqueueInput(node, NodeProperties::FirstControlIndex(node));
1446 return VisitSelect(node, truncation, lowering);
1448 return VisitPhi(node, truncation, lowering);
1450 return VisitCall(node, lowering);
1457 ProcessInput(node, 0, UseInfo::Bool());
1458 ProcessInput(node, 1, UseInfo::None());
1459 SetOutput(node, MachineRepresentation::kBit);
1460 if (lower()) DeferReplacement(node, node->InputAt(0));
1462 VisitInputs(node);
1463 SetOutput(node, MachineRepresentation::kTaggedPointer);
1468 VisitInputs(node);
1471 SetOutput(node, MachineRepresentation::kWord32);
1472 if (lower()) lowering->DoJSToNumberTruncatesToWord32(node, this);
1474 SetOutput(node, MachineRepresentation::kFloat64);
1475 if (lower()) lowering->DoJSToNumberTruncatesToFloat64(node, this);
1477 SetOutput(node, MachineRepresentation::kTagged);
1487 NodeInfo* input_info = GetInfo(node->InputAt(0));
1490 node->AppendInput(jsgraph_->zone(), jsgraph_->Int32Constant(0));
1491 NodeProperties::ChangeOp(node, lowering->machine()->Word32Equal());
1495 node->AppendInput(jsgraph_->zone(), jsgraph_->FalseConstant());
1496 NodeProperties::ChangeOp(node, lowering->machine()->WordEqual());
1500 ProcessInput(node, 0, UseInfo::AnyTruncatingToBool());
1501 SetOutput(node, MachineRepresentation::kBit);
1506 Type* const lhs_type = TypeOf(node->InputAt(0));
1507 Type* const rhs_type = TypeOf(node->InputAt(1));
1513 OneInputCannotBe(node, type_cache_.kZeroish))) {
1515 VisitBinop(node, UseInfo::TruncatingWord32(),
1517 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node));
1524 OneInputCannotBe(node, type_cache_.kZeroish))) {
1526 VisitBinop(node, UseInfo::TruncatingWord32(),
1528 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
1532 VisitBinop(node, UseInfo::TruncatingFloat64(),
1534 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
1540 if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) &&
1541 TypeOf(node->InputAt(1))->Is(Type::Unsigned32())) {
1543 VisitBinop(node, UseInfo::TruncatingWord32(),
1545 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node));
1546 } else if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) &&
1547 TypeOf(node->InputAt(1))->Is(Type::Signed32())) {
1549 VisitBinop(node, UseInfo::TruncatingWord32(),
1551 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
1554 VisitBinop(node, UseInfo::TruncatingFloat64(),
1556 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
1563 return VisitSpeculativeAdditiveOp(node, truncation, lowering);
1572 if (BothInputsAre(node, Type::PlainPrimitive())) {
1573 if (truncation.IsUnused()) return VisitUnused(node);
1576 if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) &&
1577 TypeOf(node->InputAt(1))->Is(Type::Unsigned32())) {
1579 VisitBinop(node, UseInfo::TruncatingWord32(),
1581 if (lower()) ChangeToPureOp(node, Uint32Op(node));
1583 } else if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) &&
1584 TypeOf(node->InputAt(1))->Is(Type::Signed32())) {
1586 VisitBinop(node, UseInfo::TruncatingWord32(),
1588 if (lower()) ChangeToPureOp(node, Int32Op(node));
1592 NumberOperationHint hint = NumberOperationHintOf(node->op());
1597 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1600 SetOutput(node, MachineRepresentation::kBit, Type::Any());
1603 Node* lhs = node->InputAt(0);
1604 Node* rhs = node->InputAt(1);
1607 VisitBinop(node, UseInfo::CheckedSignedSmallAsTaggedSigned(),
1610 node, changer_->TaggedSignedOperatorFor(node->opcode()));
1613 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1615 ChangeToPureOp(node, Int32Op(node));
1624 DCHECK_NE(IrOpcode::kSpeculativeNumberEqual, node->opcode());
1627 VisitBinop(node, CheckedUseInfoAsFloat64FromHint(hint),
1629 if (lower()) ChangeToPureOp(node, Float64Op(node));
1638 if (BothInputsAre(node, type_cache_.kAdditiveSafeIntegerOrMinusZero) &&
1639 (GetUpperBound(node)->Is(Type::Signed32()) ||
1640 GetUpperBound(node)->Is(Type::Unsigned32()) ||
1643 VisitWord32TruncatingBinop(node);
1644 if (lower()) ChangeToPureOp(node, Int32Op(node));
1647 VisitFloat64Binop(node);
1648 if (lower()) ChangeToPureOp(node, Float64Op(node));
1657 if (BothInputsAre(node, Type::PlainPrimitive())) {
1658 if (truncation.IsUnused()) return VisitUnused(node);
1660 if (BothInputsAre(node, Type::Integral32()) &&
1661 (NodeProperties::GetType(node)->Is(Type::Signed32()) ||
1662 NodeProperties::GetType(node)->Is(Type::Unsigned32()) ||
1664 NodeProperties::GetType(node)->Is(
1671 VisitWord32TruncatingBinop(node);
1672 if (lower()) ChangeToPureOp(node, Int32Op(node));
1676 NumberOperationHint hint = NumberOperationHintOf(node->op());
1677 Type* input0_type = TypeOf(node
1678 Type* input1_type = TypeOf(node->InputAt(1));
1682 if (BothInputsAre(node, Type::Signed32())) {
1686 VisitBinop(node, UseInfo::TruncatingWord32(),
1689 LowerToCheckedInt32Mul(node, truncation, input0_type,
1698 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1701 LowerToCheckedInt32Mul(node, truncation, input0_type, input1_type);
1707 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1709 if (lower()) ChangeToPureOp(node, Float64Op(node));
1713 if (BothInputsAre(node, Type::Integral32()) &&
1714 (NodeProperties::GetType(node)->Is(Type::Signed32()) ||
1715 NodeProperties::GetType(node)->Is(Type::Unsigned32()) ||
1717 NodeProperties::GetType(node)->Is(
1724 VisitWord32TruncatingBinop(node);
1725 if (lower()) ChangeToPureOp(node, Int32Op(node));
1729 VisitFloat64Binop(node);
1730 if (lower()) ChangeToPureOp(node, Float64Op(node));
1738 if (BothInputsAre(node, Type::PlainPrimitive())) {
1739 if (truncation.IsUnused()) return VisitUnused(node);
1741 if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) {
1743 VisitWord32TruncatingBinop(node);
1744 if (lower()) DeferReplacement(node, lowering->Uint32Div(node));
1747 if (BothInputsAreSigned32(node)) {
1748 if (NodeProperties::GetType(node)->Is(Type::Signed32())) {
1750 VisitWord32TruncatingBinop(node);
1751 if (lower()) DeferReplacement(node, lowering->Int32Div(node));
1756 VisitWord32TruncatingBinop(node);
1757 if (lower()) DeferReplacement(node, lowering->Int32Div(node));
1763 NumberOperationHint hint = NumberOperationHintOf(node->op());
1767 if (BothInputsAreUnsigned32(node)) {
1770 VisitBinop(node, UseInfo::TruncatingWord32(),
1772 if (lower()) ChangeToUint32OverflowOp(node);
1779 if (BothInputsAreSigned32(node)) {
1783 VisitBinop(node, UseInfo::TruncatingWord32(),
1785 if (lower()) ChangeToInt32OverflowOp(node);
1794 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1796 if (lower()) DeferReplacement(node, lowering->Int32Div(node));
1798 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1800 if (lower()) ChangeToInt32OverflowOp(node);
1806 VisitBinop(node, UseInfo::CheckedNumberOrOddballAsFloat64(),
1808 if (lower()) ChangeToPureOp(node, Float64Op(node));
1812 if (BothInputsAreUnsigned32(node) && truncation.IsUsedAsWord32()) {
1814 VisitWord32TruncatingBinop(node);
1815 if (lower()) DeferReplacement(node, lowering->Uint32Div(node));
1818 if (BothInputsAreSigned32(node)) {
1819 if (NodeProperties::GetType(node)->Is(Type::Signed32())) {
1821 VisitWord32TruncatingBinop(node);
1822 if (lower()) DeferReplacement(node, lowering->Int32Div(node));
1827 VisitWord32TruncatingBinop(node);
1828 if (lower()) DeferReplacement(node, lowering->Int32Div(node));
1833 VisitFloat64Binop(node);
1834 if (lower()) ChangeToPureOp(node, Float64Op(node));
1838 return VisitSpeculativeNumberModulus(node, truncation, lowering);
1840 if (BothInputsAre(node, Type::Unsigned32OrMinusZeroOrNaN()) &&
1842 NodeProperties::GetType(node)->Is(Type::Unsigned32()))) {
1844 VisitWord32TruncatingBinop(node);
1845 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
1848 if (BothInputsAre(node, Type::Signed32OrMinusZeroOrNaN()) &&
1850 NodeProperties::GetType(node)->Is(Type::Signed32()))) {
1852 VisitWord32TruncatingBinop(node);
1853 if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
1856 if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32()) &&
1857 TypeOf(node->InputAt(1))->Is(Type::Unsigned32()) &&
1859 NodeProperties::GetType(node)->Is(Type::Unsigned32()))) {
1862 VisitBinop(node, UseInfo(MachineRepresentation::kWord32,
1865 if (lower()) DeferReplacement(node, lowering->Uint32Mod(node));
1868 if (TypeOf(node->InputAt(0))->Is(Type::Signed32()) &&
1869 TypeOf(node->InputAt(1))->Is(Type::Signed32()) &&
1871 NodeProperties::GetType(node)->Is(Type::Signed32()))) {
1874 VisitBinop(node, UseInfo(MachineRepresentation::kWord32,
1877 if (lower()) DeferReplacement(node, lowering->Int32Mod(node));
1881 VisitFloat64Binop(node);
1882 if (lower()) ChangeToPureOp(node, Float64Op(node));
1888 VisitWord32TruncatingBinop(node);
1889 if (lower()) NodeProperties::ChangeOp(node, Int32Op(node));
1895 VisitSpeculativeInt32Binop(node);
1897 ChangeToPureOp(node, Int32Op(node));
1901 Type* rhs_type = GetUpperBound(node->InputAt(1));
1902 VisitBinop(node, UseInfo::TruncatingWord32(),
1905 lowering->DoShift(node, lowering->machine()->Word32Shl(), rhs_type);
1914 if (BothInputsAre(node, Type::PlainPrimitive())) {
1915 if (truncation.IsUnused()) return VisitUnused(node);
1917 if (BothInputsAre(node, Type::NumberOrOddball())) {
1918 Type* rhs_type = GetUpperBound(node->InputAt(1));
1919 VisitBinop(node, UseInfo::TruncatingWord32(),
1923 lowering->DoShift(node, lowering->machine()->Word32Shl(), rhs_type);
1927 NumberOperationHint hint = NumberOperationHintOf(node->op());
1928 Type* rhs_type = GetUpperBound(node->InputAt(1));
1929 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1932 lowering->DoShift(node, lowering->machine()->Word32Shl(), rhs_type);
1937 Type* rhs_type = GetUpperBound(node->InputAt(1));
1938 VisitBinop(node, UseInfo::TruncatingWord32(),
1941 lowering->DoShift(node, lowering->machine()->Word32Sar(), rhs_type);
1950 if (BothInputsAre(node, Type::PlainPrimitive())) {
1951 if (truncation.IsUnused()) return VisitUnused(node);
1953 if (BothInputsAre(node, Type::NumberOrOddball())) {
1954 Type* rhs_type = GetUpperBound(node->InputAt(1));
1955 VisitBinop(node, UseInfo::TruncatingWord32(),
1959 lowering->DoShift(node, lowering->machine()->Word32Sar(), rhs_type);
1963 NumberOperationHint hint = NumberOperationHintOf(node->op());
1964 Type* rhs_type = GetUpperBound(node->InputAt(1));
1965 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
1968 lowering->DoShift(node, lowering->machine()->Word32Sar(), rhs_type);
1973 Type* rhs_type = GetUpperBound(node->InputAt(1));
1974 VisitBinop(node, UseInfo::TruncatingWord32(),
1977 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type);
1986 if (BothInputsAre(node, Type::PlainPrimitive())) {
1987 if (truncation.IsUnused()) return VisitUnused(node);
1989 NumberOperationHint hint = NumberOperationHintOf(node->op());
1990 Type* rhs_type = GetUpperBound(node->InputAt(1));
1999 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
2002 node->RemoveInput(1);
2003 NodeProperties::ChangeOp(node,
2008 if (BothInputsAre(node, Type::NumberOrOddball())) {
2009 VisitBinop(node, UseInfo::TruncatingWord32(),
2013 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type);
2017 VisitBinop(node, CheckedUseInfoAsWord32FromHint(hint),
2020 lowering->DoShift(node, lowering->machine()->Word32Shr(), rhs_type);
2025 if (TypeOf(node->InputAt(0))->Is(Type::Unsigned32())) {
2026 VisitUnop(node, UseInfo::TruncatingWord32(),
2028 if (lower()) DeferReplacement(node, node->InputAt(0));
2029 } else if (TypeOf(node->InputAt(0))->Is(Type::Signed32())) {
2030 VisitUnop(node, UseInfo::TruncatingWord32(),
2032 if (lower()) DeferReplacement(node, lowering->Int32Abs(node));
2033 } else if (TypeOf(node->InputAt(0))
2035 VisitUnop(node, UseInfo::TruncatingFloat64(),
2037 if (lower()) DeferReplacement(node, node->InputAt(0));
2039 VisitUnop(node, UseInfo::TruncatingFloat64(),
2041 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
2046 VisitUnop(node, UseInfo::TruncatingWord32(),
2048 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node));
2052 VisitBinop(node, UseInfo::TruncatingWord32(),
2054 if (lower()) NodeProperties::ChangeOp(node, Uint32Op(node));
2058 VisitUnop(node, UseInfo::TruncatingFloat64(),
2060 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
2065 if (BothInputsAreUnsigned32(node)) {
2066 VisitWord32TruncatingBinop(node);
2068 lowering->DoMax(node, lowering->machine()->Uint32LessThan(),
2071 } else if (BothInputsAreSigned32(node)) {
2072 VisitWord32TruncatingBinop(node);
2074 lowering->DoMax(node, lowering->machine()->Int32LessThan(),
2077 } else if (BothInputsAre(node, Type::PlainNumber())) {
2078 VisitFloat64Binop(node);
2080 lowering->DoMax(node, lowering->machine()->Float64LessThan(),
2084 VisitFloat64Binop(node);
2085 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
2091 if (BothInputsAreUnsigned32(node)) {
2092 VisitWord32TruncatingBinop(node);
2094 lowering->DoMin(node, lowering->machine()->Uint32LessThan(),
2097 } else if (BothInputsAreSigned32(node)) {
2098 VisitWord32TruncatingBinop(node);
2100 lowering->DoMin(node, lowering->machine()->Int32LessThan(),
2103 } else if (BothInputsAre(node, Type::PlainNumber())) {
2104 VisitFloat64Binop(node);
2106 lowering->DoMin(node, lowering->machine()->Float64LessThan(),
2110 VisitFloat64Binop(node);
2111 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
2117 VisitBinop(node, UseInfo::TruncatingFloat64(),
2119 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
2144 VisitUnop(node, UseInfo::TruncatingFloat64(),
2146 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
2150 VisitUnop(node, UseInfo::TruncatingFloat64(),
2152 if (lower()) DeferReplacement(node, lowering->Float64Round(node));
2156 if (InputIs(node, Type::Signed32())) {
2157 VisitUnop(node, UseInfo::TruncatingWord32(),
2159 if (lower()) DeferReplacement(node, lowering->Int32Sign(node));
2161 VisitUnop(node, UseInfo::TruncatingFloat64(),
2163 if (lower()) DeferReplacement(node, lowering->Float64Sign(node));
2168 VisitUnop(node, UseInfo::TruncatingFloat64(),
2170 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
2174 Type* const input_type = TypeOf(node->InputAt(0));
2176 VisitUnop(node, UseInfo::TruncatingWord32(),
2178 if (lower()) lowering->DoIntegral32ToBit(node);
2180 VisitUnop(node, UseInfo::TruncatingFloat64(),
2182 if (lower()) lowering->DoOrderedNumberToBit(node);
2184 VisitUnop(node, UseInfo::TruncatingFloat64(),
2186 if (lower()) lowering->DoNumberToBit(node);
2192 VisitUnop(node, UseInfo::TruncatingWord32(),
2194 if (lower()) DeferReplacement(node, node->InputAt(0));
2199 VisitUnop(node, UseInfo::TruncatingWord32(),
2201 if (lower()) DeferReplacement(node, node->InputAt(0));
2205 Type* const input_type = TypeOf(node->InputAt(0));
2207 VisitUnop(node, UseInfo::TruncatingWord32(),
2209 if (lower()) DeferReplacement(node, node->InputAt(0));
2211 VisitUnop(node, UseInfo::TruncatingWord32(),
2213 if (lower()) lowering->DoUnsigned32ToUint8Clamped(node);
2215 VisitUnop(node, UseInfo::TruncatingWord32(),
2217 if (lower()) lowering->DoSigned32ToUint8Clamped(node);
2219 VisitUnop(node, UseInfo::TruncatingFloat64(),
2221 if (lower()) lowering->DoIntegerToUint8Clamped(node);
2223 VisitUnop(node, UseInfo::TruncatingFloat64(),
2225 if (lower()) lowering->DoNumberToUint8Clamped(node);
2230 VisitBinop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit);
2232 NodeProperties::ChangeOp(node, lowering->machine()->WordEqual());
2239 return VisitBinop(node, UseInfo::AnyTagged(),
2243 VisitBinop(node, UseInfo::AnyTagged(), UseInfo::TruncatingWord32(),
2249 VisitBinop(node, UseInfo::AnyTagged(), UseInfo::TruncatingWord32(),
2254 VisitUnop(node, UseInfo::TruncatingWord32(),
2259 VisitUnop(node, UseInfo::TruncatingWord32(),
2264 ProcessInput(node, 0, UseInfo::AnyTagged());
2265 ProcessInput(node, 1, UseInfo::AnyTagged());
2266 ProcessInput(node, 2, UseInfo::TaggedSigned());
2267 SetOutput(node, MachineRepresentation::kTaggedSigned);
2272 Type* index_type = TypeOf(node->InputAt(0));
2273 Type* length_type = TypeOf(node->InputAt(1));
2275 VisitBinop(node, UseInfo::TruncatingWord32(),
2280 DeferReplacement(node, node->InputAt(0));
2283 VisitBinop(node, UseInfo::CheckedSigned32AsWord32(),
2290 if (InputCannotBe(node, Type::SignedSmall())) {
2291 VisitUnop(node, UseInfo::AnyTagged(),
2294 VisitUnop(node, UseInfo::CheckedHeapObjectAsTaggedPointer(),
2297 if (lower()) DeferReplacement(node, node->InputAt(0));
2301 ProcessInput(node, 0, UseInfo::Bool());
2302 ProcessRemainingInputs(node, 1);
2303 SetOutput(node, MachineRepresentation::kNone);
2307 if (InputIs(node, Type::InternalizedString())) {
2308 VisitUnop(node, UseInfo::AnyTagged(),
2310 if (lower()) DeferReplacement(node, node->InputAt(0));
2312 VisitUnop(node, UseInfo::CheckedHeapObjectAsTaggedPointer(),
2318 if (InputIs(node, Type::Number())) {
2320 VisitUnop(node, UseInfo::TruncatingWord32(),
2327 VisitUnop(node, UseInfo::AnyTagged(),
2330 if (lower()) DeferReplacement(node, node->InputAt(0));
2332 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
2337 if (InputIs(node, Type::Receiver())) {
2338 VisitUnop(node, UseInfo::AnyTagged(),
2340 if (lower()) DeferReplacement(node, node->InputAt(0));
2342 VisitUnop(node, UseInfo::CheckedHeapObjectAsTaggedPointer(),
2349 VisitUnop(node, UseInfo::CheckedSignedSmallAsWord32(),
2352 VisitUnop(node, UseInfo::CheckedSignedSmallAsTaggedSigned(),
2355 if (lower()) DeferReplacement(node, node->InputAt(0));
2359 if (InputIs(node, Type::String())) {
2360 VisitUnop(node, UseInfo::AnyTagged(),
2362 if (lower()) DeferReplacement(node, node->InputAt(0));
2364 VisitUnop(node, UseInfo::CheckedHeapObjectAsTaggedPointer(),
2371 ProcessInput(node, 0, UseInfo::TruncatingWord32());
2372 ProcessRemainingInputs(node, 1);
2373 SetOutput(node, MachineRepresentation::kTaggedPointer);
2377 if (truncation.IsUnused()) return VisitUnused(node);
2378 FieldAccess access = FieldAccessOf(node->op());
2381 VisitUnop(node, UseInfoForBasePointer(access), representation);
2385 FieldAccess access = FieldAccessOf(node->op());
2386 NodeInfo* input_info = GetInfo(node->InputAt(1));
2390 node->InputAt(1));
2391 ProcessInput(node, 0, UseInfoForBasePointer(access));
2392 ProcessInput(node, 1, TruncatingUseInfoFromRepresentation(
2394 ProcessRemainingInputs(node, 2);
2395 SetOutput(node, MachineRepresentation::kNone);
2400 node, jsgraph_->simplified()->StoreField(access));
2406 if (truncation.IsUnused()) return VisitUnused(node);
2407 BufferAccess access = BufferAccessOf(node->op());
2408 ProcessInput(node, 0, UseInfo::PointerInt()); // buffer
2409 ProcessInput(node, 1, UseInfo::TruncatingWord32()); // offset
2410 ProcessInput(node, 2, UseInfo::TruncatingWord32()); // length
2411 ProcessRemainingInputs(node, 3);
2435 SetOutput(node, output);
2436 if (lower()) lowering->DoLoadBuffer(node, output, changer_);
2440 BufferAccess access = BufferAccessOf(node->op());
2441 ProcessInput(node, 0, UseInfo::PointerInt()); // buffer
2442 ProcessInput(node, 1, UseInfo::TruncatingWord32()); // offset
2443 ProcessInput(node, 2, UseInfo::TruncatingWord32()); // length
2444 ProcessInput(node, 3,
2447 ProcessRemainingInputs(node, 4);
2448 SetOutput(node, MachineRepresentation::kNone);
2449 if (lower()) lowering->DoStoreBuffer(node);
2453 if (truncation.IsUnused()) return VisitUnused(node);
2454 ElementAccess access = ElementAccessOf(node->op());
2455 VisitBinop(node, UseInfoForBasePointer(access),
2461 ElementAccess access = ElementAccessOf(node->op());
2462 NodeInfo* input_info = GetInfo(node->InputAt(2));
2465 access.type, input_info->representation(), node->InputAt(2));
2466 ProcessInput(node, 0, UseInfoForBasePointer(access)); // base
2467 ProcessInput(node, 1, UseInfo::TruncatingWord32()); // index
2468 ProcessInput(node, 2,
2471 ProcessRemainingInputs(node, 3);
2472 SetOutput(node, MachineRepresentation::kNone);
2477 node, jsgraph_->simplified()->StoreElement(access));
2484 MachineRepresentationFromArrayType(ExternalArrayTypeOf(node->op()));
2485 ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
2486 ProcessInput(node, 1, UseInfo::AnyTagged()); // base pointer
2487 ProcessInput(node, 2, UseInfo::PointerInt()); // external pointer
2488 ProcessInput(node, 3, UseInfo::TruncatingWord32()); // index
2489 ProcessRemainingInputs(node, 4);
2490 SetOutput(node, rep);
2495 MachineRepresentationFromArrayType(ExternalArrayTypeOf(node->op()));
2496 ProcessInput(node, 0, UseInfo::AnyTagged()); // buffer
2497 ProcessInput(node, 1, UseInfo::AnyTagged()); // base pointer
2498 ProcessInput(node, 2, UseInfo::PointerInt()); // external pointer
2499 ProcessInput(node, 3, UseInfo::TruncatingWord32()); // index
2500 ProcessInput(node, 4,
2502 ProcessRemainingInputs(node, 5);
2503 SetOutput(node, MachineRepresentation::kNone);
2507 if (InputIs(node, Type::Boolean())) {
2508 VisitUnop(node, UseInfo::Bool(), MachineRepresentation::kWord32);
2509 if (lower()) DeferReplacement(node, node->InputAt(0));
2510 } else if (InputIs(node, Type::String())) {
2511 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
2512 if (lower()) lowering->DoStringToNumber(node);
2514 if (InputIs(node, Type::NumberOrOddball())) {
2515 VisitUnop(node, UseInfo::TruncatingWord32(),
2517 if (lower()) DeferReplacement(node, node->InputAt(0));
2519 VisitUnop(node, UseInfo::AnyTagged(),
2522 NodeProperties::ChangeOp(node,
2527 if (InputIs(node, Type::NumberOrOddball())) {
2528 VisitUnop(node, UseInfo::TruncatingFloat64(),
2530 if (lower()) DeferReplacement(node, node->InputAt(0));
2532 VisitUnop(node, UseInfo::AnyTagged(),
2535 NodeProperties::ChangeOp(node,
2540 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
2545 VisitObjectIs(node, Type::DetectableCallable(), lowering);
2549 VisitObjectIs(node, Type::NonCallable(), lowering);
2553 VisitObjectIs(node, Type::Number(), lowering);
2557 VisitObjectIs(node, Type::Receiver(), lowering);
2562 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit);
2566 VisitObjectIs(node, Type::String(), lowering);
2570 VisitObjectIs(node, Type::Undetectable(), lowering);
2575 ProcessRemainingInputs(node, 0);
2576 SetOutput(node, MachineRepresentation::kTaggedPointer);
2580 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kBit);
2584 CheckFloat64HoleMode mode = CheckFloat64HoleModeOf(node->op());
2585 ProcessInput(node, 0, UseInfo::TruncatingFloat64());
2586 ProcessRemainingInputs(node, 1);
2587 SetOutput(node, MachineRepresentation::kFloat64);
2590 if (lower()) DeferReplacement(node, node->InputAt(0));
2595 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
2599 if (InputIs(node, Type::NumberOrOddball()) &&
2602 VisitUnop(node, UseInfo::TruncatingWord32(),
2604 if (lower()) DeferReplacement(node, node->InputAt(0));
2605 } else if (InputIs(node, Type::NumberOrOddball()) &&
2608 VisitUnop(node, UseInfo::TruncatingFloat64(),
2610 if (lower()) DeferReplacement(node, node->InputAt(0));
2611 } else if (InputIs(node, Type::NonInternal())) {
2612 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
2613 if (lower()) DeferReplacement(node, node->InputAt(0));
2617 VisitUnop(node, UseInfo::AnyTagged(), MachineRepresentation::kTagged);
2623 VisitInputs(node);
2624 return SetOutput(node, MachineRepresentation::kNone);
2627 return VisitBinop(node, UseInfo::AnyTagged(),
2630 ProcessInput(node, 0, UseInfo::AnyTagged()); // object
2631 ProcessInput(node, 1, UseInfo::AnyTagged()); // elements
2632 ProcessInput(node, 2, UseInfo::TruncatingWord32()); // index
2633 ProcessInput(node, 3, UseInfo::TruncatingWord32()); // length
2634 ProcessRemainingInputs(node, 4);
2635 SetOutput(node, MachineRepresentation::kTaggedPointer);
2640 VisitUnop(node, UseInfo::TruncatingFloat64(),
2642 if (lower()) NodeProperties::ChangeOp(node, Float64Op(node));
2645 return VisitStateValues(node);
2647 return VisitObjectState(node);
2653 GetOutputInfoForPhi(node, TypeOf(node->InputAt(0)), truncation);
2654 VisitUnop(node, UseInfo(output, truncation), output);
2655 if (lower()) DeferReplacement(node, node->InputAt(0));
2660 return VisitOsrGuard(node);
2663 VisitInputs(node);
2665 return SetOutput(node, MachineRepresentation::kTaggedPointer);
2668 VisitReturn(node);
2670 return SetOutput(node, MachineRepresentation::kTagged);
2704 VisitInputs(node);
2706 return SetOutput(node, MachineRepresentation::kTagged);
2711 "Representation inference: unsupported opcode %i (%s), node #%i\n.",
2712 node->opcode(), node->op()->mnemonic(), node->id());
2718 void DeferReplacement(Node* node, Node* replacement) {
2719 TRACE("defer replacement #%d:%s with #%d:%s\n", node->id(),
2720 node->op()->mnemonic(), replacement->id(),
2723 // Disconnect the node from effect and control chains, if necessary.
2724 if (node->op()->EffectInputCount() > 0) {
2725 DCHECK_LT(0, node->op()->ControlInputCount());
2726 // Disconnect the node from effect and control chains.
2727 Node* control = NodeProperties::GetControlInput(node);
2728 Node* effect = NodeProperties::GetEffectInput(node);
2729 ReplaceEffectControlUses(node, effect, control);
2732 replacements_.push_back(node);
2735 node->NullAllInputs(); // Node is now dead.
2738 void Kill(Node* node) {
2739 TRACE("killing #%d:%s\n", node->id(), node->op()->mnemonic());
2741 if (node->op()->EffectInputCount() == 1) {
2742 DCHECK_LT(0, node->op()->ControlInputCount());
2743 // Disconnect the node from effect and control chains.
2744 Node* control = NodeProperties::GetControlInput(node);
2745 Node* effect = NodeProperties::GetEffectInput(node);
2746 ReplaceEffectControlUses(node, effect, control);
2748 DCHECK_EQ(0, node->op()->EffectInputCount());
2749 DCHECK_EQ(0, node->op()->ControlOutputCount());
2750 DCHECK_EQ(0, node->op()->EffectOutputCount());
2753 node->ReplaceUses(jsgraph_->Dead());
2755 node->NullAllInputs(); // The {node} is now dead.
2790 ZoneVector<NodeInfo> info_; // node id -> usage information
2799 ZoneQueue<Node*> queue_; // queue for traversing the graph
2802 Node* node;
2815 NodeInfo* GetInfo(Node* node) {
2816 DCHECK(node->id() < count_);
2817 return &info_[node->id()];
2838 Node* node, RepresentationSelector* selector) {
2839 DCHECK_EQ(IrOpcode::kJSToNumber, node->opcode());
2840 Node* value = node->InputAt(0);
2841 Node* context = node->InputAt(1);
2842 Node* frame_state = node->InputAt(2);
2843 Node* effect = node->InputAt(3);
2844 Node* control = node->InputAt(4);
2845 Node* throwing;
2847 Node* check0 = graph()->NewNode(simplified()->ObjectIsSmi(), value);
2848 Node* branch0 =
2851 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
2852 Node* etrue0 = effect;
2853 Node* vtrue0;
2859 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
2860 Node* efalse0 = effect;
2861 Node* vfalse0;
2868 Node* check1 = graph()->NewNode(simplified()->ObjectIsSmi(), vfalse0);
2869 Node* branch1 = graph()->NewNode(common()->Branch(), check1, if_false0);
2871 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
2872 Node* etrue1 = efalse0;
2873 Node* vtrue1;
2880 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
2881 Node* efalse1 = efalse0;
2882 Node* vfalse1;
2903 for (Edge edge : node->use_edges()) {
2918 selector->DeferReplacement(node, value);
2922 Node* node, RepresentationSelector* selector) {
2923 DCHECK_EQ(IrOpcode::kJSToNumber, node->opcode());
2924 Node* value = node->InputAt(0);
2925 Node* context = node->InputAt(1);
2926 Node* frame_state = node->InputAt(2);
2927 Node* effect = node->InputAt(3);
2928 Node* control = node->InputAt(4);
2929 Node* throwing;
2931 Node* check0 = graph()->NewNode(simplified()->ObjectIsSmi(), value);
2932 Node* branch0 =
2935 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
2936 Node* etrue0 = effect;
2937 Node* vtrue0 =
2940 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
2941 Node* efalse0 = effect;
2942 Node* vfalse0;
2949 Node* check1 = graph()->NewNode(simplified()->ObjectIsSmi(), vfalse0);
2950 Node* branch1 = graph()->NewNode(common()->Branch(), check1, if_false0);
2952 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
2953 Node* etrue1 = efalse0;
2954 Node* vtrue1 =
2957 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
2958 Node* efalse1 = efalse0;
2959 Node* vfalse1;
2980 for (Edge edge : node->use_edges()) {
2995 selector->DeferReplacement(node, value);
2998 void SimplifiedLowering::DoLoadBuffer(Node* node,
3001 DCHECK_EQ(IrOpcode::kLoadBuffer, node->opcode());
3003 MachineType const access_type = BufferAccessOf(node->op()).machine_type();
3005 Node* const buffer = node->InputAt(0);
3006 Node* const offset = node->InputAt(1);
3007 Node* const length = node->InputAt(2);
3008 Node* const effect = node->InputAt(3);
3009 Node* const control = node->InputAt(4);
3010 Node* const index =
3015 Node* check = graph()->NewNode(machine()->Uint32LessThan(), offset, length);
3016 Node* branch =
3019 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
3020 Node* etrue = graph()->NewNode(machine()->Load(access_type), buffer, index,
3023 Type::Intersect(NodeProperties::GetType(node), Type::Number(), zone());
3024 Node* vtrue = changer->GetRepresentationFor(
3025 etrue, access_type.representation(), element_type, node,
3028 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
3029 Node* efalse = effect;
3030 Node* vfalse;
3043 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
3044 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
3046 // Replace effect uses of {node} with the {ephi}.
3047 NodeProperties::ReplaceUses(node, node, ephi);
3049 // Turn the {node} into a Phi.
3050 node->ReplaceInput(0, vtrue);
3051 node->ReplaceInput(1, vfalse);
3052 node->ReplaceInput(2, merge);
3053 node->TrimInputCount(3);
3054 NodeProperties::ChangeOp(node, common()->Phi(output_rep, 2));
3056 NodeProperties::ChangeOp(node, machine()->CheckedLoad(access_type));
3061 void SimplifiedLowering::DoStoreBuffer(Node* node) {
3062 DCHECK_EQ(IrOpcode::kStoreBuffer, node->opcode());
3064 BufferAccessOf(node->op()).machine_type().representation();
3065 NodeProperties::ChangeOp(node, machine()->CheckedStore(rep));
3068 Node* SimplifiedLowering::Float64Round(Node* const node) {
3069 Node* const one = jsgraph()->Float64Constant(1.0);
3070 Node* const one_half = jsgraph()->Float64Constant(0.5);
3071 Node* const input = node->InputAt(0);
3074 Node* result = graph()->NewNode(machine()->Float64RoundUp().placeholder(),
3075 node->InputAt(0));
3084 Node* SimplifiedLowering::Float64Sign(Node* const node) {
3085 Node* const minus_one = jsgraph()->Float64Constant(-1.0);
3086 Node* const zero = jsgraph()->Float64Constant(0.0);
3087 Node* const one = jsgraph()->Float64Constant(1.0);
3089 Node* const input = node->InputAt(0);
3100 Node* SimplifiedLowering::Int32Abs(Node* const node) {
3101 Node* const input = node->InputAt(0);
3108 Node* sign = graph()->NewNode(machine()->Word32Sar(), input,
3115 Node* SimplifiedLowering::Int32Div(Node* const node) {
3116 Int32BinopMatcher m(node);
3117 Node* const zero = jsgraph()->Int32Constant(0);
3118 Node* const minus_one = jsgraph()->Int32Constant(-1);
3119 Node* const lhs = m.left().node();
3120 Node* const rhs = m.right().node();
3148 Node* check0 = graph()->NewNode(machine()->Int32LessThan(), zero, rhs);
3149 Node* branch0 = graph()->NewNode(common()->Branch(BranchHint::kTrue), check0,
3152 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
3153 Node* true0 = graph()->NewNode(machine()->Int32Div(), lhs, rhs, if_true0);
3155 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
3156 Node* false0;
3158 Node* check1 = graph()->NewNode(machine()->Int32LessThan(), rhs, minus_one);
3159 Node* branch1 = graph()->NewNode(common()->Branch(), check1, if_false0);
3161 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
3162 Node* true1 = graph()->NewNode(machine()->Int32Div(), lhs, rhs, if_true1);
3164 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
3165 Node* false1;
3167 Node* check2 = graph()->NewNode(machine()->Word32Equal(), rhs, zero);
3168 Node* branch2 = graph()->NewNode(common()->Branch(), check2, if_false1);
3170 Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2);
3171 Node* true2 = zero;
3173 Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2);
3174 Node* false2 = graph()->NewNode(machine()->Int32Sub(), zero, lhs);
3184 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0);
3189 Node* SimplifiedLowering::Int32Mod(Node* const node) {
3190 Int32BinopMatcher m(node);
3191 Node* const zero = jsgraph()->Int32Constant(0);
3192 Node* const minus_one = jsgraph()->Int32Constant(-1);
3193 Node* const lhs = m.left().node();
3194 Node* const rhs = m.right().node();
3226 Node* check0 = graph()->NewNode(machine()->Int32LessThan(), zero, rhs);
3227 Node* branch0 = graph()->NewNode(common()->Branch(BranchHint::kTrue), check0,
3230 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
3231 Node* true0;
3233 Node* msk = graph()->NewNode(machine()->Int32Add(), rhs, minus_one);
3235 Node* check1 = graph()->NewNode(machine()->Word32And(), rhs, msk);
3236 Node* branch1 = graph()->NewNode(common()->Branch(), check1, if_true0);
3238 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
3239 Node* true1 = graph()->NewNode(machine()->Int32Mod(), lhs, rhs, if_true1);
3241 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
3242 Node* false1;
3244 Node* check2 = graph()->NewNode(machine()->Int32LessThan(), lhs, zero);
3245 Node* branch2 = graph()->NewNode(common()->Branch(BranchHint::kFalse),
3248 Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2);
3249 Node* true2 = graph()->NewNode(
3255 Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2);
3256 Node* false2 = graph()->NewNode(machine()->Word32And(), lhs, msk);
3266 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
3267 Node* false0;
3269 Node* check1 = graph()->NewNode(machine()->Int32LessThan(), rhs, minus_one);
3270 Node* branch1 = graph()->NewNode(common()->Branch(BranchHint::kTrue),
3273 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
3274 Node* true1 = graph()->NewNode(machine()->Int32Mod(), lhs, rhs, if_true1);
3276 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
3277 Node* false1 = zero;
3283 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0);
3287 Node* SimplifiedLowering::Int32Sign(Node* const node) {
3288 Node* const minus_one = jsgraph()->Int32Constant(-1);
3289 Node* const zero = jsgraph()->Int32Constant(0);
3290 Node* const one = jsgraph()->Int32Constant(1);
3292 Node* const input = node->InputAt(0);
3303 Node* SimplifiedLowering::Uint32Div(Node* const node) {
3304 Uint32BinopMatcher m(node);
3305 Node* const zero = jsgraph()->Uint32Constant(0);
3306 Node* const lhs = m.left().node();
3307 Node* const rhs = m.right().node();
3315 Node* check = graph()->NewNode(machine()->Word32Equal(), rhs, zero);
3317 Node* div = graph()->NewNode(machine()->Uint32Div(), lhs, rhs, d.if_false);
3322 Node* SimplifiedLowering::Uint32Mod(Node* const node) {
3323 Uint32BinopMatcher m(node);
3324 Node* const minus_one = jsgraph()->Int32Constant(-1);
3325 Node* const zero = jsgraph()->Uint32Constant(0);
3326 Node* const lhs = m.left().node();
3327 Node* const rhs = m.right().node();
3353 Node* branch0 = graph()->NewNode(common()->Branch(BranchHint::kTrue), rhs,
3356 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
3357 Node* true0;
3359 Node* msk = graph()->NewNode(machine()->Int32Add(), rhs, minus_one);
3361 Node* check1 = graph()->NewNode(machine()->Word32And(), rhs, msk);
3362 Node* branch1 = graph()->NewNode(common()->Branch(), check1, if_true0);
3364 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
3365 Node* true1 = graph()->NewNode(machine()->Uint32Mod(), lhs, rhs, if_true1);
3367 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
3368 Node* false1 = graph()->NewNode(machine()->Word32And(), lhs, msk);
3374 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
3375 Node* false0 = zero;
3377 Node* merge0 = graph()->NewNode(merge_op, if_true0, if_false0);
3381 void SimplifiedLowering::DoMax(Node* node, Operator const* op,
3383 Node* const lhs = node->InputAt(0);
3384 Node* const rhs = node->InputAt(1);
3386 node->ReplaceInput(0, graph()->NewNode(op, lhs, rhs));
3387 DCHECK_EQ(rhs, node->InputAt(1));
3388 node->AppendInput(graph()->zone(), lhs);
3389 NodeProperties::ChangeOp(node, common()->Select(rep));
3392 void SimplifiedLowering::DoMin(Node* node, Operator const* op,
3394 Node* const lhs = node->InputAt(0);
3395 Node* const rhs = node->InputAt(1);
3397 node->InsertInput(graph()->zone(), 0, graph()->NewNode(op, lhs, rhs));
3398 DCHECK_EQ(lhs, node->InputAt(1));
3399 DCHECK_EQ(rhs, node->InputAt(2));
3400 NodeProperties::ChangeOp(node, common()->Select(rep));
3403 void SimplifiedLowering::DoShift(Node* node, Operator const* op,
3406 Node* const rhs = NodeProperties::GetValueInput(node, 1);
3407 node->ReplaceInput(1, graph()->NewNode(machine()->Word32And(), rhs,
3410 ChangeToPureOp(node, op);
3413 void SimplifiedLowering::DoStringToNumber(Node* node) {
3419 node->InsertInput(graph()->zone(), 0,
3421 node->AppendInput(graph()->zone(), jsgraph()->NoContextConstant());
3422 node->AppendInput(graph()->zone(), graph()->start());
3423 NodeProperties::ChangeOp(node, common()->Call(desc));
3426 void SimplifiedLowering::DoIntegral32ToBit(Node* node) {
3427 Node* const input = node->InputAt(0);
3428 Node* const zero = jsgraph()->Int32Constant(0);
3431 node->ReplaceInput(0, graph()->NewNode(op, input, zero));
3432 node->AppendInput(graph()->zone(), zero);
3433 NodeProperties::ChangeOp(node, op);
3436 void SimplifiedLowering::DoOrderedNumberToBit(Node* node) {
3437 Node* const input = node->InputAt(0);
3439 node->ReplaceInput(0, graph()->NewNode(machine()->Float64Equal(), input,
3441 node->AppendInput(graph()->zone(), jsgraph()->Int32Constant(0));
3442 NodeProperties::ChangeOp(node, machine()->Word32Equal());
3445 void SimplifiedLowering::DoNumberToBit(Node* node) {
3446 Node* const input = node->InputAt(0);
3448 node->ReplaceInput(0, jsgraph()->Float64Constant(0.0));
3449 node->AppendInput(graph()->zone(),
3451 NodeProperties::ChangeOp(node, machine()->Float64LessThan());
3454 void SimplifiedLowering::DoIntegerToUint8Clamped(Node* node) {
3455 Node* const input = node->InputAt(0);
3456 Node* const min = jsgraph()->Float64Constant(0.0);
3457 Node* const max = jsgraph()->Float64Constant(255.0);
3459 node->ReplaceInput(
3461 node->AppendInput(
3467 node->AppendInput(graph()->zone(), min);
3468 NodeProperties::ChangeOp(node,
3472 void SimplifiedLowering::DoNumberToUint8Clamped(Node* node) {
3473 Node* const input = node->InputAt(0);
3474 Node* const min = jsgraph()->Float64Constant(0.0);
3475 Node* const max = jsgraph()->Float64Constant(255.0);
3477 node->ReplaceInput(
3486 NodeProperties::ChangeOp(node,
3490 void SimplifiedLowering::DoSigned32ToUint8Clamped(Node* node) {
3491 Node* const input = node->InputAt(0);
3492 Node* const min = jsgraph()->Int32Constant(0);
3493 Node* const max = jsgraph()->Int32Constant(255);
3495 node->ReplaceInput(
3497 node->AppendInput(
3502 node->AppendInput(graph()->zone(), max);
3503 NodeProperties::ChangeOp(node,
3507 void SimplifiedLowering::DoUnsigned32ToUint8Clamped(Node* node) {
3508 Node* const input = node->InputAt(0);
3509 Node* const max = jsgraph()->Uint32Constant(255u);
3511 node->ReplaceInput(
3513 node->AppendInput(graph()->zone(), input);
3514 node->AppendInput(graph()->zone(), max);
3515 NodeProperties::ChangeOp(node,
3519 Node* SimplifiedLowering::ToNumberCode() {