Home | History | Annotate | Download | only in optimizing

Lines Matching defs:phi

51       // Both type propagation and redundant phi elimination ensure `int_operand`
64 HPhi* phi = it.Current()->AsPhi();
65 HPhi* next = phi->GetNextEquivalentPhiWithSameType();
67 // Make sure we do not replace a live phi with a dead phi. A live phi
68 // has been handled by the type propagation phase, unlike a dead phi.
70 phi->ReplaceWith(next);
71 phi->SetDead();
73 next->ReplaceWith(phi);
76 << "More then one phi equivalent with type " << phi->GetType()
77 << " found for phi" << phi->GetId();
86 HPhi* phi = it_phis.Current()->AsPhi();
87 // If the phi is not dead, or has no environment uses, there is nothing to do.
88 if (!phi->IsDead() || !phi->HasEnvironmentUses()) continue;
89 HInstruction* next = phi->GetNext();
90 if (!phi->IsVRegEquivalentOf(next)) continue;
92 // If the phi equivalent is dead, check if there is another one.
94 if (!phi->IsVRegEquivalentOf(next)) continue;
95 // There can be at most two phi equivalents.
96 DCHECK(!phi->IsVRegEquivalentOf(next->GetNext()));
99 // We found a live phi equivalent. Update the environment uses of `phi` with it.
100 phi->ReplaceWith(next);
107 // If `instruction` is a dead phi, type conflict was just identified. All its
108 // live phi users, and transitively users of those users, therefore need to be
122 // Find a candidate primitive type for `phi` by merging the type of its inputs.
124 static bool TypePhiFromInputs(HPhi* phi) {
125 Primitive::Type common_type = phi->GetType();
127 for (HInstruction* input : phi->GetInputs()) {
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();
171 for (HInstruction* input : phi->GetInputs()) {
179 HInputsRef inputs = phi->GetInputs();
183 // Input type does not match phi's type. Try to retype the input or
196 phi->ReplaceInput(equivalent, i);
202 // All inputs either matched the type of the phi or we successfully replaced
208 // Attempt to set the primitive type of `phi` to match its inputs. Return whether
210 bool SsaBuilder::UpdatePrimitiveType(HPhi* phi, ArenaVector<HPhi*>* worklist) {
211 DCHECK(phi->IsLive());
212 Primitive::Type original_type = phi->GetType();
214 // Try to type the phi in two stages:
215 // (1) find a candidate type for the phi by merging types of all its inputs,
216 // (2) try to type the phi's inputs to that candidate type.
219 if (!TypePhiFromInputs(phi) || !TypeInputsOfPhi(phi, worklist)) {
220 // Conflict detected. Mark the phi dead and return true because it changed.
221 phi->SetDead();
225 // Return true if the type of the phi has changed.
226 return phi->GetType() != original_type;
235 HPhi* phi = phi_it.Current()->AsPhi();
236 if (phi->IsLive()) {
237 worklist.push_back(phi);
242 // Eagerly compute the type of the phi, for quicker convergence. Note
244 // doing a reverse post-order visit, therefore either the phi users are
245 // non-loop phi and will be visited later in the visit, or are loop-phis,
247 HPhi* phi = phi_it.Current()->AsPhi();
248 if (phi->IsLive()) {
249 UpdatePrimitiveType(phi, &worklist);
262 HPhi* phi = worklist->back();
264 // The phi could have been made dead as a result of conflicts while in the
266 if (phi->IsLive() && UpdatePrimitiveType(phi, worklist)) {
267 AddDependentInstructionsToWorklist(phi, worklist);
311 // The wrong ArrayGet equivalent may still have Phi uses coming from ArraySet
346 // Replace the original int/long instruction. Note that it may have phi
382 // Returned equivalent is a phi which may not have had its inputs
481 // case, or float/double/reference if we created an equivalent phi. So we need
483 // conflict is detected in this stage, the phi is marked dead.
488 // otherwise we could get rid of phi equivalents, whose presence is a requirement
494 // We need to do this after redundant phi elimination, to ensure the only cases
495 // that we can see are reference comparison against 0. The redundant phi
496 // 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 HInputsRef inputs = phi->GetInputs();
620 new (allocator) HPhi(allocator, phi->GetRegNumber(), inputs.size(), type);
627 phi->GetBlock()->InsertPhiAfter(new_phi, phi);