Make MachineRegisterInfo::getVRegDef more efficient by aiming the keep the def of...
authorChris Lattner <sabre@nondot.org>
Tue, 1 Jan 2008 21:08:22 +0000 (21:08 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 1 Jan 2008 21:08:22 +0000 (21:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45483 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineInstr.cpp

index 0de5501b78d30ed65c1824d8db014c7b38f3ebba..00be1f1f75e1ee329e39945fa762a93562fc9311 100644 (file)
@@ -42,17 +42,23 @@ void MachineOperand::AddRegOperandToRegInfo(MachineRegisterInfo *RegInfo) {
   }
   
   // Otherwise, add this operand to the head of the registers use/def list.
-  MachineOperand *&Head = RegInfo->getRegUseDefListHead(getReg());
+  MachineOperand **Head = &RegInfo->getRegUseDefListHead(getReg());
   
-  Contents.Reg.Next = Head;
+  // For SSA values, we prefer to keep the definition at the start of the list.
+  // we do this by skipping over the definition if it is at the head of the
+  // list.
+  if (*Head && (*Head)->isDef())
+    Head = &(*Head)->Contents.Reg.Next;
+  
+  Contents.Reg.Next = *Head;
   if (Contents.Reg.Next) {
     assert(getReg() == Contents.Reg.Next->getReg() &&
            "Different regs on the same list!");
     Contents.Reg.Next->Contents.Reg.Prev = &Contents.Reg.Next;
   }
   
-  Contents.Reg.Prev = &Head;
-  Head = this;
+  Contents.Reg.Prev = Head;
+  *Head = this;
 }
 
 void MachineOperand::setReg(unsigned Reg) {