- // Check for trivial interferences
- if (isLiveIn(SrcInfo, P->getParent()) ||
- isLiveOut(PHIInfo, SrcInfo.DefInst->getParent()) ||
- ( PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI &&
- isLiveIn(PHIInfo, SrcInfo.DefInst->getParent()) ) ||
+ // Check for trivial interferences via liveness information, allowing us
+ // to avoid extra work later. Any registers that interfere cannot both
+ // be in the renaming set, so choose one and add copies for it instead.
+ // The conditions are:
+ // 1) if the operand is live into the PHI node's block OR
+ // 2) if the PHI node is live out of the operand's defining block OR
+ // 3) if the operand is itself a PHI node and the original PHI is
+ // live into the operand's defining block OR
+ // 4) if the operand is already being renamed for another PHI node
+ // in this block OR
+ // 5) if any two operands are defined in the same block, insert copies
+ // for one of them
+ if (isLiveIn(SrcReg, P->getParent(), MRI, LV) ||
+ isLiveOut(P->getOperand(0).getReg(),
+ MRI.getVRegDef(SrcReg)->getParent(), MRI, LV) ||
+ ( MRI.getVRegDef(SrcReg)->getOpcode() == TargetInstrInfo::PHI &&
+ isLiveIn(P->getOperand(0).getReg(),
+ MRI.getVRegDef(SrcReg)->getParent(), MRI, LV) ) ||