Do not replace a live phi with a dead phi.
A dead phi is not properly typed. Therefore, always use the live phi
equivalent instead.
bug:21865466
Change-Id: Id5e26ae4062cc18f5532d5b95cc024480652d5b2
diff --git a/compiler/optimizing/ssa_builder.cc b/compiler/optimizing/ssa_builder.cc
index 2a86e60..c37b199 100644
--- a/compiler/optimizing/ssa_builder.cc
+++ b/compiler/optimizing/ssa_builder.cc
@@ -213,7 +213,13 @@
HPhi* phi = it.Current()->AsPhi();
HPhi* next = phi->GetNextEquivalentPhiWithSameType();
if (next != nullptr) {
- phi->ReplaceWith(next);
+ // Make sure we do not replace a live phi with a dead phi. A live phi has been
+ // handled by the type propagation phase, unlike a dead phi.
+ if (next->IsLive()) {
+ phi->ReplaceWith(next);
+ } else {
+ next->ReplaceWith(phi);
+ }
DCHECK(next->GetNextEquivalentPhiWithSameType() == nullptr)
<< "More then one phi equivalent with type " << phi->GetType()
<< " found for phi" << phi->GetId();