[llvm-commits] [llvm] r134228 - /llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp
Rafael Espindola
rafael.espindola at gmail.com
Thu Jun 30 19:35:06 PDT 2011
Author: rafael
Date: Thu Jun 30 21:35:06 2011
New Revision: 134228
URL: http://llvm.org/viewvc/llvm-project?rev=134228&view=rev
Log:
Check the liveinterval, not the kill flag.
Modified:
llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp
Modified: llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp?rev=134228&r1=134227&r2=134228&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp Thu Jun 30 21:35:06 2011
@@ -1197,7 +1197,8 @@
// which allows us to coalesce A and B.
// MI is the definition of B. LR is the life range of A that includes
// the slot just before B. If we return true, we add "B = X" to DupCopies.
-static bool RegistersDefinedFromSameValue(const TargetRegisterInfo &tri,
+static bool RegistersDefinedFromSameValue(LiveIntervals &li,
+ const TargetRegisterInfo &tri,
CoalescerPair &CP, MachineInstr *MI,
LiveRange *LR,
SmallVector<MachineInstr*, 8> &DupCopies) {
@@ -1207,14 +1208,16 @@
if (!MI->isFullCopy() || CP.isPartial() || CP.isPhys())
return false;
+ unsigned Dst = MI->getOperand(0).getReg();
+ unsigned Src = MI->getOperand(1).getReg();
+
// FIXME: If "B = X" kills X, we have to move the kill back to its
// previous use. For now we just avoid the optimization in that case.
- if (MI->getOperand(1).isKill())
+ SlotIndex CopyIdx = li.getInstructionIndex(MI).getNextIndex().getDefIndex();
+ LiveInterval &SrcInt = li.getInterval(Src);
+ if (SrcInt.killedAt(CopyIdx))
return false;
- unsigned Dst = MI->getOperand(0).getReg();
- unsigned Src = MI->getOperand(1).getReg();
-
if (!TargetRegisterInfo::isVirtualRegister(Src) ||
!TargetRegisterInfo::isVirtualRegister(Dst))
return false;
@@ -1332,7 +1335,7 @@
// from the RHS interval, we can use its value #.
MachineInstr *MI = VNI->getCopy();
if (!CP.isCoalescable(MI) &&
- !RegistersDefinedFromSameValue(*tri_, CP, MI, lr, DupCopies))
+ !RegistersDefinedFromSameValue(*li_, *tri_, CP, MI, lr, DupCopies))
continue;
LHSValsDefinedFromRHS[VNI] = lr->valno;
@@ -1359,7 +1362,7 @@
// from the LHS interval, we can use its value #.
MachineInstr *MI = VNI->getCopy();
if (!CP.isCoalescable(MI) &&
- !RegistersDefinedFromSameValue(*tri_, CP, MI, lr, DupCopies))
+ !RegistersDefinedFromSameValue(*li_, *tri_, CP, MI, lr, DupCopies))
continue;
RHSValsDefinedFromLHS[VNI] = lr->valno;
More information about the llvm-commits
mailing list