Implement vector shift up / down and insert zero with ps{rl}lq / ps{rl}ldq.
[oota-llvm.git] / lib / CodeGen / LiveIntervalAnalysis.cpp
index 4997302fa6a5f31aaf26fd3e8ae4f46b058876ce..976aa5a9245a7ffb8b859b52a3da07d43ae33e61 100644 (file)
@@ -75,17 +75,14 @@ void LiveIntervals::releaseMemory() {
     delete ClonedMIs[i];
 }
 
-/// runOnMachineFunction - Register allocate the whole function
-///
-bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
-  mf_ = &fn;
-  mri_ = &mf_->getRegInfo();
-  tm_ = &fn.getTarget();
-  tri_ = tm_->getRegisterInfo();
-  tii_ = tm_->getInstrInfo();
-  lv_ = &getAnalysis<LiveVariables>();
-  allocatableRegs_ = tri_->getAllocatableSet(fn);
-
+void LiveIntervals::computeNumbering() {
+  Index2MiMap OldI2MI = i2miMap_;
+  
+  Idx2MBBMap.clear();
+  MBB2IdxMap.clear();
+  mi2iMap_.clear();
+  i2miMap_.clear();
+  
   // Number MachineInstrs and MachineBasicBlocks.
   // Initialize MBB indexes to a sentinal.
   MBB2IdxMap.resize(mf_->getNumBlockIDs(), std::make_pair(~0U,~0U));
@@ -110,7 +107,34 @@ bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
     Idx2MBBMap.push_back(std::make_pair(StartIdx, MBB));
   }
   std::sort(Idx2MBBMap.begin(), Idx2MBBMap.end(), Idx2MBBCompare());
+  
+  if (!OldI2MI.empty())
+    for (iterator I = begin(), E = end(); I != E; ++I)
+      for (LiveInterval::iterator LI = I->second.begin(), LE = I->second.end();
+           LI != LE; ++LI) {
+        LI->start = mi2iMap_[OldI2MI[LI->start]];
+        LI->end = mi2iMap_[OldI2MI[LI->end]];
+        
+        VNInfo* vni = LI->valno;
+        vni->def = mi2iMap_[OldI2MI[vni->def]];
+        
+        for (size_t i = 0; i < vni->kills.size(); ++i)
+          vni->kills[i] = mi2iMap_[OldI2MI[vni->kills[i]]];
+      }
+}
+
+/// runOnMachineFunction - Register allocate the whole function
+///
+bool LiveIntervals::runOnMachineFunction(MachineFunction &fn) {
+  mf_ = &fn;
+  mri_ = &mf_->getRegInfo();
+  tm_ = &fn.getTarget();
+  tri_ = tm_->getRegisterInfo();
+  tii_ = tm_->getInstrInfo();
+  lv_ = &getAnalysis<LiveVariables>();
+  allocatableRegs_ = tri_->getAllocatableSet(fn);
 
+  computeNumbering();
   computeIntervals();
 
   numIntervals += getNumIntervals();
@@ -1150,9 +1174,7 @@ rewriteInstructionsForSpills(const LiveInterval &li, bool TrySplit,
     }
     MachineBasicBlock *MBB = MI->getParent();
 
-    // ReMatDefMI is a clone and not in the IR at all, so check
-    // RefMatOrigDefMI too.
-    if (ImpUse && MI != ReMatDefMI && MI != ReMatOrigDefMI) {
+    if (ImpUse && MI != ReMatDefMI) {
       // Re-matting an instruction with virtual register use. Update the
       // register interval's spill weight to HUGE_VALF to prevent it from
       // being spilled.