| Index: src/hydrogen-instructions.cc
|
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
|
| index 0aabfbc43229198f181ec9f76d4aaf4724228f4f..71158cee12f1a5fcfb2bdd40a7e8096cbc9522f3 100644
|
| --- a/src/hydrogen-instructions.cc
|
| +++ b/src/hydrogen-instructions.cc
|
| @@ -1422,21 +1422,14 @@ HValue* HBitNot::Canonicalize() {
|
| }
|
|
|
|
|
| -HValue* HAdd::Canonicalize() {
|
| - if (!representation().IsInteger32()) return this;
|
| - if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow);
|
| - return this;
|
| -}
|
| -
|
| -
|
| -HValue* HSub::Canonicalize() {
|
| - if (!representation().IsInteger32()) return this;
|
| - if (CheckUsesForFlag(kTruncatingToInt32)) ClearFlag(kCanOverflow);
|
| +HValue* HArithmeticBinaryOperation::Canonicalize() {
|
| + if (representation().IsInteger32() && CheckUsesForFlag(kTruncatingToInt32)) {
|
| + ClearFlag(kCanOverflow);
|
| + }
|
| return this;
|
| }
|
|
|
|
|
| -// TODO(svenpanne) Use this in other Canonicalize() functions.
|
| static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) {
|
| return arg1->representation().IsSpecialization() &&
|
| arg2->IsInteger32Constant() &&
|
| @@ -1444,10 +1437,23 @@ static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) {
|
| }
|
|
|
|
|
| +HValue* HAdd::Canonicalize() {
|
| + if (IsIdentityOperation(left(), right(), 0)) return left();
|
| + if (IsIdentityOperation(right(), left(), 0)) return right();
|
| + return HArithmeticBinaryOperation::Canonicalize();
|
| +}
|
| +
|
| +
|
| +HValue* HSub::Canonicalize() {
|
| + if (IsIdentityOperation(left(), right(), 0)) return left();
|
| + return HArithmeticBinaryOperation::Canonicalize();
|
| +}
|
| +
|
| +
|
| HValue* HMul::Canonicalize() {
|
| if (IsIdentityOperation(left(), right(), 1)) return left();
|
| if (IsIdentityOperation(right(), left(), 1)) return right();
|
| - return this;
|
| + return HArithmeticBinaryOperation::Canonicalize();
|
| }
|
|
|
|
|
|
|