Remove <def,read-undef> flags from partial redefinitions.
[oota-llvm.git] / lib / CodeGen / RegisterCoalescer.cpp
index eb4ffe17a1ece65a56e8c077f5db785bea106e3f..f45072f1ac56b69148fa395ee3a8852cc55302e0 100644 (file)
@@ -1732,6 +1732,12 @@ void JoinVals::pruneValues(JoinVals &Other,
     case CR_Replace:
       // This value takes precedence over the value in Other.LI.
       LIS->pruneValue(&Other.LI, Def, &EndPoints);
+      // Remove <def,read-undef> flags. This def is now a partial redef.
+      if (!Def.isBlock())
+        for (MIOperands MO(Indexes->getInstructionFromIndex(Def));
+             MO.isValid(); ++MO)
+          if (MO->isReg() && MO->isDef() && MO->getReg() == LI.reg)
+            MO->setIsUndef(false);
       DEBUG(dbgs() << "\t\tpruned " << PrintReg(Other.LI.reg) << " at " << Def
                    << ": " << Other.LI << '\n');
       break;