[PBQP] Fix coalescing benefits
authorArnaud A. de Grandmaison <arnaud.degrandmaison@arm.com>
Tue, 21 Oct 2014 16:24:15 +0000 (16:24 +0000)
committerArnaud A. de Grandmaison <arnaud.degrandmaison@arm.com>
Tue, 21 Oct 2014 16:24:15 +0000 (16:24 +0000)
As coalescing registers is a benefit, the cost should be improved (i.e. made smaller) when coalescing is possible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220302 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAllocPBQP.cpp

index 599fbad23b641857acc5f469d274b23ef2253ac3..5bd33743db0dc618bdec0cb5d39809f7e2b053b2 100644 (file)
@@ -350,7 +350,7 @@ public:
 
           if (PRegOpt < Allowed.size()) {
             PBQPRAGraph::RawVector NewCosts(G.getNodeCosts(NId));
-            NewCosts[PRegOpt + 1] += CBenefit;
+            NewCosts[PRegOpt + 1] -= CBenefit;
             G.setNodeCosts(NId, std::move(NewCosts));
           }
         } else {
@@ -395,7 +395,7 @@ private:
       for (unsigned J = 0; J != Allowed2.size(); ++J) {
         unsigned PReg2 = Allowed2[J];
         if (PReg1 == PReg2)
-          CostMat[I + 1][J + 1] += -Benefit;
+          CostMat[I + 1][J + 1] -= Benefit;
       }
     }
   }