mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 21:24:00 +00:00
It's not safe eliminate copies where src and dst have different sub-register indices.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103450 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -46,7 +46,7 @@ bool ProcessImplicitDefs::CanTurnIntoImplicitDef(MachineInstr *MI,
|
|||||||
const TargetInstrInfo *tii_) {
|
const TargetInstrInfo *tii_) {
|
||||||
unsigned SrcReg, DstReg, SrcSubReg, DstSubReg;
|
unsigned SrcReg, DstReg, SrcSubReg, DstSubReg;
|
||||||
if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg) &&
|
if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg) &&
|
||||||
Reg == SrcReg)
|
Reg == SrcReg && SrcSubReg == 0 && DstSubReg == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (OpIdx == 2 && MI->isSubregToReg())
|
if (OpIdx == 2 && MI->isSubregToReg())
|
||||||
@ -220,7 +220,7 @@ bool ProcessImplicitDefs::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
// Turn a copy use into an implicit_def.
|
// Turn a copy use into an implicit_def.
|
||||||
unsigned SrcReg, DstReg, SrcSubReg, DstSubReg;
|
unsigned SrcReg, DstReg, SrcSubReg, DstSubReg;
|
||||||
if (tii_->isMoveInstr(*RMI, SrcReg, DstReg, SrcSubReg, DstSubReg) &&
|
if (tii_->isMoveInstr(*RMI, SrcReg, DstReg, SrcSubReg, DstSubReg) &&
|
||||||
Reg == SrcReg) {
|
Reg == SrcReg && SrcSubReg == 0 && DstSubReg == 0) {
|
||||||
RMI->setDesc(tii_->get(TargetOpcode::IMPLICIT_DEF));
|
RMI->setDesc(tii_->get(TargetOpcode::IMPLICIT_DEF));
|
||||||
|
|
||||||
bool isKill = false;
|
bool isKill = false;
|
||||||
|
@ -583,7 +583,8 @@ void RAFast::AllocateBasicBlock(MachineBasicBlock &MBB) {
|
|||||||
unsigned SrcCopyPhysReg = 0U;
|
unsigned SrcCopyPhysReg = 0U;
|
||||||
bool isCopy = TII->isMoveInstr(*MI, SrcCopyReg, DstCopyReg,
|
bool isCopy = TII->isMoveInstr(*MI, SrcCopyReg, DstCopyReg,
|
||||||
SrcCopySubReg, DstCopySubReg);
|
SrcCopySubReg, DstCopySubReg);
|
||||||
if (isCopy && TargetRegisterInfo::isVirtualRegister(SrcCopyReg))
|
if (isCopy && SrcCopySubReg == 0 && DstCopySubReg == 0 &&
|
||||||
|
TargetRegisterInfo::isVirtualRegister(SrcCopyReg))
|
||||||
SrcCopyPhysReg = getVirt2PhysRegMapSlot(SrcCopyReg);
|
SrcCopyPhysReg = getVirt2PhysRegMapSlot(SrcCopyReg);
|
||||||
|
|
||||||
// Loop over the implicit uses, making sure they don't get reallocated.
|
// Loop over the implicit uses, making sure they don't get reallocated.
|
||||||
|
@ -460,7 +460,7 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA,
|
|||||||
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
||||||
if (!tii_->isMoveInstr(*UseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx))
|
if (!tii_->isMoveInstr(*UseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx))
|
||||||
continue;
|
continue;
|
||||||
if (DstReg == IntB.reg) {
|
if (DstReg == IntB.reg && DstSubIdx == 0) {
|
||||||
// This copy will become a noop. If it's defining a new val#,
|
// This copy will become a noop. If it's defining a new val#,
|
||||||
// remove that val# as well. However this live range is being
|
// remove that val# as well. However this live range is being
|
||||||
// extended to the end of the existing live range defined by the copy.
|
// extended to the end of the existing live range defined by the copy.
|
||||||
@ -624,7 +624,7 @@ SimpleRegisterCoalescing::TrimLiveIntervalToLastUse(SlotIndex CopyIdx,
|
|||||||
LR->valno->addKill(LastUseIdx.getDefIndex());
|
LR->valno->addKill(LastUseIdx.getDefIndex());
|
||||||
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
||||||
if (tii_->isMoveInstr(*LastUseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
|
if (tii_->isMoveInstr(*LastUseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
|
||||||
DstReg == li.reg) {
|
DstReg == li.reg && DstSubIdx == 0) {
|
||||||
// Last use is itself an identity code.
|
// Last use is itself an identity code.
|
||||||
int DeadIdx = LastUseMI->findRegisterDefOperandIdx(li.reg, false, tri_);
|
int DeadIdx = LastUseMI->findRegisterDefOperandIdx(li.reg, false, tri_);
|
||||||
LastUseMI->getOperand(DeadIdx).setIsDead();
|
LastUseMI->getOperand(DeadIdx).setIsDead();
|
||||||
@ -810,6 +810,8 @@ SimpleRegisterCoalescing::UpdateRegDefsUses(unsigned SrcReg, unsigned DstReg,
|
|||||||
unsigned CopySrcReg, CopyDstReg, CopySrcSubIdx, CopyDstSubIdx;
|
unsigned CopySrcReg, CopyDstReg, CopySrcSubIdx, CopyDstSubIdx;
|
||||||
if (tii_->isMoveInstr(*UseMI, CopySrcReg, CopyDstReg,
|
if (tii_->isMoveInstr(*UseMI, CopySrcReg, CopyDstReg,
|
||||||
CopySrcSubIdx, CopyDstSubIdx) &&
|
CopySrcSubIdx, CopyDstSubIdx) &&
|
||||||
|
CopySrcSubIdx == 0 &&
|
||||||
|
CopyDstSubIdx == 0 &&
|
||||||
CopySrcReg != CopyDstReg &&
|
CopySrcReg != CopyDstReg &&
|
||||||
CopySrcReg == SrcReg && CopyDstReg != UseDstReg) {
|
CopySrcReg == SrcReg && CopyDstReg != UseDstReg) {
|
||||||
// If the use is a copy and it won't be coalesced away, and its source
|
// If the use is a copy and it won't be coalesced away, and its source
|
||||||
@ -2637,7 +2639,7 @@ SimpleRegisterCoalescing::lastRegisterUse(SlotIndex Start,
|
|||||||
MachineInstr *UseMI = Use.getParent();
|
MachineInstr *UseMI = Use.getParent();
|
||||||
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
||||||
if (tii_->isMoveInstr(*UseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
|
if (tii_->isMoveInstr(*UseMI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
|
||||||
SrcReg == DstReg)
|
SrcReg == DstReg && SrcSubIdx == DstSubIdx)
|
||||||
// Ignore identity copies.
|
// Ignore identity copies.
|
||||||
continue;
|
continue;
|
||||||
SlotIndex Idx = li_->getInstructionIndex(UseMI);
|
SlotIndex Idx = li_->getInstructionIndex(UseMI);
|
||||||
@ -2666,7 +2668,7 @@ SimpleRegisterCoalescing::lastRegisterUse(SlotIndex Start,
|
|||||||
// Ignore identity copies.
|
// Ignore identity copies.
|
||||||
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
unsigned SrcReg, DstReg, SrcSubIdx, DstSubIdx;
|
||||||
if (!(tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
|
if (!(tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx) &&
|
||||||
SrcReg == DstReg))
|
SrcReg == DstReg && SrcSubIdx == DstSubIdx))
|
||||||
for (unsigned i = 0, NumOps = MI->getNumOperands(); i != NumOps; ++i) {
|
for (unsigned i = 0, NumOps = MI->getNumOperands(); i != NumOps; ++i) {
|
||||||
MachineOperand &Use = MI->getOperand(i);
|
MachineOperand &Use = MI->getOperand(i);
|
||||||
if (Use.isReg() && Use.isUse() && Use.getReg() &&
|
if (Use.isReg() && Use.isUse() && Use.getReg() &&
|
||||||
@ -2797,7 +2799,7 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
|
|||||||
|
|
||||||
// If the move will be an identity move delete it
|
// If the move will be an identity move delete it
|
||||||
bool isMove= tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx);
|
bool isMove= tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubIdx, DstSubIdx);
|
||||||
if (isMove && SrcReg == DstReg) {
|
if (isMove && SrcReg == DstReg && SrcSubIdx == DstSubIdx) {
|
||||||
if (li_->hasInterval(SrcReg)) {
|
if (li_->hasInterval(SrcReg)) {
|
||||||
LiveInterval &RegInt = li_->getInterval(SrcReg);
|
LiveInterval &RegInt = li_->getInterval(SrcReg);
|
||||||
// If def of this move instruction is dead, remove its live range
|
// If def of this move instruction is dead, remove its live range
|
||||||
|
@ -2425,7 +2425,8 @@ LocalRewriter::RewriteMBB(LiveIntervals *LIs,
|
|||||||
// eliminate this or else the undef marker is lost and it will
|
// eliminate this or else the undef marker is lost and it will
|
||||||
// confuses the scavenger. This is extremely rare.
|
// confuses the scavenger. This is extremely rare.
|
||||||
unsigned Src, Dst, SrcSR, DstSR;
|
unsigned Src, Dst, SrcSR, DstSR;
|
||||||
if (TII->isMoveInstr(MI, Src, Dst, SrcSR, DstSR) && Src == Dst &&
|
if (TII->isMoveInstr(MI, Src, Dst, SrcSR, DstSR) &&
|
||||||
|
Src == Dst && SrcSR == DstSR &&
|
||||||
!MI.findRegisterUseOperand(Src)->isUndef()) {
|
!MI.findRegisterUseOperand(Src)->isUndef()) {
|
||||||
++NumDCE;
|
++NumDCE;
|
||||||
DEBUG(dbgs() << "Removing now-noop copy: " << MI);
|
DEBUG(dbgs() << "Removing now-noop copy: " << MI);
|
||||||
@ -2514,7 +2515,8 @@ LocalRewriter::RewriteMBB(LiveIntervals *LIs,
|
|||||||
// instruction before considering the dest reg to be changed.
|
// instruction before considering the dest reg to be changed.
|
||||||
{
|
{
|
||||||
unsigned Src, Dst, SrcSR, DstSR;
|
unsigned Src, Dst, SrcSR, DstSR;
|
||||||
if (TII->isMoveInstr(MI, Src, Dst, SrcSR, DstSR) && Src == Dst) {
|
if (TII->isMoveInstr(MI, Src, Dst, SrcSR, DstSR) &&
|
||||||
|
Src == Dst && SrcSR == DstSR) {
|
||||||
++NumDCE;
|
++NumDCE;
|
||||||
DEBUG(dbgs() << "Removing now-noop copy: " << MI);
|
DEBUG(dbgs() << "Removing now-noop copy: " << MI);
|
||||||
InvalidateKills(MI, TRI, RegKills, KillOps);
|
InvalidateKills(MI, TRI, RegKills, KillOps);
|
||||||
|
Reference in New Issue
Block a user