| Index: src/hydrogen-instructions.cc
|
| diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
|
| index d6710a4fa1f43b9311f416c5e5604c46f4322832..5f0cd9d3176e1327269cc5bdfdd6e47cba7372b5 100644
|
| --- a/src/hydrogen-instructions.cc
|
| +++ b/src/hydrogen-instructions.cc
|
| @@ -2264,7 +2264,8 @@ Representation HBinaryOperation::RepresentationFromInputs() {
|
|
|
|
|
| void HBinaryOperation::AssumeRepresentation(Representation r) {
|
| - set_observed_input_representation(r, r);
|
| + set_observed_input_representation(1, r);
|
| + set_observed_input_representation(2, r);
|
| HValue::AssumeRepresentation(r);
|
| }
|
|
|
| @@ -3462,6 +3463,42 @@ void HBitwise::PrintDataTo(StringStream* stream) {
|
| }
|
|
|
|
|
| +void HPhi::SimplifyConstantInputs() {
|
| + // Convert constant inputs to integers when all uses are truncating.
|
| + // This must happen before representation inference takes place.
|
| + if (!CheckUsesForFlag(kTruncatingToInt32)) return;
|
| + for (int i = 0; i < OperandCount(); ++i) {
|
| + if (!OperandAt(i)->IsConstant()) return;
|
| + }
|
| + HGraph* graph = block()->graph();
|
| + for (int i = 0; i < OperandCount(); ++i) {
|
| + HConstant* operand = HConstant::cast(OperandAt(i));
|
| + if (operand->HasInteger32Value()) {
|
| + continue;
|
| + } else if (operand->HasDoubleValue()) {
|
| + HConstant* integer_input =
|
| + new(graph->zone()) HConstant(DoubleToInt32(operand->DoubleValue()),
|
| + Representation::Integer32());
|
| + integer_input->InsertAfter(operand);
|
| + SetOperandAt(i, integer_input);
|
| + } else if (operand == graph->GetConstantTrue()) {
|
| + SetOperandAt(i, graph->GetConstant1());
|
| + } else {
|
| + // This catches |false|, |undefined|, strings and objects.
|
| + SetOperandAt(i, graph->GetConstant0());
|
| + }
|
| + }
|
| + // Overwrite observed input representations because they are likely Tagged.
|
| + for (HUseIterator it(uses()); !it.Done(); it.Advance()) {
|
| + HValue* use = it.value();
|
| + if (use->IsBinaryOperation()) {
|
| + HBinaryOperation::cast(use)->set_observed_input_representation(
|
| + it.index(), Representation::Integer32());
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| void HPhi::InferRepresentation(HInferRepresentation* h_infer) {
|
| ASSERT(CheckFlag(kFlexibleRepresentation));
|
| // If there are non-Phi uses, and all of them have observed the same
|
|
|