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/machine-operator-reducer.h" | 5 #include "src/compiler/machine-operator-reducer.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/compiler/diamond.h" | 10 #include "src/compiler/diamond.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 quotient = Word32Shr(quotient, mag.shift); | 123 quotient = Word32Shr(quotient, mag.shift); |
124 } | 124 } |
125 return quotient; | 125 return quotient; |
126 } | 126 } |
127 | 127 |
128 | 128 |
129 // Perform constant folding and strength reduction on machine operators. | 129 // Perform constant folding and strength reduction on machine operators. |
130 Reduction MachineOperatorReducer::Reduce(Node* node) { | 130 Reduction MachineOperatorReducer::Reduce(Node* node) { |
131 switch (node->opcode()) { | 131 switch (node->opcode()) { |
132 case IrOpcode::kProjection: | 132 case IrOpcode::kProjection: |
133 return ReduceProjection(OpParameter<size_t>(node), node->InputAt(0)); | 133 return ReduceProjection(ProjectionIndexOf(node->op()), node->InputAt(0)); |
134 case IrOpcode::kWord32And: | 134 case IrOpcode::kWord32And: |
135 return ReduceWord32And(node); | 135 return ReduceWord32And(node); |
136 case IrOpcode::kWord32Or: | 136 case IrOpcode::kWord32Or: |
137 return ReduceWord32Or(node); | 137 return ReduceWord32Or(node); |
138 case IrOpcode::kWord32Xor: { | 138 case IrOpcode::kWord32Xor: { |
139 Int32BinopMatcher m(node); | 139 Int32BinopMatcher m(node); |
140 if (m.right().Is(0)) return Replace(m.left().node()); // x ^ 0 => x | 140 if (m.right().Is(0)) return Replace(m.left().node()); // x ^ 0 => x |
141 if (m.IsFoldable()) { // K ^ K => K | 141 if (m.IsFoldable()) { // K ^ K => K |
142 return ReplaceInt32(m.left().Value() ^ m.right().Value()); | 142 return ReplaceInt32(m.left().Value() ^ m.right().Value()); |
143 } | 143 } |
(...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 MachineOperatorBuilder* MachineOperatorReducer::machine() const { | 942 MachineOperatorBuilder* MachineOperatorReducer::machine() const { |
943 return jsgraph()->machine(); | 943 return jsgraph()->machine(); |
944 } | 944 } |
945 | 945 |
946 | 946 |
947 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } | 947 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } |
948 | 948 |
949 } // namespace compiler | 949 } // namespace compiler |
950 } // namespace internal | 950 } // namespace internal |
951 } // namespace v8 | 951 } // namespace v8 |
OLD | NEW |