11cb0ef41Sopenharmony_ci// Copyright 2014 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "src/compiler/simplified-operator-reducer.h"
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci#include "src/compiler/common-operator.h"
81cb0ef41Sopenharmony_ci#include "src/compiler/js-graph.h"
91cb0ef41Sopenharmony_ci#include "src/compiler/js-heap-broker.h"
101cb0ef41Sopenharmony_ci#include "src/compiler/machine-operator.h"
111cb0ef41Sopenharmony_ci#include "src/compiler/node-matchers.h"
121cb0ef41Sopenharmony_ci#include "src/compiler/opcodes.h"
131cb0ef41Sopenharmony_ci#include "src/compiler/operator-properties.h"
141cb0ef41Sopenharmony_ci#include "src/compiler/simplified-operator.h"
151cb0ef41Sopenharmony_ci#include "src/compiler/type-cache.h"
161cb0ef41Sopenharmony_ci#include "src/numbers/conversions-inl.h"
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_cinamespace v8 {
191cb0ef41Sopenharmony_cinamespace internal {
201cb0ef41Sopenharmony_cinamespace compiler {
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_cinamespace {
231cb0ef41Sopenharmony_ci
241cb0ef41Sopenharmony_ciDecision DecideObjectIsSmi(Node* const input) {
251cb0ef41Sopenharmony_ci  NumberMatcher m(input);
261cb0ef41Sopenharmony_ci  if (m.HasResolvedValue()) {
271cb0ef41Sopenharmony_ci    return IsSmiDouble(m.ResolvedValue()) ? Decision::kTrue : Decision::kFalse;
281cb0ef41Sopenharmony_ci  }
291cb0ef41Sopenharmony_ci  if (m.IsAllocate()) return Decision::kFalse;
301cb0ef41Sopenharmony_ci  if (m.IsChangeBitToTagged()) return Decision::kFalse;
311cb0ef41Sopenharmony_ci  if (m.IsChangeInt31ToTaggedSigned()) return Decision::kTrue;
321cb0ef41Sopenharmony_ci  if (m.IsHeapConstant()) return Decision::kFalse;
331cb0ef41Sopenharmony_ci  return Decision::kUnknown;
341cb0ef41Sopenharmony_ci}
351cb0ef41Sopenharmony_ci
361cb0ef41Sopenharmony_ci}  // namespace
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ciSimplifiedOperatorReducer::SimplifiedOperatorReducer(
391cb0ef41Sopenharmony_ci    Editor* editor, JSGraph* jsgraph, JSHeapBroker* broker,
401cb0ef41Sopenharmony_ci    BranchSemantics branch_semantics)
411cb0ef41Sopenharmony_ci    : AdvancedReducer(editor),
421cb0ef41Sopenharmony_ci      jsgraph_(jsgraph),
431cb0ef41Sopenharmony_ci      broker_(broker),
441cb0ef41Sopenharmony_ci      branch_semantics_(branch_semantics) {}
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ciSimplifiedOperatorReducer::~SimplifiedOperatorReducer() = default;
471cb0ef41Sopenharmony_ci
481cb0ef41Sopenharmony_ci
491cb0ef41Sopenharmony_ciReduction SimplifiedOperatorReducer::Reduce(Node* node) {
501cb0ef41Sopenharmony_ci  switch (node->opcode()) {
511cb0ef41Sopenharmony_ci    case IrOpcode::kBooleanNot: {
521cb0ef41Sopenharmony_ci      HeapObjectMatcher m(node->InputAt(0));
531cb0ef41Sopenharmony_ci      if (m.Is(factory()->true_value())) return ReplaceBoolean(false);
541cb0ef41Sopenharmony_ci      if (m.Is(factory()->false_value())) return ReplaceBoolean(true);
551cb0ef41Sopenharmony_ci      if (m.IsBooleanNot()) return Replace(m.InputAt(0));
561cb0ef41Sopenharmony_ci      break;
571cb0ef41Sopenharmony_ci    }
581cb0ef41Sopenharmony_ci    case IrOpcode::kChangeBitToTagged: {
591cb0ef41Sopenharmony_ci      Int32Matcher m(node->InputAt(0));
601cb0ef41Sopenharmony_ci      if (m.Is(0)) return Replace(jsgraph()->FalseConstant());
611cb0ef41Sopenharmony_ci      if (m.Is(1)) return Replace(jsgraph()->TrueConstant());
621cb0ef41Sopenharmony_ci      if (m.IsChangeTaggedToBit()) return Replace(m.InputAt(0));
631cb0ef41Sopenharmony_ci      break;
641cb0ef41Sopenharmony_ci    }
651cb0ef41Sopenharmony_ci    case IrOpcode::kChangeTaggedToBit: {
661cb0ef41Sopenharmony_ci      HeapObjectMatcher m(node->InputAt(0));
671cb0ef41Sopenharmony_ci      if (m.HasResolvedValue()) {
681cb0ef41Sopenharmony_ci        base::Optional<bool> maybe_result =
691cb0ef41Sopenharmony_ci            m.Ref(broker()).TryGetBooleanValue();
701cb0ef41Sopenharmony_ci        if (maybe_result.has_value()) return ReplaceInt32(*maybe_result);
711cb0ef41Sopenharmony_ci      }
721cb0ef41Sopenharmony_ci      if (m.IsChangeBitToTagged()) return Replace(m.InputAt(0));
731cb0ef41Sopenharmony_ci      break;
741cb0ef41Sopenharmony_ci    }
751cb0ef41Sopenharmony_ci    case IrOpcode::kChangeFloat64ToTagged: {
761cb0ef41Sopenharmony_ci      Float64Matcher m(node->InputAt(0));
771cb0ef41Sopenharmony_ci      if (m.HasResolvedValue()) return ReplaceNumber(m.ResolvedValue());
781cb0ef41Sopenharmony_ci      if (m.IsChangeTaggedToFloat64()) return Replace(m.node()->InputAt(0));
791cb0ef41Sopenharmony_ci      break;
801cb0ef41Sopenharmony_ci    }
811cb0ef41Sopenharmony_ci    case IrOpcode::kChangeInt31ToTaggedSigned:
821cb0ef41Sopenharmony_ci    case IrOpcode::kChangeInt32ToTagged: {
831cb0ef41Sopenharmony_ci      Int32Matcher m(node->InputAt(0));
841cb0ef41Sopenharmony_ci      if (m.HasResolvedValue()) return ReplaceNumber(m.ResolvedValue());
851cb0ef41Sopenharmony_ci      if (m.IsChangeTaggedSignedToInt32()) {
861cb0ef41Sopenharmony_ci        return Replace(m.InputAt(0));
871cb0ef41Sopenharmony_ci      }
881cb0ef41Sopenharmony_ci      break;
891cb0ef41Sopenharmony_ci    }
901cb0ef41Sopenharmony_ci    case IrOpcode::kChangeTaggedToFloat64:
911cb0ef41Sopenharmony_ci    case IrOpcode::kTruncateTaggedToFloat64: {
921cb0ef41Sopenharmony_ci      NumberMatcher m(node->InputAt(0));
931cb0ef41Sopenharmony_ci      if (m.HasResolvedValue()) return ReplaceFloat64(m.ResolvedValue());
941cb0ef41Sopenharmony_ci      if (m.IsChangeFloat64ToTagged() || m.IsChangeFloat64ToTaggedPointer()) {
951cb0ef41Sopenharmony_ci        return Replace(m.node()->InputAt(0));
961cb0ef41Sopenharmony_ci      }
971cb0ef41Sopenharmony_ci      if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) {
981cb0ef41Sopenharmony_ci        return Change(node, machine()->ChangeInt32ToFloat64(), m.InputAt(0));
991cb0ef41Sopenharmony_ci      }
1001cb0ef41Sopenharmony_ci      if (m.IsChangeUint32ToTagged()) {
1011cb0ef41Sopenharmony_ci        return Change(node, machine()->ChangeUint32ToFloat64(), m.InputAt(0));
1021cb0ef41Sopenharmony_ci      }
1031cb0ef41Sopenharmony_ci      break;
1041cb0ef41Sopenharmony_ci    }
1051cb0ef41Sopenharmony_ci    case IrOpcode::kChangeTaggedSignedToInt32:
1061cb0ef41Sopenharmony_ci    case IrOpcode::kChangeTaggedToInt32: {
1071cb0ef41Sopenharmony_ci      NumberMatcher m(node->InputAt(0));
1081cb0ef41Sopenharmony_ci      if (m.HasResolvedValue())
1091cb0ef41Sopenharmony_ci        return ReplaceInt32(DoubleToInt32(m.ResolvedValue()));
1101cb0ef41Sopenharmony_ci      if (m.IsChangeFloat64ToTagged() || m.IsChangeFloat64ToTaggedPointer()) {
1111cb0ef41Sopenharmony_ci        return Change(node, machine()->ChangeFloat64ToInt32(), m.InputAt(0));
1121cb0ef41Sopenharmony_ci      }
1131cb0ef41Sopenharmony_ci      if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged()) {
1141cb0ef41Sopenharmony_ci        return Replace(m.InputAt(0));
1151cb0ef41Sopenharmony_ci      }
1161cb0ef41Sopenharmony_ci      break;
1171cb0ef41Sopenharmony_ci    }
1181cb0ef41Sopenharmony_ci    case IrOpcode::kChangeTaggedToUint32: {
1191cb0ef41Sopenharmony_ci      NumberMatcher m(node->InputAt(0));
1201cb0ef41Sopenharmony_ci      if (m.HasResolvedValue())
1211cb0ef41Sopenharmony_ci        return ReplaceUint32(DoubleToUint32(m.ResolvedValue()));
1221cb0ef41Sopenharmony_ci      if (m.IsChangeFloat64ToTagged() || m.IsChangeFloat64ToTaggedPointer()) {
1231cb0ef41Sopenharmony_ci        return Change(node, machine()->ChangeFloat64ToUint32(), m.InputAt(0));
1241cb0ef41Sopenharmony_ci      }
1251cb0ef41Sopenharmony_ci      if (m.IsChangeUint32ToTagged()) return Replace(m.InputAt(0));
1261cb0ef41Sopenharmony_ci      break;
1271cb0ef41Sopenharmony_ci    }
1281cb0ef41Sopenharmony_ci    case IrOpcode::kChangeUint32ToTagged: {
1291cb0ef41Sopenharmony_ci      Uint32Matcher m(node->InputAt(0));
1301cb0ef41Sopenharmony_ci      if (m.HasResolvedValue())
1311cb0ef41Sopenharmony_ci        return ReplaceNumber(FastUI2D(m.ResolvedValue()));
1321cb0ef41Sopenharmony_ci      break;
1331cb0ef41Sopenharmony_ci    }
1341cb0ef41Sopenharmony_ci    case IrOpcode::kTruncateTaggedToWord32: {
1351cb0ef41Sopenharmony_ci      NumberMatcher m(node->InputAt(0));
1361cb0ef41Sopenharmony_ci      if (m.HasResolvedValue())
1371cb0ef41Sopenharmony_ci        return ReplaceInt32(DoubleToInt32(m.ResolvedValue()));
1381cb0ef41Sopenharmony_ci      if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged() ||
1391cb0ef41Sopenharmony_ci          m.IsChangeUint32ToTagged()) {
1401cb0ef41Sopenharmony_ci        return Replace(m.InputAt(0));
1411cb0ef41Sopenharmony_ci      }
1421cb0ef41Sopenharmony_ci      if (m.IsChangeFloat64ToTagged() || m.IsChangeFloat64ToTaggedPointer()) {
1431cb0ef41Sopenharmony_ci        return Change(node, machine()->TruncateFloat64ToWord32(), m.InputAt(0));
1441cb0ef41Sopenharmony_ci      }
1451cb0ef41Sopenharmony_ci      break;
1461cb0ef41Sopenharmony_ci    }
1471cb0ef41Sopenharmony_ci    case IrOpcode::kCheckedFloat64ToInt32: {
1481cb0ef41Sopenharmony_ci      Float64Matcher m(node->InputAt(0));
1491cb0ef41Sopenharmony_ci      if (m.HasResolvedValue() && IsInt32Double(m.ResolvedValue())) {
1501cb0ef41Sopenharmony_ci        Node* value =
1511cb0ef41Sopenharmony_ci            jsgraph()->Int32Constant(static_cast<int32_t>(m.ResolvedValue()));
1521cb0ef41Sopenharmony_ci        ReplaceWithValue(node, value);
1531cb0ef41Sopenharmony_ci        return Replace(value);
1541cb0ef41Sopenharmony_ci      }
1551cb0ef41Sopenharmony_ci      break;
1561cb0ef41Sopenharmony_ci    }
1571cb0ef41Sopenharmony_ci    case IrOpcode::kCheckedTaggedToArrayIndex:
1581cb0ef41Sopenharmony_ci    case IrOpcode::kCheckedTaggedToInt32:
1591cb0ef41Sopenharmony_ci    case IrOpcode::kCheckedTaggedSignedToInt32: {
1601cb0ef41Sopenharmony_ci      NodeMatcher m(node->InputAt(0));
1611cb0ef41Sopenharmony_ci      if (m.IsConvertTaggedHoleToUndefined()) {
1621cb0ef41Sopenharmony_ci        node->ReplaceInput(0, m.InputAt(0));
1631cb0ef41Sopenharmony_ci        return Changed(node);
1641cb0ef41Sopenharmony_ci      }
1651cb0ef41Sopenharmony_ci      break;
1661cb0ef41Sopenharmony_ci    }
1671cb0ef41Sopenharmony_ci    case IrOpcode::kCheckIf: {
1681cb0ef41Sopenharmony_ci      HeapObjectMatcher m(node->InputAt(0));
1691cb0ef41Sopenharmony_ci      if (m.Is(factory()->true_value())) {
1701cb0ef41Sopenharmony_ci        Node* const effect = NodeProperties::GetEffectInput(node);
1711cb0ef41Sopenharmony_ci        return Replace(effect);
1721cb0ef41Sopenharmony_ci      }
1731cb0ef41Sopenharmony_ci      break;
1741cb0ef41Sopenharmony_ci    }
1751cb0ef41Sopenharmony_ci    case IrOpcode::kCheckNumber: {
1761cb0ef41Sopenharmony_ci      NodeMatcher m(node->InputAt(0));
1771cb0ef41Sopenharmony_ci      if (m.IsConvertTaggedHoleToUndefined()) {
1781cb0ef41Sopenharmony_ci        node->ReplaceInput(0, m.InputAt(0));
1791cb0ef41Sopenharmony_ci        return Changed(node);
1801cb0ef41Sopenharmony_ci      }
1811cb0ef41Sopenharmony_ci      break;
1821cb0ef41Sopenharmony_ci    }
1831cb0ef41Sopenharmony_ci    case IrOpcode::kCheckHeapObject: {
1841cb0ef41Sopenharmony_ci      Node* const input = node->InputAt(0);
1851cb0ef41Sopenharmony_ci      if (DecideObjectIsSmi(input) == Decision::kFalse) {
1861cb0ef41Sopenharmony_ci        ReplaceWithValue(node, input);
1871cb0ef41Sopenharmony_ci        return Replace(input);
1881cb0ef41Sopenharmony_ci      }
1891cb0ef41Sopenharmony_ci      NodeMatcher m(input);
1901cb0ef41Sopenharmony_ci      if (m.IsCheckHeapObject()) {
1911cb0ef41Sopenharmony_ci        ReplaceWithValue(node, input);
1921cb0ef41Sopenharmony_ci        return Replace(input);
1931cb0ef41Sopenharmony_ci      }
1941cb0ef41Sopenharmony_ci      break;
1951cb0ef41Sopenharmony_ci    }
1961cb0ef41Sopenharmony_ci    case IrOpcode::kCheckSmi: {
1971cb0ef41Sopenharmony_ci      Node* const input = node->InputAt(0);
1981cb0ef41Sopenharmony_ci      if (DecideObjectIsSmi(input) == Decision::kTrue) {
1991cb0ef41Sopenharmony_ci        ReplaceWithValue(node, input);
2001cb0ef41Sopenharmony_ci        return Replace(input);
2011cb0ef41Sopenharmony_ci      }
2021cb0ef41Sopenharmony_ci      NodeMatcher m(input);
2031cb0ef41Sopenharmony_ci      if (m.IsCheckSmi()) {
2041cb0ef41Sopenharmony_ci        ReplaceWithValue(node, input);
2051cb0ef41Sopenharmony_ci        return Replace(input);
2061cb0ef41Sopenharmony_ci      } else if (m.IsConvertTaggedHoleToUndefined()) {
2071cb0ef41Sopenharmony_ci        node->ReplaceInput(0, m.InputAt(0));
2081cb0ef41Sopenharmony_ci        return Changed(node);
2091cb0ef41Sopenharmony_ci      }
2101cb0ef41Sopenharmony_ci      break;
2111cb0ef41Sopenharmony_ci    }
2121cb0ef41Sopenharmony_ci    case IrOpcode::kObjectIsSmi: {
2131cb0ef41Sopenharmony_ci      Node* const input = node->InputAt(0);
2141cb0ef41Sopenharmony_ci      switch (DecideObjectIsSmi(input)) {
2151cb0ef41Sopenharmony_ci        case Decision::kTrue:
2161cb0ef41Sopenharmony_ci          return ReplaceBoolean(true);
2171cb0ef41Sopenharmony_ci        case Decision::kFalse:
2181cb0ef41Sopenharmony_ci          return ReplaceBoolean(false);
2191cb0ef41Sopenharmony_ci        case Decision::kUnknown:
2201cb0ef41Sopenharmony_ci          break;
2211cb0ef41Sopenharmony_ci      }
2221cb0ef41Sopenharmony_ci      break;
2231cb0ef41Sopenharmony_ci    }
2241cb0ef41Sopenharmony_ci    case IrOpcode::kNumberAbs: {
2251cb0ef41Sopenharmony_ci      NumberMatcher m(node->InputAt(0));
2261cb0ef41Sopenharmony_ci      if (m.HasResolvedValue())
2271cb0ef41Sopenharmony_ci        return ReplaceNumber(std::fabs(m.ResolvedValue()));
2281cb0ef41Sopenharmony_ci      break;
2291cb0ef41Sopenharmony_ci    }
2301cb0ef41Sopenharmony_ci    case IrOpcode::kReferenceEqual: {
2311cb0ef41Sopenharmony_ci      HeapObjectBinopMatcher m(node);
2321cb0ef41Sopenharmony_ci      if (m.left().node() == m.right().node()) return ReplaceBoolean(true);
2331cb0ef41Sopenharmony_ci      break;
2341cb0ef41Sopenharmony_ci    }
2351cb0ef41Sopenharmony_ci    case IrOpcode::kCheckedInt32Add: {
2361cb0ef41Sopenharmony_ci      // (x + a) + b => x + (a + b) where a and b are constants and have the
2371cb0ef41Sopenharmony_ci      // same sign.
2381cb0ef41Sopenharmony_ci      Int32BinopMatcher m(node);
2391cb0ef41Sopenharmony_ci      if (m.right().HasResolvedValue()) {
2401cb0ef41Sopenharmony_ci        Node* checked_int32_add = m.left().node();
2411cb0ef41Sopenharmony_ci        if (checked_int32_add->opcode() == IrOpcode::kCheckedInt32Add) {
2421cb0ef41Sopenharmony_ci          Int32BinopMatcher n(checked_int32_add);
2431cb0ef41Sopenharmony_ci          if (n.right().HasResolvedValue() &&
2441cb0ef41Sopenharmony_ci              (n.right().ResolvedValue() >= 0) ==
2451cb0ef41Sopenharmony_ci                  (m.right().ResolvedValue() >= 0)) {
2461cb0ef41Sopenharmony_ci            int32_t val;
2471cb0ef41Sopenharmony_ci            bool overflow = base::bits::SignedAddOverflow32(
2481cb0ef41Sopenharmony_ci                n.right().ResolvedValue(), m.right().ResolvedValue(), &val);
2491cb0ef41Sopenharmony_ci            if (!overflow) {
2501cb0ef41Sopenharmony_ci              bool has_no_other_uses = true;
2511cb0ef41Sopenharmony_ci              for (Edge edge : checked_int32_add->use_edges()) {
2521cb0ef41Sopenharmony_ci                if (!edge.from()->IsDead() && edge.from() != node) {
2531cb0ef41Sopenharmony_ci                  has_no_other_uses = false;
2541cb0ef41Sopenharmony_ci                  break;
2551cb0ef41Sopenharmony_ci                }
2561cb0ef41Sopenharmony_ci              }
2571cb0ef41Sopenharmony_ci              if (has_no_other_uses) {
2581cb0ef41Sopenharmony_ci                node->ReplaceInput(0, n.left().node());
2591cb0ef41Sopenharmony_ci                node->ReplaceInput(1, jsgraph()->Int32Constant(val));
2601cb0ef41Sopenharmony_ci                RelaxEffectsAndControls(checked_int32_add);
2611cb0ef41Sopenharmony_ci                return Changed(node);
2621cb0ef41Sopenharmony_ci              }
2631cb0ef41Sopenharmony_ci            }
2641cb0ef41Sopenharmony_ci          }
2651cb0ef41Sopenharmony_ci        }
2661cb0ef41Sopenharmony_ci      }
2671cb0ef41Sopenharmony_ci      break;
2681cb0ef41Sopenharmony_ci    }
2691cb0ef41Sopenharmony_ci    default:
2701cb0ef41Sopenharmony_ci      break;
2711cb0ef41Sopenharmony_ci  }
2721cb0ef41Sopenharmony_ci  return NoChange();
2731cb0ef41Sopenharmony_ci}
2741cb0ef41Sopenharmony_ci
2751cb0ef41Sopenharmony_ciReduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op,
2761cb0ef41Sopenharmony_ci                                            Node* a) {
2771cb0ef41Sopenharmony_ci  DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op));
2781cb0ef41Sopenharmony_ci  DCHECK_LE(1, node->InputCount());
2791cb0ef41Sopenharmony_ci  node->ReplaceInput(0, a);
2801cb0ef41Sopenharmony_ci  NodeProperties::ChangeOp(node, op);
2811cb0ef41Sopenharmony_ci  return Changed(node);
2821cb0ef41Sopenharmony_ci}
2831cb0ef41Sopenharmony_ci
2841cb0ef41Sopenharmony_ciReduction SimplifiedOperatorReducer::ReplaceBoolean(bool value) {
2851cb0ef41Sopenharmony_ci  if (branch_semantics_ == BranchSemantics::kJS) {
2861cb0ef41Sopenharmony_ci    return Replace(jsgraph()->BooleanConstant(value));
2871cb0ef41Sopenharmony_ci  } else {
2881cb0ef41Sopenharmony_ci    return ReplaceInt32(value);
2891cb0ef41Sopenharmony_ci  }
2901cb0ef41Sopenharmony_ci}
2911cb0ef41Sopenharmony_ci
2921cb0ef41Sopenharmony_ciReduction SimplifiedOperatorReducer::ReplaceFloat64(double value) {
2931cb0ef41Sopenharmony_ci  return Replace(jsgraph()->Float64Constant(value));
2941cb0ef41Sopenharmony_ci}
2951cb0ef41Sopenharmony_ci
2961cb0ef41Sopenharmony_ci
2971cb0ef41Sopenharmony_ciReduction SimplifiedOperatorReducer::ReplaceInt32(int32_t value) {
2981cb0ef41Sopenharmony_ci  return Replace(jsgraph()->Int32Constant(value));
2991cb0ef41Sopenharmony_ci}
3001cb0ef41Sopenharmony_ci
3011cb0ef41Sopenharmony_ci
3021cb0ef41Sopenharmony_ciReduction SimplifiedOperatorReducer::ReplaceNumber(double value) {
3031cb0ef41Sopenharmony_ci  return Replace(jsgraph()->Constant(value));
3041cb0ef41Sopenharmony_ci}
3051cb0ef41Sopenharmony_ci
3061cb0ef41Sopenharmony_ci
3071cb0ef41Sopenharmony_ciReduction SimplifiedOperatorReducer::ReplaceNumber(int32_t value) {
3081cb0ef41Sopenharmony_ci  return Replace(jsgraph()->Constant(value));
3091cb0ef41Sopenharmony_ci}
3101cb0ef41Sopenharmony_ci
3111cb0ef41Sopenharmony_ciFactory* SimplifiedOperatorReducer::factory() const {
3121cb0ef41Sopenharmony_ci  return jsgraph()->isolate()->factory();
3131cb0ef41Sopenharmony_ci}
3141cb0ef41Sopenharmony_ci
3151cb0ef41Sopenharmony_ciGraph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); }
3161cb0ef41Sopenharmony_ci
3171cb0ef41Sopenharmony_ciMachineOperatorBuilder* SimplifiedOperatorReducer::machine() const {
3181cb0ef41Sopenharmony_ci  return jsgraph()->machine();
3191cb0ef41Sopenharmony_ci}
3201cb0ef41Sopenharmony_ci
3211cb0ef41Sopenharmony_ciSimplifiedOperatorBuilder* SimplifiedOperatorReducer::simplified() const {
3221cb0ef41Sopenharmony_ci  return jsgraph()->simplified();
3231cb0ef41Sopenharmony_ci}
3241cb0ef41Sopenharmony_ci
3251cb0ef41Sopenharmony_ci}  // namespace compiler
3261cb0ef41Sopenharmony_ci}  // namespace internal
3271cb0ef41Sopenharmony_ci}  // namespace v8
328