Chromium Code Reviews| Index: src/hydrogen.cc |
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
| index 6cb2b240a95b61103609b49d4f2532282985591d..4a99aa90b76e98d13daada80238b42f68d001bff 100644 |
| --- a/src/hydrogen.cc |
| +++ b/src/hydrogen.cc |
| @@ -485,6 +485,11 @@ HConstant* HGraph::GetConstant(SetOncePointer<HConstant>* pointer, |
| } |
| +HConstant* HGraph::GetConstant0() { |
| + return GetConstant(&constant_0_, Smi::FromInt(0)); |
| +} |
| + |
| + |
| HConstant* HGraph::GetConstant1() { |
| return GetConstant(&constant_1_, Smi::FromInt(1)); |
| } |
| @@ -4519,7 +4524,7 @@ void HGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { |
| VisitForEffect(expr->expression()); |
| } |
| - } else if (op == Token::BIT_NOT || op == Token::SUB) { |
| + } else if (op == Token::BIT_NOT || op == Token::SUB || op == Token::ADD) { |
| VISIT_FOR_VALUE(expr->expression()); |
| HValue* value = Pop(); |
| HInstruction* instr = NULL; |
| @@ -4528,8 +4533,10 @@ void HGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { |
| instr = new HBitNot(value); |
| break; |
| case Token::SUB: |
| - instr = new HMul(graph_->GetConstantMinus1(), value); |
| + instr = new HSub(graph_->GetConstant0(), value); |
|
Kevin Millikin (Chromium)
2011/03/14 14:18:46
I'm suspicious of this case. Isn't it true that:
Lasse Reichstein
2011/03/15 12:18:33
Argh, foiled again by -0.
Yes, you are correct.
In
|
| break; |
| + case Token::ADD: |
| + instr = new HSub(value, graph_->GetConstant0()); |
|
Kevin Millikin (Chromium)
2011/03/14 14:18:46
I'm also suspicious of this:
+(-0) = 0-(-0) = 0+0
Lasse Reichstein
2011/03/15 12:18:33
Agree, that's bad too.
|
| default: |
| UNREACHABLE(); |
| break; |