Chromium Code Reviews| Index: src/hydrogen-instructions.cc |
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
| index 60a6912654fe50b3533a470a1df8a540d145b37d..da6820ce67eb1966cab0d4eefe454c2324d9182d 100644 |
| --- a/src/hydrogen-instructions.cc |
| +++ b/src/hydrogen-instructions.cc |
| @@ -1436,6 +1436,20 @@ HValue* HSub::Canonicalize() { |
| } |
| +// TODO(svenpanne) Use this in other Canonicalize() functions. |
| +static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
| + return arg1->representation().IsSpecialization() && |
| + arg2->IsInteger32Constant() && |
| + arg2->GetInteger32Constant() == identity; |
| +} |
| + |
|
Jakob Kummerow
2013/04/17 12:36:07
nit: two newlines between top-level blocks
|
| +HValue* HMul::Canonicalize() { |
| + if (IsIdentityOperation(left(), right(), 1)) return left(); |
| + if (IsIdentityOperation(right(), left(), 1)) return right(); |
| + return this; |
| +} |
| + |
| + |
| HValue* HChange::Canonicalize() { |
| return (from().Equals(to())) ? value() : this; |
| } |