From 6cf7c390ecf33cdbe9e65d230e4f61ac548893e6 Mon Sep 17 00:00:00 2001
From: Owen Anderson <resistor@mac.com>
Date: Wed, 21 Jan 2009 00:13:28 +0000
Subject: [PATCH] Be more aggressive about renumbering vregs after splitting
 them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62639 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/CodeGen/PreAllocSplitting.cpp | 10 +++++++---
 test/CodeGen/X86/pre-split2.ll    |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp
index 6b37637ee95..3c8257f1dac 100644
--- a/lib/CodeGen/PreAllocSplitting.cpp
+++ b/lib/CodeGen/PreAllocSplitting.cpp
@@ -1127,9 +1127,11 @@ bool PreAllocSplitting::Rematerialize(unsigned vreg, VNInfo* ValNo,
   LIs->InsertMachineInstrInMaps(prior(RestorePt), RestoreIdx);
   
   if (KillPt->getParent() == BarrierMBB) {
-    UpdateRegisterInterval(ValNo, LIs->getUseIndex(KillIdx)+1,
+    VNInfo* After = UpdateRegisterInterval(ValNo, LIs->getUseIndex(KillIdx)+1,
                            LIs->getDefIndex(RestoreIdx));
     
+    RenumberValno(After);
+
     ++NumSplits;
     ++NumRemats;
     return true;
@@ -1312,9 +1314,11 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) {
     UpdateSpillSlotInterval(ValNo, LIs->getUseIndex(SpillIndex)+1,
                             LIs->getDefIndex(RestoreIndex));
 
-    UpdateRegisterInterval(ValNo, LIs->getUseIndex(SpillIndex)+1,
+    VNInfo* After = UpdateRegisterInterval(ValNo,
+                           LIs->getUseIndex(SpillIndex)+1,
                            LIs->getDefIndex(RestoreIndex));
-    
+    RenumberValno(After);
+   
     ++NumSplits;
     return true;
   }
diff --git a/test/CodeGen/X86/pre-split2.ll b/test/CodeGen/X86/pre-split2.ll
index 1d69aa85442..fcb3f05a838 100644
--- a/test/CodeGen/X86/pre-split2.ll
+++ b/test/CodeGen/X86/pre-split2.ll
@@ -1,5 +1,5 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -pre-alloc-split -stats |& \
-; RUN:   grep {pre-alloc-split} | count 2
+; RUN:   grep {pre-alloc-split} | count 3
 
 define i32 @t() {
 entry: