OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 HValue* result = HBitNot::cast(value())->value(); | 1415 HValue* result = HBitNot::cast(value())->value(); |
1416 ASSERT(result->representation().IsInteger32()); | 1416 ASSERT(result->representation().IsInteger32()); |
1417 if (!result->CheckFlag(kUint32)) { | 1417 if (!result->CheckFlag(kUint32)) { |
1418 return result; | 1418 return result; |
1419 } | 1419 } |
1420 } | 1420 } |
1421 return this; | 1421 return this; |
1422 } | 1422 } |
1423 | 1423 |
1424 | 1424 |
1425 HValue* HAdd::Canonicalize() { | 1425 HValue* HArithmeticBinaryOperation::Canonicalize() { |
1426 if (!representation().IsInteger32()) return this; | 1426 if (representation().IsInteger32() && CheckUsesForFlag(kTruncatingToInt32)) { |
1427 if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow); | 1427 ClearFlag(kCanOverflow); |
| 1428 } |
1428 return this; | 1429 return this; |
1429 } | 1430 } |
1430 | 1431 |
1431 | 1432 |
1432 HValue* HSub::Canonicalize() { | |
1433 if (!representation().IsInteger32()) return this; | |
1434 if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow); | |
1435 return this; | |
1436 } | |
1437 | |
1438 | |
1439 // TODO(svenpanne) Use this in other Canonicalize() functions. | |
1440 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { | 1433 static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
1441 return arg1->representation().IsSpecialization() && | 1434 return arg1->representation().IsSpecialization() && |
1442 arg2->IsInteger32Constant() && | 1435 arg2->IsInteger32Constant() && |
1443 arg2->GetInteger32Constant() == identity; | 1436 arg2->GetInteger32Constant() == identity; |
1444 } | 1437 } |
1445 | 1438 |
1446 | 1439 |
| 1440 HValue* HAdd::Canonicalize() { |
| 1441 if (IsIdentityOperation(left(), right(), 0)) return left(); |
| 1442 if (IsIdentityOperation(right(), left(), 0)) return right(); |
| 1443 return HArithmeticBinaryOperation::Canonicalize(); |
| 1444 } |
| 1445 |
| 1446 |
| 1447 HValue* HSub::Canonicalize() { |
| 1448 if (IsIdentityOperation(left(), right(), 0)) return left(); |
| 1449 return HArithmeticBinaryOperation::Canonicalize(); |
| 1450 } |
| 1451 |
| 1452 |
1447 HValue* HMul::Canonicalize() { | 1453 HValue* HMul::Canonicalize() { |
1448 if (IsIdentityOperation(left(), right(), 1)) return left(); | 1454 if (IsIdentityOperation(left(), right(), 1)) return left(); |
1449 if (IsIdentityOperation(right(), left(), 1)) return right(); | 1455 if (IsIdentityOperation(right(), left(), 1)) return right(); |
1450 return this; | 1456 return HArithmeticBinaryOperation::Canonicalize(); |
1451 } | 1457 } |
1452 | 1458 |
1453 | 1459 |
1454 HValue* HChange::Canonicalize() { | 1460 HValue* HChange::Canonicalize() { |
1455 return (from().Equals(to())) ? value() : this; | 1461 return (from().Equals(to())) ? value() : this; |
1456 } | 1462 } |
1457 | 1463 |
1458 | 1464 |
1459 HValue* HWrapReceiver::Canonicalize() { | 1465 HValue* HWrapReceiver::Canonicalize() { |
1460 if (HasNoUses()) return NULL; | 1466 if (HasNoUses()) return NULL; |
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3585 | 3591 |
3586 | 3592 |
3587 void HCheckFunction::Verify() { | 3593 void HCheckFunction::Verify() { |
3588 HInstruction::Verify(); | 3594 HInstruction::Verify(); |
3589 ASSERT(HasNoUses()); | 3595 ASSERT(HasNoUses()); |
3590 } | 3596 } |
3591 | 3597 |
3592 #endif | 3598 #endif |
3593 | 3599 |
3594 } } // namespace v8::internal | 3600 } } // namespace v8::internal |
OLD | NEW |