summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-02-13 08:41:08 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-02-13 08:41:08 +0000
commit8cc58728a8e662b3c1d1480dd939928ee00365a1 (patch)
tree0d800573b1cadb2b95261d643e0335a8be17a786 /llvm/lib
parent460648abde9b8a3b9435088906d248535fe78e03 (diff)
downloadbcm5719-llvm-8cc58728a8e662b3c1d1480dd939928ee00365a1.tar.gz
bcm5719-llvm-8cc58728a8e662b3c1d1480dd939928ee00365a1.zip
* Cannot safely commute an instruction there are other defs which can reach its uses.
* Ignore copy instructions which have already been coalesced. llvm-svn: 47056
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp b/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
index 94a94a1fe04..df5d3fa6f0d 100644
--- a/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
+++ b/llvm/lib/CodeGen/SimpleRegisterCoalescing.cpp
@@ -237,7 +237,9 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA,
// AValNo is the value number in A that defines the copy, A3 in the example.
LiveInterval::iterator ALR = IntA.FindLiveRangeContaining(CopyIdx-1);
VNInfo *AValNo = ALR->valno;
- if (AValNo->def == ~0U || AValNo->def == ~1U)
+ // If other defs can reach uses of this def, then it's not safe to perform
+ // the optimization.
+ if (AValNo->def == ~0U || AValNo->def == ~1U || AValNo->hasPHIKill)
return false;
MachineInstr *DefMI = li_->getInstructionFromIndex(AValNo->def);
const TargetInstrDesc &TID = DefMI->getDesc();
@@ -312,6 +314,8 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA,
MachineOperand &UseMO = UI.getOperand();
++UI;
MachineInstr *UseMI = UseMO.getParent();
+ if (JoinedCopies.count(UseMI))
+ continue;
unsigned UseIdx = li_->getInstructionIndex(UseMI);
LiveInterval::iterator ULR = IntA.FindLiveRangeContaining(UseIdx);
if (ULR->valno != AValNo)
OpenPOWER on IntegriCloud