all but CAS working on x86
[oota-llvm.git] / lib / CodeGen / LiveIntervalAnalysis.cpp
index a13bc43a5efbf77cd89da0aa789ff03eff9ba71f..00ba2e770b05acdc2f291f422b07713b89c5001f 100644 (file)
@@ -764,6 +764,9 @@ bool LiveIntervals::tryFoldMemoryOperand(MachineInstr* &MI,
   MachineInstr *fmi = isSS ? tii_->foldMemoryOperand(*mf_, MI, FoldOps, Slot)
                            : tii_->foldMemoryOperand(*mf_, MI, FoldOps, DefMI);
   if (fmi) {
+    // Remember this instruction uses the spill slot.
+    if (isSS) vrm.addSpillSlotUse(Slot, fmi);
+
     // Attempt to fold the memory reference into the instruction. If
     // we can do this, we don't need to insert spill code.
     if (lv_)
@@ -789,7 +792,7 @@ bool LiveIntervals::tryFoldMemoryOperand(MachineInstr* &MI,
 /// folding is possible.
 bool LiveIntervals::canFoldMemoryOperand(MachineInstr *MI,
                                          SmallVector<unsigned, 2> &Ops,
-                                         bool ReMatLoadSS) const {
+                                         bool ReMatLoad) const {
   // Filter the list of operand indexes that are to be folded. Abort if
   // any operand will prevent folding.
   unsigned MRInfo = 0;
@@ -797,8 +800,8 @@ bool LiveIntervals::canFoldMemoryOperand(MachineInstr *MI,
   if (FilterFoldedOps(MI, Ops, MRInfo, FoldOps))
     return false;
 
-  // Can't fold a load from fixed stack slot into a two address instruction.
-  if (ReMatLoadSS && (MRInfo & VirtRegMap::isMod))
+  // Can't fold a remat'ed load into a two address instruction.
+  if (ReMatLoad && (MRInfo & VirtRegMap::isMod))
     return false;
 
   return tii_->canFoldMemoryOperand(MI, FoldOps);
@@ -951,7 +954,7 @@ rewriteInstructionForSpills(const LiveInterval &li, const VNInfo *VNI,
           goto RestartInstruction;
         }
       } else {
-        CanFold = canFoldMemoryOperand(MI, Ops, DefIsReMat && isLoadSS);
+        CanFold = canFoldMemoryOperand(MI, Ops, DefIsReMat && isLoad);
       }
     } else
       CanFold = false;