Chromium Code Reviews| Index: src/compiler/machine-operator-reducer.cc |
| diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc |
| index b70eef5ccf0a44ca8f5989797a7af05b8d28d31f..420eb0bfcd1cb7f7a1e01f58f638b0a1049202cc 100644 |
| --- a/src/compiler/machine-operator-reducer.cc |
| +++ b/src/compiler/machine-operator-reducer.cc |
| @@ -213,13 +213,13 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
| return ReplaceInt32(m.left().Value() * m.right().Value()); |
| } |
| if (m.right().Is(-1)) { // x * -1 => 0 - x |
| - node->set_op(machine()->Int32Sub()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Sub()); |
|
Jarin
2015/09/24 14:00:41
After ReplaceInput? (Here and below.)
Michael Starzinger
2015/09/24 14:21:28
Done.
|
| node->ReplaceInput(0, Int32Constant(0)); |
| node->ReplaceInput(1, m.left().node()); |
| return Changed(node); |
| } |
| if (m.right().IsPowerOf2()) { // x * 2^n => x << n |
| - node->set_op(machine()->Word32Shl()); |
| + NodeProperties::ChangeOp(node, machine()->Word32Shl()); |
| node->ReplaceInput(1, Int32Constant(WhichPowerOf2(m.right().Value()))); |
| Reduction reduction = ReduceWord32Shl(node); |
| return reduction.Changed() ? reduction : Changed(node); |
| @@ -338,7 +338,7 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
| case IrOpcode::kFloat64Mul: { |
| Float64BinopMatcher m(node); |
| if (m.right().Is(-1)) { // x * -1.0 => -0.0 - x |
| - node->set_op(machine()->Float64Sub()); |
| + NodeProperties::ChangeOp(node, machine()->Float64Sub()); |
| node->ReplaceInput(0, Float64Constant(-0.0)); |
| node->ReplaceInput(1, m.left().node()); |
| return Changed(node); |
| @@ -461,7 +461,7 @@ Reduction MachineOperatorReducer::ReduceInt32Add(Node* node) { |
| if (m.left().IsInt32Sub()) { |
| Int32BinopMatcher mleft(m.left().node()); |
| if (mleft.left().Is(0)) { // (0 - x) + y => y - x |
| - node->set_op(machine()->Int32Sub()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Sub()); |
| node->ReplaceInput(0, m.right().node()); |
| node->ReplaceInput(1, mleft.right().node()); |
| Reduction const reduction = ReduceInt32Sub(node); |
| @@ -471,7 +471,7 @@ Reduction MachineOperatorReducer::ReduceInt32Add(Node* node) { |
| if (m.right().IsInt32Sub()) { |
| Int32BinopMatcher mright(m.right().node()); |
| if (mright.left().Is(0)) { // y + (0 - x) => y - x |
| - node->set_op(machine()->Int32Sub()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Sub()); |
| node->ReplaceInput(1, mright.right().node()); |
| Reduction const reduction = ReduceInt32Sub(node); |
| return reduction.Changed() ? reduction : Changed(node); |
| @@ -491,7 +491,7 @@ Reduction MachineOperatorReducer::ReduceInt32Sub(Node* node) { |
| } |
| if (m.LeftEqualsRight()) return ReplaceInt32(0); // x - x => 0 |
| if (m.right().HasValue()) { // x - K => x + -K |
| - node->set_op(machine()->Int32Add()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Add()); |
| node->ReplaceInput(1, Int32Constant(-m.right().Value())); |
| Reduction const reduction = ReduceInt32Add(node); |
| return reduction.Changed() ? reduction : Changed(node); |
| @@ -514,10 +514,10 @@ Reduction MachineOperatorReducer::ReduceInt32Div(Node* node) { |
| return Replace(Word32Equal(Word32Equal(m.left().node(), zero), zero)); |
| } |
| if (m.right().Is(-1)) { // x / -1 => 0 - x |
| - node->set_op(machine()->Int32Sub()); |
| node->ReplaceInput(0, Int32Constant(0)); |
| node->ReplaceInput(1, m.left().node()); |
| node->TrimInputCount(2); |
| + NodeProperties::ChangeOp(node, machine()->Int32Sub()); |
| return Changed(node); |
| } |
| if (m.right().HasValue()) { |
| @@ -536,10 +536,10 @@ Reduction MachineOperatorReducer::ReduceInt32Div(Node* node) { |
| quotient = Int32Div(quotient, Abs(divisor)); |
| } |
| if (divisor < 0) { |
| - node->set_op(machine()->Int32Sub()); |
| node->ReplaceInput(0, Int32Constant(0)); |
| node->ReplaceInput(1, quotient); |
| node->TrimInputCount(2); |
| + NodeProperties::ChangeOp(node, machine()->Int32Sub()); |
| return Changed(node); |
| } |
| return Replace(quotient); |
| @@ -565,9 +565,9 @@ Reduction MachineOperatorReducer::ReduceUint32Div(Node* node) { |
| Node* const dividend = m.left().node(); |
| uint32_t const divisor = m.right().Value(); |
| if (base::bits::IsPowerOfTwo32(divisor)) { // x / 2^n => x >> n |
| - node->set_op(machine()->Word32Shr()); |
| node->ReplaceInput(1, Uint32Constant(WhichPowerOf2(m.right().Value()))); |
| node->TrimInputCount(2); |
| + NodeProperties::ChangeOp(node, machine()->Word32Shr()); |
| return Changed(node); |
| } else { |
| return Replace(Uint32Div(dividend, divisor)); |
| @@ -594,7 +594,8 @@ Reduction MachineOperatorReducer::ReduceInt32Mod(Node* node) { |
| if (base::bits::IsPowerOfTwo32(divisor)) { |
| uint32_t const mask = divisor - 1; |
| Node* const zero = Int32Constant(0); |
| - node->set_op(common()->Select(kMachInt32, BranchHint::kFalse)); |
| + NodeProperties::ChangeOp( |
| + node, common()->Select(kMachInt32, BranchHint::kFalse)); |
| node->ReplaceInput( |
| 0, graph()->NewNode(machine()->Int32LessThan(), dividend, zero)); |
| node->ReplaceInput( |
| @@ -602,10 +603,10 @@ Reduction MachineOperatorReducer::ReduceInt32Mod(Node* node) { |
| node->ReplaceInput(2, Word32And(dividend, mask)); |
| } else { |
| Node* quotient = Int32Div(dividend, divisor); |
| - node->set_op(machine()->Int32Sub()); |
| DCHECK_EQ(dividend, node->InputAt(0)); |
| node->ReplaceInput(1, Int32Mul(quotient, Int32Constant(divisor))); |
| node->TrimInputCount(2); |
| + NodeProperties::ChangeOp(node, machine()->Int32Sub()); |
| } |
| return Changed(node); |
| } |
| @@ -627,15 +628,16 @@ Reduction MachineOperatorReducer::ReduceUint32Mod(Node* node) { |
| Node* const dividend = m.left().node(); |
| uint32_t const divisor = m.right().Value(); |
| if (base::bits::IsPowerOfTwo32(divisor)) { // x % 2^n => x & 2^n-1 |
| - node->set_op(machine()->Word32And()); |
| node->ReplaceInput(1, Uint32Constant(m.right().Value() - 1)); |
| + node->TrimInputCount(2); |
| + NodeProperties::ChangeOp(node, machine()->Word32And()); |
| } else { |
| Node* quotient = Uint32Div(dividend, divisor); |
| - node->set_op(machine()->Int32Sub()); |
| DCHECK_EQ(dividend, node->InputAt(0)); |
| node->ReplaceInput(1, Int32Mul(quotient, Uint32Constant(divisor))); |
| + node->TrimInputCount(2); |
| + NodeProperties::ChangeOp(node, machine()->Int32Sub()); |
| } |
| - node->TrimInputCount(2); |
| return Changed(node); |
| } |
| return NoChange(); |
| @@ -663,7 +665,8 @@ Reduction MachineOperatorReducer::ReduceTruncateFloat64ToInt32(Node* node) { |
| if (reduction.Changed()) input = reduction.replacement(); |
| phi->ReplaceInput(i, input); |
| } |
| - phi->set_op(common()->Phi(kMachInt32, value_input_count)); |
| + NodeProperties::ChangeOp(phi, |
| + common()->Phi(kMachInt32, value_input_count)); |
| return Replace(phi); |
| } |
| } |
| @@ -776,7 +779,7 @@ Reduction MachineOperatorReducer::ReduceWord32Shl(Node* node) { |
| if (m.left().IsWord32Sar() || m.left().IsWord32Shr()) { |
| Int32BinopMatcher mleft(m.left().node()); |
| if (mleft.right().Is(m.right().Value())) { |
| - node->set_op(machine()->Word32And()); |
| + NodeProperties::ChangeOp(node, machine()->Word32And()); |
| node->ReplaceInput(0, mleft.left().node()); |
| node->ReplaceInput(1, |
| Uint32Constant(~((1U << m.right().Value()) - 1U))); |
| @@ -800,7 +803,7 @@ Reduction MachineOperatorReducer::ReduceWord32Sar(Node* node) { |
| if (mleft.left().IsComparison()) { |
| if (m.right().Is(31) && mleft.right().Is(31)) { |
| // Comparison << 31 >> 31 => 0 - Comparison |
| - node->set_op(machine()->Int32Sub()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Sub()); |
| node->ReplaceInput(0, Int32Constant(0)); |
| node->ReplaceInput(1, mleft.left().node()); |
| Reduction const reduction = ReduceInt32Sub(node); |
| @@ -859,7 +862,7 @@ Reduction MachineOperatorReducer::ReduceWord32And(Node* node) { |
| if (mleft.right().HasValue() && |
| (mleft.right().Value() & mask) == mleft.right().Value()) { |
| // (x + (K << L)) & (-1 << L) => (x & (-1 << L)) + (K << L) |
| - node->set_op(machine()->Int32Add()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Add()); |
| node->ReplaceInput(0, Word32And(mleft.left().node(), m.right().node())); |
| node->ReplaceInput(1, mleft.right().node()); |
| Reduction const reduction = ReduceInt32Add(node); |
| @@ -869,7 +872,7 @@ Reduction MachineOperatorReducer::ReduceWord32And(Node* node) { |
| Int32BinopMatcher mleftleft(mleft.left().node()); |
| if (mleftleft.right().IsMultipleOf(-mask)) { |
| // (y * (K << L) + x) & (-1 << L) => (x & (-1 << L)) + y * (K << L) |
| - node->set_op(machine()->Int32Add()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Add()); |
| node->ReplaceInput(0, |
| Word32And(mleft.right().node(), m.right().node())); |
| node->ReplaceInput(1, mleftleft.node()); |
| @@ -881,7 +884,7 @@ Reduction MachineOperatorReducer::ReduceWord32And(Node* node) { |
| Int32BinopMatcher mleftright(mleft.right().node()); |
| if (mleftright.right().IsMultipleOf(-mask)) { |
| // (x + y * (K << L)) & (-1 << L) => (x & (-1 << L)) + y * (K << L) |
| - node->set_op(machine()->Int32Add()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Add()); |
| node->ReplaceInput(0, |
| Word32And(mleft.left().node(), m.right().node())); |
| node->ReplaceInput(1, mleftright.node()); |
| @@ -893,7 +896,7 @@ Reduction MachineOperatorReducer::ReduceWord32And(Node* node) { |
| Int32BinopMatcher mleftleft(mleft.left().node()); |
| if (mleftleft.right().Is(base::bits::CountTrailingZeros32(mask))) { |
| // (y << L + x) & (-1 << L) => (x & (-1 << L)) + y << L |
| - node->set_op(machine()->Int32Add()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Add()); |
| node->ReplaceInput(0, |
| Word32And(mleft.right().node(), m.right().node())); |
| node->ReplaceInput(1, mleftleft.node()); |
| @@ -905,7 +908,7 @@ Reduction MachineOperatorReducer::ReduceWord32And(Node* node) { |
| Int32BinopMatcher mleftright(mleft.right().node()); |
| if (mleftright.right().Is(base::bits::CountTrailingZeros32(mask))) { |
| // (x + y << L) & (-1 << L) => (x & (-1 << L)) + y << L |
| - node->set_op(machine()->Int32Add()); |
| + NodeProperties::ChangeOp(node, machine()->Int32Add()); |
| node->ReplaceInput(0, |
| Word32And(mleft.left().node(), m.right().node())); |
| node->ReplaceInput(1, mleftright.node()); |
| @@ -975,7 +978,7 @@ Reduction MachineOperatorReducer::ReduceWord32Or(Node* node) { |
| if (!msub.left().Is(32) || msub.right().node() != y) return NoChange(); |
| } |
| - node->set_op(machine()->Word32Ror()); |
| + NodeProperties::ChangeOp(node, machine()->Word32Ror()); |
| node->ReplaceInput(0, mshl.left().node()); |
| node->ReplaceInput(1, mshr.right().node()); |
| return Changed(node); |
| @@ -1040,13 +1043,13 @@ Reduction MachineOperatorReducer::ReduceFloat64Compare(Node* node) { |
| m.right().IsChangeFloat32ToFloat64())) { |
| switch (node->opcode()) { |
| case IrOpcode::kFloat64Equal: |
| - node->set_op(machine()->Float32Equal()); |
| + NodeProperties::ChangeOp(node, machine()->Float32Equal()); |
| break; |
| case IrOpcode::kFloat64LessThan: |
| - node->set_op(machine()->Float32LessThan()); |
| + NodeProperties::ChangeOp(node, machine()->Float32LessThan()); |
| break; |
| case IrOpcode::kFloat64LessThanOrEqual: |
| - node->set_op(machine()->Float32LessThanOrEqual()); |
| + NodeProperties::ChangeOp(node, machine()->Float32LessThanOrEqual()); |
| break; |
| default: |
| return NoChange(); |