diff options
| author | 2015-04-14 15:11:57 +0100 | |
|---|---|---|
| committer | 2015-04-14 15:59:12 +0100 | |
| commit | 5f4886aad49b48cdc6945e3094549145c0914fe8 (patch) | |
| tree | 792a11dfdd9f943017b575e99557da36e5bc43bd /compiler/optimizing | |
| parent | e015a31e509c3f4de8a90b57b77329ba6609ce2f (diff) | |
Fix a bug in type propagation.
If a phi requests its inputs to be of a certain type, the inputs need
to propagate that type to their users, as those users might be
phis.
Bug report and test courtesy of Serguei I Katkov.
Change-Id: I79baac271566ec4fa684c1edf11a1b3383d896a9
Diffstat (limited to 'compiler/optimizing')
| -rw-r--r-- | compiler/optimizing/primitive_type_propagation.cc | 8 | ||||
| -rw-r--r-- | compiler/optimizing/primitive_type_propagation.h | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/optimizing/primitive_type_propagation.cc b/compiler/optimizing/primitive_type_propagation.cc index c20c8a172d..af93438c9a 100644 --- a/compiler/optimizing/primitive_type_propagation.cc +++ b/compiler/optimizing/primitive_type_propagation.cc @@ -65,6 +65,10 @@ bool PrimitiveTypePropagation::UpdateType(HPhi* phi) { if (equivalent->IsPhi()) { equivalent->AsPhi()->SetLive(); AddToWorklist(equivalent->AsPhi()); + } else if (equivalent == input) { + // The input has changed its type. It can be an input of other phis, + // so we need to put phi users in the work list. + AddDependentInstructionsToWorklist(equivalent); } } } @@ -117,10 +121,10 @@ void PrimitiveTypePropagation::AddToWorklist(HPhi* instruction) { worklist_.Add(instruction); } -void PrimitiveTypePropagation::AddDependentInstructionsToWorklist(HPhi* instruction) { +void PrimitiveTypePropagation::AddDependentInstructionsToWorklist(HInstruction* instruction) { for (HUseIterator<HInstruction*> it(instruction->GetUses()); !it.Done(); it.Advance()) { HPhi* phi = it.Current()->GetUser()->AsPhi(); - if (phi != nullptr && phi->IsLive()) { + if (phi != nullptr && phi->IsLive() && phi->GetType() != instruction->GetType()) { AddToWorklist(phi); } } diff --git a/compiler/optimizing/primitive_type_propagation.h b/compiler/optimizing/primitive_type_propagation.h index 1374cbb6ab..6d370ed2ab 100644 --- a/compiler/optimizing/primitive_type_propagation.h +++ b/compiler/optimizing/primitive_type_propagation.h @@ -33,7 +33,7 @@ class PrimitiveTypePropagation : public ValueObject { void VisitBasicBlock(HBasicBlock* block); void ProcessWorklist(); void AddToWorklist(HPhi* phi); - void AddDependentInstructionsToWorklist(HPhi* phi); + void AddDependentInstructionsToWorklist(HInstruction* instruction); bool UpdateType(HPhi* phi); HGraph* const graph_; |