Author: evancheng
Date: Wed Feb 13 02:41:08 2008
New Revision: 47056

URL: http://llvm.org/viewvc/llvm-project?rev=47056&view=rev
Log:
* Cannot safely commute an instruction there are other defs which can reach its 
uses.
* Ignore copy instructions which have already been coalesced.

Modified:
    llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp

Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=47056&r1=47055&r2=47056&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original)
+++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Wed Feb 13 02:41:08 2008
@@ -237,7 +237,9 @@
   // AValNo is the value number in A that defines the copy, A3 in the example.
   LiveInterval::iterator ALR = IntA.FindLiveRangeContaining(CopyIdx-1);
   VNInfo *AValNo = ALR->valno;
-  if (AValNo->def == ~0U || AValNo->def == ~1U)
+  // If other defs can reach uses of this def, then it's not safe to perform
+  // the optimization.
+  if (AValNo->def == ~0U || AValNo->def == ~1U || AValNo->hasPHIKill)
     return false;
   MachineInstr *DefMI = li_->getInstructionFromIndex(AValNo->def);
   const TargetInstrDesc &TID = DefMI->getDesc();
@@ -312,6 +314,8 @@
     MachineOperand &UseMO = UI.getOperand();
     ++UI;
     MachineInstr *UseMI = UseMO.getParent();
+  if (JoinedCopies.count(UseMI))
+    continue;
     unsigned UseIdx = li_->getInstructionIndex(UseMI);
     LiveInterval::iterator ULR = IntA.FindLiveRangeContaining(UseIdx);
     if (ULR->valno != AValNo)


_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to