=========== =========== =========== =========== =====
                     -8                      15     4 [27 -(O,0,1)-> 21] 
                    -11                      12     1 [25 -(A,0,1)-> 21] 
                    -12                      11     0 [24 -(O,0,1)-> 21] 
         -7                       4                 4 [21 -(O,0,0)-> 27] 
        -10                      13                 1 [21 -(T,0,1)-> 25] 
        -10                       1                 1 [21 -(T,0,0)-> 25] 
        -11                       0                 0 [21 -(O,0,0)-> 24] 
----------- ----------- ----------- ----------- -----
         -7          -8           0          11       (max, max, min, min)
                     -7           0                   final window

Trying to schedule node 1 INSN = 21  in (0 .. -8) step -1
---------------------------------------------------------------------------

Tested in the same way as the previous patch.  OK to install?

Richard


gcc/
	* modulo-sched.c (get_sched_window): Use a table for the debug output.
	Print the current ii.

Index: gcc/modulo-sched.c
===================================================================
--- gcc/modulo-sched.c	2011-08-04 12:03:53.000000000 +0100
+++ gcc/modulo-sched.c	2011-08-04 12:11:43.000000000 +0100
@@ -1658,44 +1658,41 @@ get_sched_window (partial_schedule_ptr p
   count_preds = psp_not_empty;
   count_succs = pss_not_empty;
 
+  if (dump_file && (psp_not_empty || pss_not_empty))
+    {
+      fprintf (dump_file, "\nAnalyzing dependencies for node %d (INSN %d)"
+	       "; ii = %d\n\n", u_node->cuid, INSN_UID (u_node->insn), ii);
+      fprintf (dump_file, "%11s %11s %11s %11s %5s\n",
+	       "start", "early start", "late start", "end", "time");
+      fprintf (dump_file, "=========== =========== =========== ==========="
+	       " =====\n");
+    }
   /* Calculate early_start and limit end.  Both bounds are inclusive.  */
   if (psp_not_empty)
     for (e = u_node->in; e != 0; e = e->next_in)
       {
 	ddg_node_ptr v_node = e->src;
 
-	if (dump_file)
-	  {
-	    fprintf (dump_file, "\nProcessing edge: ");
-	    print_ddg_edge (dump_file, e);
-	    fprintf (dump_file,
-		     "\nScheduling %d (%d) in psp_not_empty,"
-		     " checking p %d (%d): ", u_node->cuid,
-		     INSN_UID (u_node->insn), v_node->cuid, INSN_UID
-		     (v_node->insn));
-	  }
-
 	if (TEST_BIT (sched_nodes, v_node->cuid))
 	  {
 	    int p_st = SCHED_TIME (v_node);
+	    int earliest = p_st + e->latency - (e->distance * ii);
+	    int latest = (e->data_type == MEM_DEP ? p_st + ii - 1 : INT_MAX);
 
-	    early_start = MAX (early_start,
-			       p_st + e->latency - (e->distance * ii));
+	    if (dump_file)
+	      {
+		fprintf (dump_file, "%11s %11d %11s %11d %5d",
+			 "", earliest, "", latest, p_st);
+		print_ddg_edge (dump_file, e);
+		fprintf (dump_file, "\n");
+	      }
 
-	    if (e->data_type == MEM_DEP)
-	      end = MIN (end, p_st + ii - 1);
+	    early_start = MAX (early_start, earliest);
+	    end = MIN (end, latest);
 
 	    if (e->type == TRUE_DEP && e->data_type == REG_DEP)
 	      count_preds++;
-
-	    if (dump_file)
-	      fprintf (dump_file,
-		       "pred st = %d; early_start = %d; latency: %d;"
-		       " end: %d\n", p_st, early_start, e->latency, end);
-
 	  }
-	else if (dump_file)
-	  fprintf (dump_file, "the node is not scheduled\n");
       }
 
   /* Calculate late_start and limit start.  Both bounds are inclusive.  */
@@ -1704,40 +1701,37 @@ get_sched_window (partial_schedule_ptr p
       {
 	ddg_node_ptr v_node = e->dest;
 
-	if (dump_file)
-	  {
-	    fprintf (dump_file, "\nProcessing edge:");
-	    print_ddg_edge (dump_file, e);
-	    fprintf (dump_file,
-		     "\nScheduling %d (%d) in pss_not_empty,"
-		     " checking s %d (%d): ", u_node->cuid,
-		     INSN_UID (u_node->insn), v_node->cuid, INSN_UID
-		     (v_node->insn));
-	  }
-
 	if (TEST_BIT (sched_nodes, v_node->cuid))
 	  {
 	    int s_st = SCHED_TIME (v_node);
+	    int earliest = (e->data_type == MEM_DEP ? s_st - ii + 1 : INT_MIN);
+	    int latest = s_st - e->latency + (e->distance * ii);
 
-	    late_start = MIN (late_start,
-			      s_st - e->latency + (e->distance * ii));
+	    if (dump_file)
+	      {
+		fprintf (dump_file, "%11d %11s %11d %11s %5d",
+			 earliest, "", latest, "", s_st);
+		print_ddg_edge (dump_file, e);
+		fprintf (dump_file, "\n");
+	      }
 
-	    if (e->data_type == MEM_DEP)
-	      start = MAX (start, s_st - ii + 1);
+	    start = MAX (start, earliest);
+	    late_start = MIN (late_start, latest);
 
 	    if (e->type == TRUE_DEP && e->data_type == REG_DEP)
 	      count_succs++;
-
-	    if (dump_file)
-	      fprintf (dump_file,
-		       "succ st = %d; late_start = %d; latency = %d;"
-		       " start=%d", s_st, late_start, e->latency, start);
-
 	  }
-	else if (dump_file)
-	  fprintf (dump_file, "the node is not scheduled\n");
       }
 
+  if (dump_file && (psp_not_empty || pss_not_empty))
+    {
+      fprintf (dump_file, "----------- ----------- ----------- -----------"
+	       " -----\n");
+      fprintf (dump_file, "%11d %11d %11d %11d %5s %s\n",
+	       start, early_start, late_start, end, "",
+	       "(max, max, min, min)");
+    }
+
   /* Get a target scheduling window no bigger than ii.  */
   if (early_start == INT_MIN && late_start == INT_MAX)
     early_start = SCHED_ASAP (u_node);
@@ -1750,6 +1744,10 @@ get_sched_window (partial_schedule_ptr p
   end = MIN (end, late_start);
   step = 1;
 
+  if (dump_file && (psp_not_empty || pss_not_empty))
+    fprintf (dump_file, "%11s %11d %11d %11s %5s final window\n",
+	     "", start, end, "", "");
+
   /* If there are at least as many successors as predecessors, schedule the
      node close to its successors.  */
   if (count_succs && count_succs >= count_preds)
@@ -1957,8 +1955,8 @@ sms_schedule_by_order (ddg_ptr g, int mi
                                 &step, &end) == 0)
             {
               if (dump_file)
-                fprintf (dump_file, "\nTrying to schedule node %d \
-                        INSN = %d  in (%d .. %d) step %d\n", u, (INSN_UID
+                fprintf (dump_file, "\nTrying to schedule node %d "
+			 "INSN = %d  in (%d .. %d) step %d\n", u, (INSN_UID
                         (g->nodes[u].insn)), start, end, step);
 
               gcc_assert ((step > 0 && start < end)
