Lines Matching defs:phi

49       // Both type propagation and redundant phi elimination ensure `int_operand`
62 HPhi* phi = it.Current()->AsPhi();
63 HPhi* next = phi->GetNextEquivalentPhiWithSameType();
65 // Make sure we do not replace a live phi with a dead phi. A live phi
66 // has been handled by the type propagation phase, unlike a dead phi.
68 phi->ReplaceWith(next);
69 phi->SetDead();
71 next->ReplaceWith(phi);
74 << "More then one phi equivalent with type " << phi->GetType()
75 << " found for phi" << phi->GetId();
85 HPhi* phi = it_phis.Current()->AsPhi();
86 // If the phi is not dead, or has no environment uses, there is nothing to do.
87 if (!phi->IsDead() || !phi->HasEnvironmentUses()) continue;
88 HInstruction* next = phi->GetNext();
89 if (!phi->IsVRegEquivalentOf(next)) continue;
91 // If the phi equivalent is dead, check if there is another one.
93 if (!phi->IsVRegEquivalentOf(next)) continue;
94 // There can be at most two phi equivalents.
95 DCHECK(!phi->IsVRegEquivalentOf(next->GetNext()));
98 // We found a live phi equivalent. Update the environment uses of `phi` with it.
99 phi->ReplaceWith(next);
106 // If `instruction` is a dead phi, type conflict was just identified. All its
107 // live phi users, and transitively users of those users, therefore need to be
121 // Find a candidate primitive type for `phi` by merging the type of its inputs.
123 static bool TypePhiFromInputs(HPhi* phi) {
124 Primitive::Type common_type = phi->GetType();
126 for (HInputIterator it(phi); !it.Done(); it.Advance()) {
129 // Phis are constructed live so if an input is a dead phi, it must have
130 // been made dead due to type conflict. Mark this phi conflicting too.
158 // We have found a candidate type for the phi. Set it and return true. We may
160 phi->SetType(common_type);
164 // Replace inputs of `phi` to match its type. Return false if conflict is identified.
165 bool SsaBuilder::TypeInputsOfPhi(HPhi* phi, ArenaVector<HPhi*>* worklist) {
166 Primitive::Type common_type = phi->GetType();
172 for (size_t i = 0, e = phi->InputCount(); i < e; ++i) {
173 HInstruction* input = phi->InputAt(i);
186 for (size_t i = 0, e = phi->InputCount(); i < e; ++i) {
187 HInstruction* input = phi->InputAt(i);
189 // Input type does not match phi's type. Try to retype the input or
202 phi->ReplaceInput(equivalent, i);
208 // All inputs either matched the type of the phi or we successfully replaced
214 // Attempt to set the primitive type of `phi` to match its inputs. Return whether
216 bool SsaBuilder::UpdatePrimitiveType(HPhi* phi, ArenaVector<HPhi*>* worklist) {
217 DCHECK(phi->IsLive());
218 Primitive::Type original_type = phi->GetType();
220 // Try to type the phi in two stages:
221 // (1) find a candidate type for the phi by merging types of all its inputs,
222 // (2) try to type the phi's inputs to that candidate type.
225 if (!TypePhiFromInputs(phi) || !TypeInputsOfPhi(phi, worklist)) {
226 // Conflict detected. Mark the phi dead and return true because it changed.
227 phi->SetDead();
231 // Return true if the type of the phi has changed.
232 return phi->GetType() != original_type;
242 HPhi* phi = phi_it.Current()->AsPhi();
243 if (phi->IsLive()) {
244 worklist.push_back(phi);
249 // Eagerly compute the type of the phi, for quicker convergence. Note
251 // doing a reverse post-order visit, therefore either the phi users are
252 // non-loop phi and will be visited later in the visit, or are loop-phis,
254 HPhi* phi = phi_it.Current()->AsPhi();
255 if (phi->IsLive()) {
256 UpdatePrimitiveType(phi, &worklist);
269 HPhi* phi = worklist->back();
271 // The phi could have been made dead as a result of conflicts while in the
273 if (phi->IsLive() && UpdatePrimitiveType(phi, worklist)) {
274 AddDependentInstructionsToWorklist(phi, worklist);
353 // Replace the original int/long instruction. Note that it may have phi
389 // Returned equivalent is a phi which may not have had its inputs
485 // case, or float/double/reference if we created an equivalent phi. So we need
487 // conflict is detected in this stage, the phi is marked dead.
492 // otherwise we could get rid of phi equivalents, whose presence is a requirement
498 // We need to do this after redundant phi elimination, to ensure the only cases
499 // that we can see are reference comparison against 0. The redundant phi
500 // elimination ensures we do not see a phi taking two 0 constants in a HEqual
522 // 7) Make sure environments use the right phi equivalent: a phi marked dead
523 // can have a phi equivalent that is not dead. In that case we have to replace
596 * Because of Dex format, we might end up having the same phi being
600 * phi with a floating point / reference type.
602 HPhi* SsaBuilder::GetFloatDoubleOrReferenceEquivalentOfPhi(HPhi* phi, Primitive::Type type) {
603 DCHECK(phi->IsLive()) << "Cannot get equivalent of a dead phi since it would create a live one.";
605 // We place the floating point /reference phi next to this phi.
606 HInstruction* next = phi->GetNext();
608 && next->AsPhi()->GetRegNumber() == phi->GetRegNumber()
610 // Move to the next phi to see if it is the one we are looking for.
615 || (next->AsPhi()->GetRegNumber() != phi->GetRegNumber())
618 HPhi* new_phi = new (allocator) HPhi(allocator, phi->GetRegNumber(), phi->InputCount(), type);
619 for (size_t i = 0, e = phi->InputCount(); i < e; ++i) {
622 new_phi->SetRawInputAt(i, phi->InputAt(i));
624 phi->GetBlock()->InsertPhiAfter(new_phi, phi);