[llvm-commits] [llvm] r95973 - in /llvm/trunk/lib/CodeGen/PBQP: HeuristicSolver.h Heuristics/Briggs.h
Lang Hames
lhames at gmail.com
Fri Feb 12 01:43:38 PST 2010
Author: lhames
Date: Fri Feb 12 03:43:37 2010
New Revision: 95973
URL: http://llvm.org/viewvc/llvm-project?rev=95973&view=rev
Log:
* Updated the cost matrix normalization proceedure to better handle infinite costs.
* Enabled R1/R2 application for nodes with infinite spill costs in the Briggs heuristic (made
safe by the changes to the normalization proceedure).
* Removed a redundant header.
Modified:
llvm/trunk/lib/CodeGen/PBQP/HeuristicSolver.h
llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h
Modified: llvm/trunk/lib/CodeGen/PBQP/HeuristicSolver.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PBQP/HeuristicSolver.h?rev=95973&r1=95972&r2=95973&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PBQP/HeuristicSolver.h (original)
+++ llvm/trunk/lib/CodeGen/PBQP/HeuristicSolver.h Fri Feb 12 03:43:37 2010
@@ -18,7 +18,6 @@
#include "Graph.h"
#include "Solution.h"
-#include "llvm/Support/raw_ostream.h"
#include <vector>
#include <limits>
@@ -494,14 +493,23 @@
bool tryNormaliseEdgeMatrix(Graph::EdgeItr &eItr) {
+ const PBQPNum infinity = std::numeric_limits<PBQPNum>::infinity();
+
Matrix &edgeCosts = g.getEdgeCosts(eItr);
Vector &uCosts = g.getNodeCosts(g.getEdgeNode1(eItr)),
&vCosts = g.getNodeCosts(g.getEdgeNode2(eItr));
for (unsigned r = 0; r < edgeCosts.getRows(); ++r) {
- PBQPNum rowMin = edgeCosts.getRowMin(r);
+ PBQPNum rowMin = infinity;
+
+ for (unsigned c = 0; c < edgeCosts.getCols(); ++c) {
+ if (vCosts[c] != infinity && edgeCosts[r][c] < rowMin)
+ rowMin = edgeCosts[r][c];
+ }
+
uCosts[r] += rowMin;
- if (rowMin != std::numeric_limits<PBQPNum>::infinity()) {
+
+ if (rowMin != infinity) {
edgeCosts.subFromRow(r, rowMin);
}
else {
@@ -510,9 +518,16 @@
}
for (unsigned c = 0; c < edgeCosts.getCols(); ++c) {
- PBQPNum colMin = edgeCosts.getColMin(c);
+ PBQPNum colMin = infinity;
+
+ for (unsigned r = 0; r < edgeCosts.getRows(); ++r) {
+ if (uCosts[r] != infinity && edgeCosts[r][c] < colMin)
+ colMin = edgeCosts[r][c];
+ }
+
vCosts[c] += colMin;
- if (colMin != std::numeric_limits<PBQPNum>::infinity()) {
+
+ if (colMin != infinity) {
edgeCosts.subFromCol(c, colMin);
}
else {
Modified: llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h?rev=95973&r1=95972&r2=95973&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h (original)
+++ llvm/trunk/lib/CodeGen/PBQP/Heuristics/Briggs.h Fri Feb 12 03:43:37 2010
@@ -128,14 +128,7 @@
/// selected for heuristic reduction instead.
bool shouldOptimallyReduce(Graph::NodeItr nItr) {
if (getSolver().getSolverDegree(nItr) < 3) {
- if (getGraph().getNodeCosts(nItr)[0] !=
- std::numeric_limits<PBQPNum>::infinity()) {
- return true;
- }
- // Otherwise we have an infinite spill cost node.
- initializeNode(nItr);
- NodeData &nd = getHeuristicNodeData(nItr);
- return nd.isAllocable;
+ return true;
}
// else
return false;
More information about the llvm-commits
mailing list