i965: Fix Crystal Well PCI IDs.
[mesa.git] / src / mesa / program / register_allocate.c
index 07eb154954d14574463382622808a61d8287e232..88793dbdc1e2f7e7831f51d1566bd8f1613f8729 100644 (file)
@@ -255,9 +255,11 @@ ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int r)
 /**
  * Must be called after all conflicts and register classes have been
  * set up and before the register set is used for allocation.
+ * To avoid costly q value computation, use the q_values paramater
+ * to pass precomputed q values to this function.
  */
 void
-ra_set_finalize(struct ra_regs *regs)
+ra_set_finalize(struct ra_regs *regs, unsigned int **q_values)
 {
    unsigned int b, c;
 
@@ -265,6 +267,15 @@ ra_set_finalize(struct ra_regs *regs)
       regs->classes[b]->q = ralloc_array(regs, unsigned int, regs->class_count);
    }
 
+   if (q_values) {
+      for (b = 0; b < regs->class_count; b++) {
+         for (c = 0; c < regs->class_count; c++) {
+            regs->classes[b]->q[c] = q_values[b][c];
+        }
+      }
+      return;
+   }
+
    /* Compute, for each class B and C, how many regs of B an
     * allocation to C could conflict with.
     */
@@ -544,6 +555,13 @@ ra_get_best_spill_node(struct ra_graph *g)
       if (cost <= 0.0)
         continue;
 
+      /* Only consider registers for spilling if they are still in the
+       * interference graph (those on the stack have already been proven to be
+       * allocatable without spilling).
+       */
+      if (g->nodes[n].in_stack)
+         continue;
+
       benefit = ra_get_spill_benefit(g, n);
 
       if (benefit / cost > best_benefit) {