Fix a pasto. Also simplify for Bill's benefit.
[oota-llvm.git] / lib / CodeGen / SimpleRegisterCoalescing.cpp
index 068dcda93b5fe8a6c321ff6ecdebe4c61916bfaa..22b62c3603797a8bfea33ffd18874eb1116e0e44 100644 (file)
@@ -2571,17 +2571,19 @@ void SimpleRegisterCoalescing::CalculateSpillWeights() {
           continue;
 
         bool HasDef = mopi.isDef();
-        bool HasUse = mopi.isUse();
+        bool HasUse = !HasDef;
         for (unsigned j = i+1; j != e; ++j) {
           const MachineOperand &mopj = MI->getOperand(j);
           if (!mopj.isReg() || mopj.getReg() != Reg)
             continue;
           HasDef |= mopj.isDef();
           HasUse |= mopj.isUse();
+          if (HasDef && HasUse)
+            break;
         }
 
         LiveInterval &RegInt = li_->getInterval(Reg);
-        float Weight = li_->getSpillWeight(HasDef, HasUse, loopDepth+1);
+        float Weight = li_->getSpillWeight(HasDef, HasUse, loopDepth);
         if (HasDef && isExit) {
           // Looks like this is a loop count variable update.
           MachineInstrIndex DefIdx =