Do not delete identity insert_subreg even if dest is virtual. Let later passes delete them. This avoids register scavenger complain.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85045 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2009-10-25 07:48:51 +00:00
parent f5fe5e4e79
commit d66f0015ad

View File

@ -922,7 +922,7 @@ static void PropagateDeadness(LiveInterval &li, MachineInstr *CopyMI,
DefMI->getOperand(DeadIdx).setIsDead();
else
DefMI->addOperand(MachineOperand::CreateReg(li.reg,
true, true, false, true));
/*def*/true, /*implicit*/true, /*kill*/false, /*dead*/true));
LRStart = li_->getNextSlot(LRStart);
}
}
@ -1853,7 +1853,7 @@ bool SimpleRegisterCoalescing::RangeIsDefinedByCopyFromReg(LiveInterval &li,
tii_->isMoveInstr(*DefMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
DstReg == li.reg && SrcReg == Reg) {
// Cache computed info.
LR->valno->def = LR->start;
LR->valno->def = LR->start;
LR->valno->setCopy(DefMI);
return true;
}
@ -2006,7 +2006,7 @@ bool SimpleRegisterCoalescing::SimpleJoin(LiveInterval &LHS, LiveInterval &RHS){
// RHS into, update the value number info for the LHS to indicate that the
// value number is defined where the RHS value number was.
const VNInfo *VNI = RHS.getValNumInfo(0);
LHSValNo->def = VNI->def;
LHSValNo->def = VNI->def;
LHSValNo->setCopy(VNI->getCopy());
// Okay, the final step is to loop over the RHS live intervals, adding them to
@ -2489,8 +2489,7 @@ SimpleRegisterCoalescing::lastRegisterUse(LiveIndex Start,
MachineOperand &Use = I.getOperand();
MachineInstr *UseMI = Use.getParent();
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
if (tii_->isMoveInstr(*UseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
SrcReg == DstReg)
if (tii_->isIdentityCopy(*UseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx))
// Ignore identity copies.
continue;
LiveIndex Idx = li_->getInstructionIndex(UseMI);
@ -2516,8 +2515,7 @@ SimpleRegisterCoalescing::lastRegisterUse(LiveIndex Start,
// Ignore identity copies.
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
if (!(tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
SrcReg == DstReg))
if (!tii_->isIdentityCopy(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx))
for (unsigned i = 0, NumOps = MI->getNumOperands(); i != NumOps; ++i) {
MachineOperand &Use = MI->getOperand(i);
if (Use.isReg() && Use.isUse() && Use.getReg() &&
@ -2570,7 +2568,11 @@ void SimpleRegisterCoalescing::CalculateSpillWeights() {
for (MachineBasicBlock::const_iterator mii = MBB->begin(), mie = MBB->end();
mii != mie; ++mii) {
const MachineInstr *MI = mii;
if (tii_->isIdentityCopy(*MI))
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
if (tii_->isIdentityCopy(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx))
continue;
if (MI->getOpcode() == TargetInstrInfo::IMPLICIT_DEF)
continue;
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
@ -2601,8 +2603,7 @@ void SimpleRegisterCoalescing::CalculateSpillWeights() {
float Weight = li_->getSpillWeight(HasDef, HasUse, loopDepth);
if (HasDef && isExiting) {
// Looks like this is a loop count variable update.
LiveIndex DefIdx =
li_->getDefIndex(li_->getInstructionIndex(MI));
LiveIndex DefIdx = li_->getDefIndex(li_->getInstructionIndex(MI));
const LiveRange *DLR =
li_->getInterval(Reg).getLiveRangeContaining(DefIdx);
if (DLR->end > MBBEnd)
@ -2704,27 +2705,34 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
MI->getOpcode() == TargetInstrInfo::SUBREG_TO_REG) &&
"Unrecognized copy instruction");
DstReg = MI->getOperand(0).getReg();
// Do not delete subreg_to_reg, insert_subreg with undef source unless
// the definition is dead. e.g.
// %DO<def> = INSERT_SUBREG %D0<undef>, %S0<kill>, 1
// or else the scavenger may complain. These will be eliminated by the
// rewriter or the subreg lowering pass.
if (TargetRegisterInfo::isPhysicalRegister(DstReg))
// Do not delete extract_subreg, insert_subreg of physical
// registers unless the definition is dead. e.g.
// %DO<def> = INSERT_SUBREG %D0<undef>, %S0<kill>, 1
// or else the scavenger may complain. LowerSubregs will
// change this to an IMPLICIT_DEF later.
// Don't delete extract_subreg of a physical register.
DoDelete = false;
else if (MI->getOpcode() == TargetInstrInfo::SUBREG_TO_REG ||
(MI->getOpcode() == TargetInstrInfo::INSERT_SUBREG &&
MI->getOperand(1).isUndef()))
DoDelete = false;
}
if (MI->registerDefIsDead(DstReg)) {
LiveInterval &li = li_->getInterval(DstReg);
if (!ShortenDeadCopySrcLiveRange(li, MI))
ShortenDeadCopyLiveRange(li, MI);
DoDelete = true;
}
if (!DoDelete)
if (!DoDelete) {
mii = next(mii);
else {
} else {
li_->RemoveMachineInstrFromMaps(MI);
mii = mbbi->erase(mii);
++numPeep;
}
++numPeep;
continue;
}
@ -2762,8 +2770,7 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
}
// If the move will be an identity move delete it
bool isMove= tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx);
if (isMove && SrcReg == DstReg) {
if (tii_->isIdentityCopy(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx)) {
if (li_->hasInterval(SrcReg)) {
LiveInterval &RegInt = li_->getInterval(SrcReg);
// If def of this move instruction is dead, remove its live range