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/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // only tagged uses. | 317 // only tagged uses. |
318 return kRepTagged; | 318 return kRepTagged; |
319 } else if (upper->Is(Type::Integral32())) { | 319 } else if (upper->Is(Type::Integral32())) { |
320 // Integer within [-2^31, 2^32[ range. | 320 // Integer within [-2^31, 2^32[ range. |
321 if ((use & kRepMask) == kRepFloat64) { | 321 if ((use & kRepMask) == kRepFloat64) { |
322 // only float64 uses. | 322 // only float64 uses. |
323 return kRepFloat64; | 323 return kRepFloat64; |
324 } else if (upper->Is(Type::Signed32()) || upper->Is(Type::Unsigned32())) { | 324 } else if (upper->Is(Type::Signed32()) || upper->Is(Type::Unsigned32())) { |
325 // multiple uses, but we are within 32 bits range => pick kRepWord32. | 325 // multiple uses, but we are within 32 bits range => pick kRepWord32. |
326 return kRepWord32; | 326 return kRepWord32; |
327 } else if ((use & kRepMask) == kRepWord32 || | 327 } else if (((use & kRepMask) == kRepWord32 && |
| 328 !CanObserveNonWord32(use)) || |
328 (use & kTypeMask) == kTypeInt32 || | 329 (use & kTypeMask) == kTypeInt32 || |
329 (use & kTypeMask) == kTypeUint32) { | 330 (use & kTypeMask) == kTypeUint32) { |
330 // We only use 32 bits or we use the result consistently. | 331 // We only use 32 bits or we use the result consistently. |
331 return kRepWord32; | 332 return kRepWord32; |
332 } else { | 333 } else { |
333 return kRepFloat64; | 334 return kRepFloat64; |
334 } | 335 } |
335 } else if (upper->Is(Type::Boolean())) { | 336 } else if (upper->Is(Type::Boolean())) { |
336 // multiple uses => pick kRepBit. | 337 // multiple uses => pick kRepBit. |
337 return kRepBit; | 338 return kRepBit; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 bool CanLowerToUint32Binop(Node* node, MachineTypeUnion use) { | 445 bool CanLowerToUint32Binop(Node* node, MachineTypeUnion use) { |
445 return BothInputsAre(node, Type::Unsigned32()) && !CanObserveNonUint32(use); | 446 return BothInputsAre(node, Type::Unsigned32()) && !CanObserveNonUint32(use); |
446 } | 447 } |
447 | 448 |
448 bool CanLowerToUint32AdditiveBinop(Node* node, MachineTypeUnion use) { | 449 bool CanLowerToUint32AdditiveBinop(Node* node, MachineTypeUnion use) { |
449 return IsSafeIntAdditiveOperand(node->InputAt(0)) && | 450 return IsSafeIntAdditiveOperand(node->InputAt(0)) && |
450 IsSafeIntAdditiveOperand(node->InputAt(1)) && | 451 IsSafeIntAdditiveOperand(node->InputAt(1)) && |
451 !CanObserveNonUint32(use); | 452 !CanObserveNonUint32(use); |
452 } | 453 } |
453 | 454 |
| 455 bool CanObserveNonWord32(MachineTypeUnion use) { |
| 456 return (use & ~(kTypeUint32 | kTypeInt32)) != 0; |
| 457 } |
| 458 |
454 bool CanObserveNonInt32(MachineTypeUnion use) { | 459 bool CanObserveNonInt32(MachineTypeUnion use) { |
455 return (use & (kTypeUint32 | kTypeNumber | kTypeAny)) != 0; | 460 return (use & (kTypeUint32 | kTypeNumber | kTypeAny)) != 0; |
456 } | 461 } |
457 | 462 |
458 bool CanObserveMinusZero(MachineTypeUnion use) { | 463 bool CanObserveMinusZero(MachineTypeUnion use) { |
459 // TODO(turbofan): technically Uint32 cannot observe minus zero either. | 464 // TODO(turbofan): technically Uint32 cannot observe minus zero either. |
460 return (use & (kTypeUint32 | kTypeNumber | kTypeAny)) != 0; | 465 return (use & (kTypeUint32 | kTypeNumber | kTypeAny)) != 0; |
461 } | 466 } |
462 | 467 |
463 bool CanObserveNaN(MachineTypeUnion use) { | 468 bool CanObserveNaN(MachineTypeUnion use) { |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1573 | 1578 |
1574 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { | 1579 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { |
1575 node->set_op(machine()->IntLessThanOrEqual()); | 1580 node->set_op(machine()->IntLessThanOrEqual()); |
1576 node->ReplaceInput(0, StringComparison(node, true)); | 1581 node->ReplaceInput(0, StringComparison(node, true)); |
1577 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1582 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1578 } | 1583 } |
1579 | 1584 |
1580 } // namespace compiler | 1585 } // namespace compiler |
1581 } // namespace internal | 1586 } // namespace internal |
1582 } // namespace v8 | 1587 } // namespace v8 |
OLD | NEW |