Chromium Code Reviews| Index: src/hydrogen-instructions.cc |
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
| index 0aabfbc43229198f181ec9f76d4aaf4724228f4f..f1137f6360c21f6cabe5c5eb49e528156f199498 100644 |
| --- a/src/hydrogen-instructions.cc |
| +++ b/src/hydrogen-instructions.cc |
| @@ -648,6 +648,13 @@ int32_t HValue::GetInteger32Constant() { |
| } |
| +bool HValue::EqualsInteger32Constant(int32_t value) { |
| + return IsConstant() |
| + && HConstant::cast(this)->HasInteger32Value() |
| + && HConstant::cast(this)->Integer32Value() == value; |
|
Sven Panne
2013/04/18 09:46:23
Use a combination of IsInteger32Constant and GetIn
|
| +} |
| + |
| + |
| void HValue::SetOperandAt(int index, HValue* value) { |
| RegisterUse(index, value); |
| InternalSetOperandAt(index, value); |
| @@ -1393,15 +1400,11 @@ HValue* HBitwise::Canonicalize() { |
| if (!representation().IsInteger32()) return this; |
| // If x is an int32, then x & -1 == x, x | 0 == x and x ^ 0 == x. |
| int32_t nop_constant = (op() == Token::BIT_AND) ? -1 : 0; |
| - if (left()->IsConstant() && |
| - HConstant::cast(left())->HasInteger32Value() && |
| - HConstant::cast(left())->Integer32Value() == nop_constant && |
| + if (left()->EqualsInteger32Constant(nop_constant) && |
| !right()->CheckFlag(kUint32)) { |
| return right(); |
| } |
| - if (right()->IsConstant() && |
| - HConstant::cast(right())->HasInteger32Value() && |
| - HConstant::cast(right())->Integer32Value() == nop_constant && |
| + if (right()->EqualsInteger32Constant(nop_constant) && |
| !left()->CheckFlag(kUint32)) { |
| return left(); |
| } |
| @@ -1439,8 +1442,7 @@ 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; |
| + arg2->EqualsInteger32Constant(identity); |
| } |