summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-05-09 06:37:48 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-05-09 06:37:48 +0000
commitae450207204786385d19959ea87320bc99848129 (patch)
tree342ed76c4ce64488fc133678468ff6090cf80a67 /llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
parentf2925b3b2ce9e814db9253766e6f96b247a1a221 (diff)
downloadbcm5719-llvm-ae450207204786385d19959ea87320bc99848129.tar.gz
bcm5719-llvm-ae450207204786385d19959ea87320bc99848129.zip
PR 770 - permit coallescing of registers in subset register classes.
llvm-svn: 28197
Diffstat (limited to 'llvm/lib/CodeGen/LiveIntervalAnalysis.cpp')
-rw-r--r--llvm/lib/CodeGen/LiveIntervalAnalysis.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
index 17144f55822..946d80de6b4 100644
--- a/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -705,9 +705,12 @@ void LiveIntervals::joinIntervalsInMachineBB(MachineBasicBlock *MBB) {
MRegisterInfo::isPhysicalRegister(DestReg))
continue;
- // If they are not of the same register class, we cannot join them.
- if (differingRegisterClasses(SrcReg, DestReg))
+ // If they are not of compatible register classes, we cannot join them.
+ bool Swap = false;
+ if (!compatibleRegisterClasses(SrcReg, DestReg, Swap)) {
+ DEBUG(std::cerr << "Register classes aren't compatible!\n");
continue;
+ }
LiveInterval &SrcInt = getInterval(SrcReg);
LiveInterval &DestInt = getInterval(DestReg);
@@ -741,7 +744,7 @@ void LiveIntervals::joinIntervalsInMachineBB(MachineBasicBlock *MBB) {
DestInt.join(SrcInt, MIDefIdx);
DEBUG(std::cerr << "Joined. Result = " << DestInt << "\n");
- if (!MRegisterInfo::isPhysicalRegister(SrcReg)) {
+ if (!Swap && !MRegisterInfo::isPhysicalRegister(SrcReg)) {
r2iMap_.erase(SrcReg);
r2rMap_[SrcReg] = DestReg;
} else {
@@ -803,24 +806,33 @@ void LiveIntervals::joinIntervals() {
std::cerr << " reg " << i << " -> reg " << r2rMap_[i] << "\n");
}
-/// Return true if the two specified registers belong to different register
-/// classes. The registers may be either phys or virt regs.
-bool LiveIntervals::differingRegisterClasses(unsigned RegA,
- unsigned RegB) const {
+/// Return true if the two specified registers belong to same or compatible
+/// register classes. The registers may be either phys or virt regs.
+bool LiveIntervals::compatibleRegisterClasses(unsigned RegA, unsigned RegB,
+ bool &Swap) const {
// Get the register classes for the first reg.
if (MRegisterInfo::isPhysicalRegister(RegA)) {
assert(MRegisterInfo::isVirtualRegister(RegB) &&
"Shouldn't consider two physregs!");
- return !mf_->getSSARegMap()->getRegClass(RegB)->contains(RegA);
+ return mf_->getSSARegMap()->getRegClass(RegB)->contains(RegA);
}
// Compare against the regclass for the second reg.
- const TargetRegisterClass *RegClass = mf_->getSSARegMap()->getRegClass(RegA);
- if (MRegisterInfo::isVirtualRegister(RegB))
- return RegClass != mf_->getSSARegMap()->getRegClass(RegB);
- else
- return !RegClass->contains(RegB);
+ const TargetRegisterClass *RegClassA = mf_->getSSARegMap()->getRegClass(RegA);
+ if (MRegisterInfo::isVirtualRegister(RegB)) {
+ const TargetRegisterClass *RegClassB=mf_->getSSARegMap()->getRegClass(RegB);
+ if (RegClassA == RegClassB)
+ return true;
+ else {
+ if (RegClassB->hasSubRegClass(RegClassA)) {
+ Swap = true;
+ return true;
+ }
+ return RegClassA->hasSubRegClass(RegClassB);
+ }
+ } else
+ return RegClassA->contains(RegB);
}
bool LiveIntervals::overlapsAliases(const LiveInterval *LHS,
OpenPOWER on IntegriCloud