aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/StrongPHIElimination.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-07-30 18:27:35 +0000
committerOwen Anderson <resistor@mac.com>2008-07-30 18:27:35 +0000
commitd723f722b2457dd847ece84f9cfa7cfae33f9bb0 (patch)
treeaea27b5be20921cb82c83c5c2394f013b9f0338b /lib/CodeGen/StrongPHIElimination.cpp
parent10535024867e7aab23daae2ffbc230938ab73278 (diff)
downloadexternal_llvm-d723f722b2457dd847ece84f9cfa7cfae33f9bb0.zip
external_llvm-d723f722b2457dd847ece84f9cfa7cfae33f9bb0.tar.gz
external_llvm-d723f722b2457dd847ece84f9cfa7cfae33f9bb0.tar.bz2
Use existing LiveInterval methods to simplify live interval merging. Thanks to Evan for pointing these out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54225 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/StrongPHIElimination.cpp')
-rw-r--r--lib/CodeGen/StrongPHIElimination.cpp63
1 files changed, 32 insertions, 31 deletions
diff --git a/lib/CodeGen/StrongPHIElimination.cpp b/lib/CodeGen/StrongPHIElimination.cpp
index 0f1acc2..b04a879 100644
--- a/lib/CodeGen/StrongPHIElimination.cpp
+++ b/lib/CodeGen/StrongPHIElimination.cpp
@@ -802,38 +802,39 @@ void StrongPHIElimination::mergeLiveIntervals(unsigned primary,
DenseMap<VNInfo*, VNInfo*> VNMap;
VNMap.insert(std::make_pair(RangeMergingIn->valno, NewVN));
- bool changed = true;
- while (changed) {
- changed = false;
- for (LiveInterval::iterator RI = RHS.begin(), RE = RHS.end();
- RI != RE; )
- if (MergedVNs.count(RI->valno)) {
- NewVN->hasPHIKill = true;
- LiveRange NewRange(RI->start, RI->end, VNMap[RI->valno]);
- LHS.addRange(NewRange);
+ // Find all VNs that are the inputs to two-address instructiosn
+ // chaining upwards from the VN we're trying to merge.
+ bool addedVN = true;
+ while (addedVN) {
+ addedVN = false;
+ unsigned defIndex = RHSVN->def;
+
+ if (defIndex != ~0U) {
+ MachineInstr* instr = LI.getInstructionFromIndex(defIndex);
- MachineInstr* instr = LI.getInstructionFromIndex(RI->start);
- for (unsigned i = 0; i < instr->getNumOperands(); ++i) {
- if (instr->getOperand(i).isReg() &&
- instr->getOperand(i).getReg() == secondary)
- if (instr->isRegReDefinedByTwoAddr(secondary, i)) {
- VNInfo* twoaddr = RHS.getLiveRangeContaining(RI->start-1)->valno;
- MergedVNs.insert(twoaddr);
-
- VNInfo* NextVN = LHS.getNextValue(twoaddr->def,
- twoaddr->copy,
- LI.getVNInfoAllocator());
- VNMap.insert(std::make_pair(twoaddr, NextVN));
- }
- }
-
- unsigned start = RI->start;
- unsigned end = RI->end;
- ++RI;
- RHS.removeRange(start, end, true);
- changed = true;
- } else
- ++RI;
+ for (unsigned i = 0; i < instr->getNumOperands(); ++i) {
+ if (instr->getOperand(i).isReg() &&
+ instr->getOperand(i).getReg() == secondary)
+ if (instr->isRegReDefinedByTwoAddr(secondary, i)) {
+ RHSVN = RHS.getLiveRangeContaining(defIndex-1)->valno;
+ addedVN = true;
+
+ VNInfo* NextVN = LHS.getNextValue(RHSVN->def,
+ RHSVN->copy,
+ LI.getVNInfoAllocator());
+ VNMap.insert(std::make_pair(RHSVN, NextVN));
+
+ break;
+ }
+ }
+ }
+ }
+
+ // Merge VNs from RHS into LHS using the mapping we computed above.
+ for (DenseMap<VNInfo*, VNInfo*>::iterator VI = VNMap.begin(),
+ VE = VNMap.end(); VI != VE; ++VI) {
+ LHS.MergeValueInAsValue(RHS, VI->first, VI->second);
+ RHS.removeValNo(VI->first);
}
if (RHS.begin() == RHS.end())