mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-02 02:22:31 +00:00
Added a check so that if we have two machine instructions in this form
MOV R0, R1 MOV R1, R0 the second machine instruction is removed. Added a regression test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29792 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8ea5ecb056
commit
d36d03bf2d
@ -521,6 +521,7 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
|
|||||||
// Process all of the spilled uses and all non spilled reg references.
|
// Process all of the spilled uses and all non spilled reg references.
|
||||||
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
|
for (unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
|
||||||
MachineOperand &MO = MI.getOperand(i);
|
MachineOperand &MO = MI.getOperand(i);
|
||||||
|
|
||||||
if (!MO.isRegister() || MO.getReg() == 0)
|
if (!MO.isRegister() || MO.getReg() == 0)
|
||||||
continue; // Ignore non-register operands.
|
continue; // Ignore non-register operands.
|
||||||
|
|
||||||
@ -790,16 +791,37 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!OpTakenCareOf) {
|
if (!OpTakenCareOf) {
|
||||||
// Check to see if this is a noop copy. If so, eliminate the
|
|
||||||
// instruction before considering the dest reg to be changed.
|
|
||||||
unsigned Src, Dst;
|
unsigned Src, Dst;
|
||||||
if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) {
|
if (TII->isMoveInstr(MI, Src, Dst)) {
|
||||||
++NumDCE;
|
if (Src == Dst) {
|
||||||
DEBUG(std::cerr << "Removing now-noop copy: " << MI);
|
// Check to see if this is a noop copy. If so, eliminate
|
||||||
MBB.erase(&MI);
|
// the instruction before considering the dest reg to be
|
||||||
VRM.RemoveFromFoldedVirtMap(&MI);
|
// changed.
|
||||||
goto ProcessNextInst;
|
++NumDCE;
|
||||||
|
DEBUG(std::cerr << "Removing now-noop copy: " << MI);
|
||||||
|
MBB.erase(&MI);
|
||||||
|
VRM.RemoveFromFoldedVirtMap(&MI);
|
||||||
|
goto ProcessNextInst;
|
||||||
|
} else if (MII != MBB.begin()) {
|
||||||
|
// Check to see if this is a sequence of the form:
|
||||||
|
// mov R0, R1
|
||||||
|
// mov R1, R0
|
||||||
|
// Eliminate the second move if so.
|
||||||
|
MachineBasicBlock::iterator PrevMII = MII; --PrevMII;
|
||||||
|
MachineInstr& PrevMI = *PrevMII;
|
||||||
|
unsigned PrevSrc, PrevDst;
|
||||||
|
|
||||||
|
if (TII->isMoveInstr(PrevMI, PrevSrc, PrevDst))
|
||||||
|
if (PrevSrc == Dst && PrevDst == Src) {
|
||||||
|
++NumDCE;
|
||||||
|
DEBUG(std::cerr << "Removing now-noop copy: " << MI);
|
||||||
|
MBB.erase(&MI);
|
||||||
|
VRM.RemoveFromFoldedVirtMap(&MI);
|
||||||
|
goto ProcessNextInst;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spills.ClobberPhysReg(VirtReg);
|
Spills.ClobberPhysReg(VirtReg);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -861,8 +883,6 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
llvm::Spiller* llvm::createSpiller() {
|
llvm::Spiller* llvm::createSpiller() {
|
||||||
switch (SpillerOpt) {
|
switch (SpillerOpt) {
|
||||||
default: assert(0 && "Unreachable!");
|
default: assert(0 && "Unreachable!");
|
||||||
|
15
test/CodeGen/X86/2006-08-21-ExtraMovInst.ll
Normal file
15
test/CodeGen/X86/2006-08-21-ExtraMovInst.ll
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
; RUN: llvm-as < %s | llc -fast -march=x86 -mcpu=i386 | not grep 'movl %eax, %edx'
|
||||||
|
|
||||||
|
int %foo(int %t, int %C) {
|
||||||
|
entry:
|
||||||
|
br label %cond_true
|
||||||
|
|
||||||
|
cond_true: ; preds = %cond_true, %entry
|
||||||
|
%t_addr.0.0 = phi int [ %t, %entry ], [ %tmp7, %cond_true ] ; <int> [#uses=2]
|
||||||
|
%tmp7 = add int %t_addr.0.0, 1 ; <int> [#uses=1]
|
||||||
|
%tmp = setgt int %C, 39 ; <bool> [#uses=1]
|
||||||
|
br bool %tmp, label %bb12, label %cond_true
|
||||||
|
|
||||||
|
bb12: ; preds = %cond_true
|
||||||
|
ret int %t_addr.0.0
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user