llvm.org GIT mirror llvm / 3472925
When coalescing an EXTRACT_SUBREG and the dst register is a physical register, the source register will be coalesced to the super register of the LHS. Properly merge in the live ranges of the resulting coalesced interval that were part of the original source interval to the live interval of the super-register. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42961 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 12 years ago
3 changed file(s) with 29 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
252252 /// current interval, but only if the overlapping LiveRanges have the
253253 /// specified value number.
254254 void MergeValueInAsValue(const LiveInterval &RHS,
255 VNInfo *RHSValNo, VNInfo *LHSValNo);
255 const VNInfo *RHSValNo, VNInfo *LHSValNo);
256256
257257 /// Copy - Copy the specified live interval. This copies all the fields
258258 /// except for the register of the interval.
388388 /// current interval, but only if the overlapping LiveRanges have the
389389 /// specified value number.
390390 void LiveInterval::MergeValueInAsValue(const LiveInterval &RHS,
391 VNInfo *RHSValNo, VNInfo *LHSValNo) {
391 const VNInfo *RHSValNo, VNInfo *LHSValNo) {
392392 // TODO: Make this more efficient.
393393 iterator InsertPos = begin();
394394 for (const_iterator I = RHS.begin(), E = RHS.end(); I != E; ++I) {
420420 // cl = EXTRACT_SUBREG reg1024, 1
421421 // then create and update the actual physical register allocated to RHS.
422422 if (RealDstReg) {
423 unsigned CopyIdx = li_->getInstructionIndex(CopyMI);
424 VNInfo *DstValNo =
425 ResDstInt->getLiveRangeContaining(li_->getUseIndex(CopyIdx))->valno;
426423 LiveInterval &RealDstInt = li_->getOrCreateInterval(RealDstReg);
427 VNInfo *ValNo = RealDstInt.getNextValue(DstValNo->def, DstValNo->reg,
428 li_->getVNInfoAllocator());
429 RealDstInt.addKills(ValNo, DstValNo->kills);
430 RealDstInt.MergeValueInAsValue(*ResDstInt, DstValNo, ValNo);
424 for (unsigned i = 0, e = ResSrcInt->getNumValNums(); i != e; ++i) {
425 const VNInfo *SrcValNo = ResSrcInt->getValNumInfo(i);
426 const VNInfo *DstValNo =
427 ResDstInt->FindLiveRangeContaining(SrcValNo->def)->valno;
428 VNInfo *ValNo = RealDstInt.getNextValue(DstValNo->def, DstValNo->reg,
429 li_->getVNInfoAllocator());
430 RealDstInt.addKills(ValNo, DstValNo->kills);
431 RealDstInt.MergeValueInAsValue(*ResDstInt, DstValNo, ValNo);
432 }
431433 repDstReg = RealDstReg;
432434 }
433435
878880 }
879881 }
880882
883 // Update kill info. Some live ranges are extended due to copy coalescing.
884 for (DenseMap::iterator I = LHSValsDefinedFromRHS.begin(),
885 E = LHSValsDefinedFromRHS.end(); I != E; ++I) {
886 VNInfo *VNI = I->first;
887 unsigned LHSValID = LHSValNoAssignments[VNI->id];
888 LiveInterval::removeKill(NewVNInfo[LHSValID], VNI->def);
889 RHS.addKills(NewVNInfo[LHSValID], VNI->kills);
890 }
891
892 // Update kill info. Some live ranges are extended due to copy coalescing.
893 for (DenseMap::iterator I = RHSValsDefinedFromLHS.begin(),
894 E = RHSValsDefinedFromLHS.end(); I != E; ++I) {
895 VNInfo *VNI = I->first;
896 unsigned RHSValID = RHSValNoAssignments[VNI->id];
897 LiveInterval::removeKill(NewVNInfo[RHSValID], VNI->def);
898 LHS.addKills(NewVNInfo[RHSValID], VNI->kills);
899 }
900
881901 // If we get here, we know that we can coalesce the live ranges. Ask the
882902 // intervals to coalesce themselves now.
883903 if ((RHS.ranges.size() > LHS.ranges.size() &&
884904 MRegisterInfo::isVirtualRegister(LHS.reg)) ||
885905 MRegisterInfo::isPhysicalRegister(RHS.reg)) {
886 // Update kill info. Some live ranges are extended due to copy coalescing.
887 for (DenseMap::iterator I = LHSValsDefinedFromRHS.begin(),
888 E = LHSValsDefinedFromRHS.end(); I != E; ++I) {
889 VNInfo *VNI = I->first;
890 unsigned LHSValID = LHSValNoAssignments[VNI->id];
891 LiveInterval::removeKill(NewVNInfo[LHSValID], VNI->def);
892 RHS.addKills(NewVNInfo[LHSValID], VNI->kills);
893 }
894
895906 RHS.join(LHS, &RHSValNoAssignments[0], &LHSValNoAssignments[0], NewVNInfo);
896907 Swapped = true;
897908 } else {
898 // Update kill info. Some live ranges are extended due to copy coalescing.
899 for (DenseMap::iterator I = RHSValsDefinedFromLHS.begin(),
900 E = RHSValsDefinedFromLHS.end(); I != E; ++I) {
901 VNInfo *VNI = I->first;
902 unsigned RHSValID = RHSValNoAssignments[VNI->id];
903 LiveInterval::removeKill(NewVNInfo[RHSValID], VNI->def);
904 LHS.addKills(NewVNInfo[RHSValID], VNI->kills);
905 }
906
907909 LHS.join(RHS, &LHSValNoAssignments[0], &RHSValNoAssignments[0], NewVNInfo);
908910 Swapped = false;
909911 }