| Index: src/hydrogen-instructions.cc
|
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
|
| index e4599e1e83d88c2b8a9e05e3f846fd6a9a2b5fb0..4d318f19f5b24a33cde024f17f1aabed6dfbbcf7 100644
|
| --- a/src/hydrogen-instructions.cc
|
| +++ b/src/hydrogen-instructions.cc
|
| @@ -1206,8 +1206,15 @@ 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();
|
| + // Adding 0 is an identity operation except in case of -0: -0 + 0 = +0
|
| + if (IsIdentityOperation(left(), right(), 0) &&
|
| + !left()->representation().IsDouble()) { // Left could be -0.
|
| + return left();
|
| + }
|
| + if (IsIdentityOperation(right(), left(), 0) &&
|
| + !left()->representation().IsDouble()) { // Right could be -0.
|
| + return right();
|
| + }
|
| return this;
|
| }
|
|
|
|
|