Chromium Code Reviews| Index: src/hydrogen-instructions.cc |
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc |
| index c47351d1aafa3c4a7856a40dbfeda4cb1e3a9f32..a7ecb6ca40047f4564a27718fe159a548f3cdc63 100644 |
| --- a/src/hydrogen-instructions.cc |
| +++ b/src/hydrogen-instructions.cc |
| @@ -1269,6 +1269,26 @@ HValue* HBitwise::Canonicalize() { |
| } |
| +Representation HAdd::RepresentationFromInputs() { |
| + Representation left_rep = left()->representation(); |
| + if (left_rep.IsExternal()) { |
| + return Representation::External(); |
| + } |
| + return HArithmeticBinaryOperation::RepresentationFromInputs(); |
| +} |
| + |
| + |
| +Representation HAdd::RequiredInputRepresentation(int index) { |
| + if (index == 2) { |
| + Representation left_rep = left()->representation(); |
| + if (left_rep.IsExternal()) { |
| + return Representation::Integer32(); |
| + } |
| + } |
| + return HArithmeticBinaryOperation::RequiredInputRepresentation(index); |
| +} |
| + |
| + |
| static bool IsIdentityOperation(HValue* arg1, HValue* arg2, int32_t identity) { |
| return arg1->representation().IsSpecialization() && |
| arg2->EqualsInteger32Constant(identity); |
| @@ -3756,13 +3776,37 @@ HInstruction* HInstr::New( \ |
| } |
| -DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HAdd, +) |
| DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HMul, *) |
| DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR(HSub, -) |
| #undef DEFINE_NEW_H_SIMPLE_ARITHMETIC_INSTR |
| +HInstruction* HAdd::New( |
| + Zone* zone, HValue* context, HValue* left, HValue* right, |
| + Representation forced_representation) { |
| + if (!forced_representation.IsNone()) { |
|
Dmitry Lomov (no reviews)
2013/11/19 09:42:04
I am not entirely convinced this is a good change.
danno
2013/11/20 09:45:25
I see your point, but I also really don't like the
|
| + HAdd* result = new(zone) HAdd(context, left, right); |
| + |
| + result->set_observed_input_representation(1, forced_representation); |
| + result->initialize_output_representation(forced_representation); |
| + return result; |
| + } |
| + if (FLAG_fold_constants && left->IsConstant() && right->IsConstant()) { |
| + HConstant* c_left = HConstant::cast(left); |
| + HConstant* c_right = HConstant::cast(right); |
| + if ((c_left->HasNumberValue() && c_right->HasNumberValue())) { |
| + double double_res = c_left->DoubleValue() + c_right->DoubleValue(); |
| + if (TypeInfo::IsInt32Double(double_res)) { |
| + return H_CONSTANT_INT(double_res); |
| + } |
| + return H_CONSTANT_DOUBLE(double_res); |
| + } |
| + } |
| + return new(zone) HAdd(context, left, right); |
| +} |
| + |
| + |
| HInstruction* HStringAdd::New(Zone* zone, |
| HValue* context, |
| HValue* left, |