summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-08-05 23:51:28 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-08-05 23:51:28 +0000
commitf67202c94d4eb2fab788196cab1ad138ea8e32cd (patch)
tree4eda04136090980b42f695f27bdd65974126d16f /lib
parentc910c8d2fa6e73e8f9875e871a2f3a44574a0b01 (diff)
downloadllvm-f67202c94d4eb2fab788196cab1ad138ea8e32cd.tar.gz
llvm-f67202c94d4eb2fab788196cab1ad138ea8e32cd.tar.bz2
llvm-f67202c94d4eb2fab788196cab1ad138ea8e32cd.tar.xz
Be more aggressive about removing joined physreg copies.
When a joined COPY changes subreg liveness, we keep it around as a KILL, otherwise it is safe to delete. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110403 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SimpleRegisterCoalescing.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp
index ff591832a3..fd6ffcecd1 100644
--- a/lib/CodeGen/SimpleRegisterCoalescing.cpp
+++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp
@@ -1726,7 +1726,8 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
bool DoDelete = true;
assert(MI->isCopyLike() && "Unrecognized copy instruction");
unsigned SrcReg = MI->getOperand(MI->isSubregToReg() ? 2 : 1).getReg();
- if (TargetRegisterInfo::isPhysicalRegister(SrcReg))
+ if (TargetRegisterInfo::isPhysicalRegister(SrcReg) &&
+ MI->getNumOperands() > 2)
// 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
@@ -1740,9 +1741,15 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
ShortenDeadCopyLiveRange(li, MI);
DoDelete = true;
}
- if (!DoDelete)
+ if (!DoDelete) {
+ // We need the instruction to adjust liveness, so make it a KILL.
+ if (MI->isSubregToReg()) {
+ MI->RemoveOperand(3);
+ MI->RemoveOperand(1);
+ }
+ MI->setDesc(tii_->get(TargetOpcode::KILL));
mii = llvm::next(mii);
- else {
+ } else {
li_->RemoveMachineInstrFromMaps(MI);
mii = mbbi->erase(mii);
++numPeep;