Home | History | Annotate | Download | only in CodeGen

Lines Matching refs:PHI

1 //===- StrongPHIElimination.cpp - Eliminate PHI nodes by inserting copies -===//
10 // This pass eliminates PHI instructions by aggressively coalescing the copies
13 // registers appearing in a PHI instruction do not interfere. It then eliminates
72 /// PHI with that register as its destination has been isolated.
112 /// Get the color of a PHI. The color of a PHI is 0 if the PHI has been
117 /// Isolate a PHI.
135 // Lowers a PHI instruction, inserting copies of the source and destination
153 // Maps a basic block to a list of its defs of registers that appear as PHI
158 // is the operand of that PHI corresponding to the current basic block.
197 INITIALIZE_PASS_BEGIN(StrongPHIElimination, "strong-phi-node-elimination",
198 "Eliminate PHI nodes for register allocation, intelligently", false, false)
202 INITIALIZE_PASS_END(StrongPHIElimination, "strong-phi-node-elimination",
203 "Eliminate PHI nodes for register allocation, intelligently", false, false)
261 // interferences amongst PHI-congruence classes.
271 // Insert copies for all PHI source and destination registers.
304 MachineInstr *PHI = BBI;
306 assert(PHI->getNumOperands() > 0);
308 unsigned SrcReg = PHI->getOperand(1).getReg();
317 unsigned DestReg = PHI->getOperand(0).getReg();
321 for (unsigned i = 3; i < PHI->getNumOperands(); i += 2) {
322 unsigned SrcReg = PHI->getOperand(i).getReg();
327 LI->RemoveMachineInstrFromMaps(PHI);
328 PHI->eraseFromParent();
334 // guaranteed to not overlap, except in one case: an original PHI source and a
335 // PHI destination copy. In this case, they have the same value and thus don't
348 && "PHI destination copy's live interval should be a single live "
365 // Adjust the live intervals of all PHI source registers to handle the case
457 unsigned StrongPHIElimination::getPHIColor(MachineInstr *PHI) {
458 assert(PHI->isPHI());
460 unsigned DestReg = PHI->getOperand(0).getReg();
465 for (unsigned i = 1; i < PHI->getNumOperands(); i += 2) {
466 unsigned SrcColor = getRegColor(PHI->getOperand(i).getReg());
473 void StrongPHIElimination::isolatePHI(MachineInstr *PHI) {
474 assert(PHI->isPHI());
475 Node *Node = RegNodeMap[PHI->getOperand(0).getReg()];
545 // If the virtual register being defined is not used in any PHI or has
588 // is necessary because the use of a PHI's operands are logically contained in
589 // the predecessor block. The def of a PHI's destination register is processed
598 MachineInstr *PHI = BBI;
600 // If a PHI is already isolated, either by being isolated directly or
602 unsigned Color = getPHIColor(PHI);
606 // Find the index of the PHI operand that corresponds to this basic block.
608 for (PredIndex = 1; PredIndex < PHI->getNumOperands(); PredIndex += 2) {
609 if (PHI->getOperand(PredIndex + 1).getMBB() == &MBB)
612 assert(PredIndex < PHI->getNumOperands());
613 unsigned PredOperandReg = PHI->getOperand(PredIndex).getReg();
626 // register rather than the PHI. It is also possible to isolate the
627 // PHI, but that introduces copies for all of the registers involved
628 // in that PHI.
637 // they don't actually interfere. Otherwise, isolate the current PHI. This
638 // could possibly be improved, e.g. we could isolate the PHI with the
641 isolatePHI(PHI);
643 CurrentPHI = std::make_pair(PHI, PredOperandReg);
648 void StrongPHIElimination::InsertCopiesForPHI(MachineInstr *PHI,
650 assert(PHI->isPHI());
652 unsigned PHIColor = getPHIColor(PHI);
654 for (unsigned i = 1; i < PHI->getNumOperands(); i += 2) {
655 MachineOperand &SrcMO = PHI->getOperand(i);
664 "Machine PHI Operands must all be virtual registers!");
666 MachineBasicBlock *PredBB = PHI->getOperand(i + 1).getMBB();
669 // If neither the PHI nor the operand were isolated, then we only need to
670 // set the phi-kill flag on the VNInfo at this PHI.
697 PHI->getDebugLoc(),
724 // If SrcReg is not live beyond the PHI, trim its interval so that it is no
732 SlotIndex PHIIndex = LI->getInstructionIndex(PHI);
738 unsigned DestReg = PHI->getOperand(0).getReg();
744 // Set the phi-def flag for the VN at this PHI.
745 SlotIndex PHIIndex = LI->getInstructionIndex(PHI);
749 // Prior to PHI elimination, the live ranges of PHIs begin at their defining
750 // instruction. After PHI elimination, PHI instructions are replaced by VNs
751 // with the phi-def flag set, and the live ranges of these VNs start at the
766 PHI->getDebugLoc(),
770 PHI->getOperand(0).setReg(CopyReg);
787 SlotIndex PHIIndex = LI->getInstructionIndex(PHI);