diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-08-26 01:28:16 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-08-26 01:28:16 +0000 |
| commit | 122f2bcdc2f59c9abce31f41d166fefa930efb03 (patch) | |
| tree | 3c77367c7991337b330b70e9f108bf627355bf94 /llvm/lib/CodeGen/LiveInterval.cpp | |
| parent | ab8297f92da0311cdcd761f6ec39bdec03e35c9d (diff) | |
| download | bcm5719-llvm-122f2bcdc2f59c9abce31f41d166fefa930efb03.tar.gz bcm5719-llvm-122f2bcdc2f59c9abce31f41d166fefa930efb03.zip | |
Simplifications to liveinterval analysis, no functionality change.
llvm-svn: 29896
Diffstat (limited to 'llvm/lib/CodeGen/LiveInterval.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/LiveInterval.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp index 80c050ff330..7f16b318238 100644 --- a/llvm/lib/CodeGen/LiveInterval.cpp +++ b/llvm/lib/CodeGen/LiveInterval.cpp @@ -374,21 +374,25 @@ LiveInterval::FindLiveRangeContaining(unsigned Idx) { /// is the result of a copy instruction in the source program, that occurs at /// index 'CopyIdx' that copies from 'Other' to 'this'. void LiveInterval::join(LiveInterval &Other, unsigned CopyIdx) { - const LiveRange *SourceLR = Other.getLiveRangeContaining(CopyIdx-1); - const LiveRange *DestLR = getLiveRangeContaining(CopyIdx); - assert(SourceLR && DestLR && "Not joining due to a copy?"); - unsigned MergedSrcValIdx = SourceLR->ValId; - unsigned MergedDstValIdx = DestLR->ValId; - // Try to do the least amount of work possible. In particular, if there are // more liverange chunks in the other set than there are in the 'this' set, // swap sets to merge the fewest chunks in possible. - if (Other.ranges.size() > ranges.size()) { - std::swap(MergedSrcValIdx, MergedDstValIdx); - std::swap(ranges, Other.ranges); - std::swap(NumValues, Other.NumValues); - std::swap(InstDefiningValue, Other.InstDefiningValue); + // + // Also, if one range is a physreg and one is a vreg, we always merge from the + // vreg into the physreg, which leaves the vreg intervals pristine. + unsigned OtherOffs = 1, ThisOffs = 0; + if ((Other.ranges.size() > ranges.size() && + MRegisterInfo::isVirtualRegister(reg)) || + MRegisterInfo::isPhysicalRegister(Other.reg)) { + swap(Other); + std::swap(ThisOffs, OtherOffs); } + + const LiveRange *SourceLR = Other.getLiveRangeContaining(CopyIdx-OtherOffs); + const LiveRange *DestLR = getLiveRangeContaining(CopyIdx-ThisOffs); + assert(SourceLR && DestLR && "Not joining due to a copy?"); + unsigned MergedSrcValIdx = SourceLR->ValId; + unsigned MergedDstValIdx = DestLR->ValId; // Join the ranges of other into the ranges of this interval. std::map<unsigned, unsigned> Dst2SrcIdxMap; |

