| Index: runtime/vm/intermediate_language.cc
|
| diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc
|
| index 59f0cb232b255b1a368a5c80c48d04b7e4fe768c..cdd9d7f7a85493b6f293ff03acbc281d79788488 100644
|
| --- a/runtime/vm/intermediate_language.cc
|
| +++ b/runtime/vm/intermediate_language.cc
|
| @@ -789,6 +789,18 @@ bool Instruction::IsDominatedBy(Instruction* dom) {
|
| }
|
|
|
|
|
| +bool Instruction::HasUnmatchedInputRepresentations() const {
|
| + for (intptr_t i = 0; i < InputCount(); i++) {
|
| + Definition* input = InputAt(i)->definition();
|
| + if (RequiredInputRepresentation(i) != input->representation()) {
|
| + return true;
|
| + }
|
| + }
|
| +
|
| + return false;
|
| +}
|
| +
|
| +
|
| void Definition::ReplaceWith(Definition* other,
|
| ForwardInstructionIterator* iterator) {
|
| // Record other's input uses.
|
| @@ -1994,7 +2006,7 @@ Definition* BoxInt64Instr::Canonicalize(FlowGraph* flow_graph) {
|
|
|
|
|
| Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) {
|
| - if (!HasUses()) return NULL;
|
| + if (!HasUses() && !CanDeoptimize()) return NULL;
|
|
|
| // Fold away Unbox<rep>(Box<rep>(v)).
|
| BoxInstr* box_defn = value()->definition()->AsBox();
|
| @@ -2250,19 +2262,12 @@ Instruction* BranchInstr::Canonicalize(FlowGraph* flow_graph) {
|
| return this;
|
| }
|
| ComparisonInstr* comp = replacement->AsComparison();
|
| - if ((comp == NULL) || comp->CanDeoptimize()) {
|
| + if ((comp == NULL) ||
|
| + comp->CanDeoptimize() ||
|
| + comp->HasUnmatchedInputRepresentations()) {
|
| return this;
|
| }
|
|
|
| - // Assert that the comparison is not serving as a pending deoptimization
|
| - // target for conversions.
|
| - for (intptr_t i = 0; i < comp->InputCount(); i++) {
|
| - if (comp->RequiredInputRepresentation(i) !=
|
| - comp->InputAt(i)->definition()->representation()) {
|
| - return this;
|
| - }
|
| - }
|
| -
|
| // Replace the comparison if the replacement is used at this branch,
|
| // and has exactly one use.
|
| Value* use = comp->input_use_list();
|
|
|