Fold trivial two-operand tokenfactors where the operands are equal
[oota-llvm.git] / lib / CodeGen / SimpleRegisterCoalescing.cpp
index 88996575db86540fa0723b6a4192d6a1f981bf53..86065f069f73c40b392fbd87c4646c9ce698589d 100644 (file)
@@ -67,13 +67,13 @@ static RegisterAnalysisGroup<RegisterCoalescer, true/*The Default*/> V(X);
 const PassInfo *const llvm::SimpleRegisterCoalescingID = &X;
 
 void SimpleRegisterCoalescing::getAnalysisUsage(AnalysisUsage &AU) const {
+  AU.addRequired<LiveIntervals>();
   AU.addPreserved<LiveIntervals>();
+  AU.addRequired<MachineLoopInfo>();
   AU.addPreserved<MachineLoopInfo>();
   AU.addPreservedID(MachineDominatorsID);
   AU.addPreservedID(PHIEliminationID);
   AU.addPreservedID(TwoAddressInstructionPassID);
-  AU.addRequired<LiveIntervals>();
-  AU.addRequired<MachineLoopInfo>();
   MachineFunctionPass::getAnalysisUsage(AU);
 }
 
@@ -1206,14 +1206,6 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
   DOUT << " and "; DstInt.print(DOUT, tri_);
   DOUT << ": ";
 
-  // If one interval is earlyclobber and the other is overlaps-earlyclobber,
-  // we cannot coalesce them.
-  if ((SrcInt.isEarlyClobber && DstInt.overlapsEarlyClobber) ||
-      (DstInt.isEarlyClobber && SrcInt.overlapsEarlyClobber)) {
-    DOUT << "\t\tCannot join due to earlyclobber.";
-    return false;
-  }
-
   // Check if it is necessary to propagate "isDead" property.
   if (!isExtSubReg && !isInsSubReg) {
     MachineOperand *mopd = CopyMI->findRegisterDefOperand(DstReg, false);
@@ -1374,10 +1366,6 @@ bool SimpleRegisterCoalescing::JoinCopy(CopyRec &TheCopy, bool &Again) {
   if (TargetRegisterInfo::isVirtualRegister(DstReg))
     RemoveUnnecessaryKills(DstReg, *ResDstInt);
 
-  // Merge the earlyclobber bits.
-  ResDstInt->isEarlyClobber |= ResSrcInt->isEarlyClobber;
-  ResDstInt->overlapsEarlyClobber |= ResSrcInt->overlapsEarlyClobber;
-
   if (isInsSubReg)
     // Avoid:
     // r1024 = op
@@ -2373,7 +2361,8 @@ bool SimpleRegisterCoalescing::runOnMachineFunction(MachineFunction &fn) {
         LI.weight = HUGE_VALF;
       else {
         bool isLoad = false;
-        if (li_->isReMaterializable(LI, isLoad)) {
+        SmallVector<LiveInterval*, 4> SpillIs;
+        if (li_->isReMaterializable(LI, SpillIs, isLoad)) {
           // If all of the definitions of the interval are re-materializable,
           // it is a preferred candidate for spilling. If non of the defs are
           // loads, then it's potentially very cheap to re-materialize.