- // If DestVirtReg already has a value, forget about it. Why doesn't
- // getReg do this right?
- std::map<unsigned, unsigned>::iterator DestI =
- Virt2PhysRegMap.find(DestVirtReg);
- if (DestI != Virt2PhysRegMap.end()) {
- unsigned PhysReg = DestI->second;
- Virt2PhysRegMap.erase(DestI);
- removePhysReg(PhysReg);
- }
-
- if (TM->getInstrInfo().isTwoAddrInstr(MI->getOpcode()) && i == 0) {
- // must be same register number as the first operand
- // This maps a = b + c into b += c, and saves b into a's spot
- assert(MI->getOperand(1).isRegister() &&
- MI->getOperand(1).getAllocatedRegNum() &&
- MI->getOperand(1).opIsUse() &&
- "Two address instruction invalid!");
- DestPhysReg = MI->getOperand(1).getAllocatedRegNum();
-
- liberatePhysReg(MBB, I, DestPhysReg);
- assignVirtToPhysReg(DestVirtReg, DestPhysReg);
- } else {
- DestPhysReg = getReg(MBB, I, DestVirtReg);
- }
+ // If DestVirtReg already has a value, use it.
+ if (!(DestPhysReg = getVirt2PhysRegMapSlot(DestVirtReg)))
+ DestPhysReg = getReg(MBB, MI, DestVirtReg);