OSDN Git Service

PR middle-end/28071
[pf3gnuchains/gcc-fork.git] / gcc / sched-deps.c
index 6de5296..c3dc579 100644 (file)
@@ -97,7 +97,7 @@ init_dep_1 (dep_t dep, rtx pro, rtx con, enum reg_note kind, ds_t ds)
 
 /* Init DEP with the arguments.
    While most of the scheduler (including targets) only need the major type
-   of the dependency, it is convinient to hide full dep_status from them.  */
+   of the dependency, it is convenient to hide full dep_status from them.  */
 void
 init_dep (dep_t dep, rtx pro, rtx con, enum reg_note kind)
 {
@@ -493,21 +493,6 @@ deps_may_trap_p (rtx mem)
   return rtx_addr_can_trap_p (addr);
 }
 \f
-/* Return the INSN_LIST containing INSN in LIST, or NULL
-   if LIST does not contain INSN.  */
-
-rtx
-find_insn_list (rtx insn, rtx list)
-{
-  while (list)
-    {
-      if (XEXP (list, 0) == insn)
-       return list;
-      list = XEXP (list, 1);
-    }
-  return 0;
-}
-\f
 /* Find the condition under which INSN is executed.  */
 
 static rtx
@@ -1032,11 +1017,26 @@ fixup_sched_groups (rtx insn)
    so that we can do memory aliasing on it.  */
 
 static void
-add_insn_mem_dependence (struct deps *deps, rtx *insn_list, rtx *mem_list,
+add_insn_mem_dependence (struct deps *deps, bool read_p,
                         rtx insn, rtx mem)
 {
+  rtx *insn_list;
+  rtx *mem_list;
   rtx link;
 
+  if (read_p)
+    {
+      insn_list = &deps->pending_read_insns;
+      mem_list = &deps->pending_read_mems;
+      deps->pending_read_list_length++;
+    }
+  else
+    {
+      insn_list = &deps->pending_write_insns;
+      mem_list = &deps->pending_write_mems;
+      deps->pending_write_list_length++;
+    }
+
   link = alloc_INSN_LIST (insn, *insn_list);
   *insn_list = link;
 
@@ -1047,8 +1047,6 @@ add_insn_mem_dependence (struct deps *deps, rtx *insn_list, rtx *mem_list,
     }
   link = alloc_EXPR_LIST (VOIDmode, canon_rtx (mem), *mem_list);
   *mem_list = link;
-
-  deps->pending_lists_length++;
 }
 
 /* Make a dependency between every memory reference on the pending lists
@@ -1064,12 +1062,13 @@ flush_pending_lists (struct deps *deps, rtx insn, int for_read,
       add_dependence_list_and_free (insn, &deps->pending_read_insns, 1,
                                    REG_DEP_ANTI);
       free_EXPR_LIST_list (&deps->pending_read_mems);
+      deps->pending_read_list_length = 0;
     }
 
   add_dependence_list_and_free (insn, &deps->pending_write_insns, 1,
                                for_read ? REG_DEP_ANTI : REG_DEP_OUTPUT);
   free_EXPR_LIST_list (&deps->pending_write_mems);
-  deps->pending_lists_length = 0;
+  deps->pending_write_list_length = 0;
 
   add_dependence_list_and_free (insn, &deps->last_pending_memory_flush, 1,
                                for_read ? REG_DEP_ANTI : REG_DEP_OUTPUT);
@@ -1233,7 +1232,8 @@ sched_analyze_1 (struct deps *deps, rtx x, rtx insn)
        }
       t = canon_rtx (t);
 
-      if (deps->pending_lists_length > MAX_PENDING_LIST_LENGTH)
+      if ((deps->pending_read_list_length + deps->pending_write_list_length)
+         > MAX_PENDING_LIST_LENGTH)
        {
          /* Flush all pending reads and writes to prevent the pending lists
             from getting any larger.  Insn scheduling runs too slowly when
@@ -1273,8 +1273,7 @@ sched_analyze_1 (struct deps *deps, rtx x, rtx insn)
          add_dependence_list (insn, deps->last_pending_memory_flush, 1,
                               REG_DEP_ANTI);
 
-         add_insn_mem_dependence (deps, &deps->pending_write_insns,
-                                  &deps->pending_write_mems, insn, dest);
+         add_insn_mem_dependence (deps, false, insn, dest);
        }
       sched_analyze_2 (deps, XEXP (dest, 0), insn);
     }
@@ -1395,8 +1394,7 @@ sched_analyze_2 (struct deps *deps, rtx x, rtx insn)
 
        /* Always add these dependencies to pending_reads, since
           this insn may be followed by a write.  */
-       add_insn_mem_dependence (deps, &deps->pending_read_insns,
-                                &deps->pending_read_mems, insn, x);
+       add_insn_mem_dependence (deps, true, insn, x);
 
        /* Take advantage of tail recursion here.  */
        sched_analyze_2 (deps, XEXP (x, 0), insn);
@@ -2096,7 +2094,8 @@ init_deps (struct deps *deps)
   deps->pending_read_mems = 0;
   deps->pending_write_insns = 0;
   deps->pending_write_mems = 0;
-  deps->pending_lists_length = 0;
+  deps->pending_read_list_length = 0;
+  deps->pending_write_list_length = 0;
   deps->pending_flush_length = 0;
   deps->last_pending_memory_flush = 0;
   deps->last_function_call = 0;
@@ -2425,7 +2424,7 @@ add_back_forw_dep (rtx insn, rtx elem, enum reg_note dep_type, ds_t ds)
     gcc_assert (deps_list_consistent_p (INSN_BACK_DEPS (insn)));
 }
 
-/* Remove a dependency refered by L.  */
+/* Remove a dependency referred to by L.  */
 void
 delete_back_forw_dep (dep_link_t l)
 {