OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/typed-optimization.h" | 5 #include "src/compiler/typed-optimization.h" |
6 | 6 |
7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 #include "src/compiler/simplified-operator.h" | 10 #include "src/compiler/simplified-operator.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return NoChange(); | 188 return NoChange(); |
189 } | 189 } |
190 | 190 |
191 Reduction TypedOptimization::ReduceNumberFloor(Node* node) { | 191 Reduction TypedOptimization::ReduceNumberFloor(Node* node) { |
192 Node* const input = NodeProperties::GetValueInput(node, 0); | 192 Node* const input = NodeProperties::GetValueInput(node, 0); |
193 Type* const input_type = NodeProperties::GetType(input); | 193 Type* const input_type = NodeProperties::GetType(input); |
194 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { | 194 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { |
195 return Replace(input); | 195 return Replace(input); |
196 } | 196 } |
197 if (input_type->Is(Type::PlainNumber()) && | 197 if (input_type->Is(Type::PlainNumber()) && |
198 input->opcode() == IrOpcode::kNumberDivide) { | 198 (input->opcode() == IrOpcode::kNumberDivide || |
| 199 input->opcode() == IrOpcode::kSpeculativeNumberDivide)) { |
199 Node* const lhs = NodeProperties::GetValueInput(input, 0); | 200 Node* const lhs = NodeProperties::GetValueInput(input, 0); |
200 Type* const lhs_type = NodeProperties::GetType(lhs); | 201 Type* const lhs_type = NodeProperties::GetType(lhs); |
201 Node* const rhs = NodeProperties::GetValueInput(input, 1); | 202 Node* const rhs = NodeProperties::GetValueInput(input, 1); |
202 Type* const rhs_type = NodeProperties::GetType(rhs); | 203 Type* const rhs_type = NodeProperties::GetType(rhs); |
203 if (lhs_type->Is(Type::Unsigned32()) && rhs_type->Is(Type::Unsigned32())) { | 204 if (lhs_type->Is(Type::Unsigned32()) && rhs_type->Is(Type::Unsigned32())) { |
204 // We can replace | 205 // We can replace |
205 // | 206 // |
206 // NumberFloor(NumberDivide(lhs: unsigned32, | 207 // NumberFloor(NumberDivide(lhs: unsigned32, |
207 // rhs: unsigned32)): plain-number | 208 // rhs: unsigned32)): plain-number |
208 // | 209 // |
209 // with | 210 // with |
210 // | 211 // |
211 // NumberToUint32(NumberDivide(lhs, rhs)) | 212 // NumberToUint32(NumberDivide(lhs, rhs)) |
212 // | 213 // |
213 // and just smash the type of the {lhs} on the {node}, | 214 // and just smash the type of the {lhs} on the {node}, |
214 // as the truncated result must be in the same range as | 215 // as the truncated result must be in the same range as |
215 // {lhs} since {rhs} cannot be less than 1 (due to the | 216 // {lhs} since {rhs} cannot be less than 1 (due to the |
216 // plain-number type constraint on the {node}). | 217 // plain-number type constraint on the {node}). |
217 NodeProperties::ChangeOp(node, simplified()->NumberToUint32()); | 218 NodeProperties::ChangeOp(node, simplified()->NumberToUint32()); |
218 NodeProperties::SetType(node, lhs_type); | 219 NodeProperties::SetType(node, lhs_type); |
219 return Changed(node); | 220 return Changed(node); |
220 } | 221 } |
| 222 if (lhs_type->Is(Type::Signed32()) && rhs_type->Is(Type::Unsigned32())) { |
| 223 NodeProperties::ChangeOp(node, simplified()->NumberToInt32()); |
| 224 NodeProperties::SetType(node, lhs_type); |
| 225 return Changed(node); |
| 226 } |
221 } | 227 } |
222 return NoChange(); | 228 return NoChange(); |
223 } | 229 } |
224 | 230 |
225 Reduction TypedOptimization::ReduceNumberRoundop(Node* node) { | 231 Reduction TypedOptimization::ReduceNumberRoundop(Node* node) { |
226 Node* const input = NodeProperties::GetValueInput(node, 0); | 232 Node* const input = NodeProperties::GetValueInput(node, 0); |
227 Type* const input_type = NodeProperties::GetType(input); | 233 Type* const input_type = NodeProperties::GetType(input); |
228 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { | 234 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { |
229 return Replace(input); | 235 return Replace(input); |
230 } | 236 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 | 322 |
317 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } | 323 Isolate* TypedOptimization::isolate() const { return jsgraph()->isolate(); } |
318 | 324 |
319 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { | 325 SimplifiedOperatorBuilder* TypedOptimization::simplified() const { |
320 return jsgraph()->simplified(); | 326 return jsgraph()->simplified(); |
321 } | 327 } |
322 | 328 |
323 } // namespace compiler | 329 } // namespace compiler |
324 } // namespace internal | 330 } // namespace internal |
325 } // namespace v8 | 331 } // namespace v8 |
OLD | NEW |