OSDN Git Service

PR middle-end/28071
[pf3gnuchains/gcc-fork.git] / gcc / sched-rgn.c
index 47d0a9a..79129bb 100644 (file)
@@ -1711,12 +1711,12 @@ update_live (rtx insn, int src)
 static void
 set_spec_fed (rtx load_insn)
 {
-  rtx link;
+  dep_link_t link;
 
-  for (link = INSN_DEPEND (load_insn); link; link = XEXP (link, 1))
-    if (GET_MODE (link) == VOIDmode)
-      FED_BY_SPEC_LOAD (XEXP (link, 0)) = 1;
-}                              /* set_spec_fed */
+  FOR_EACH_DEP_LINK (link, INSN_FORW_DEPS (load_insn))
+    if (DEP_LINK_KIND (link) == REG_DEP_TRUE)
+      FED_BY_SPEC_LOAD (DEP_LINK_CON (link)) = 1;
+}
 
 /* On the path from the insn to load_insn_bb, find a conditional
 branch depending on insn, that guards the speculative load.  */
@@ -1724,17 +1724,18 @@ branch depending on insn, that guards the speculative load.  */
 static int
 find_conditional_protection (rtx insn, int load_insn_bb)
 {
-  rtx link;
+  dep_link_t link;
 
   /* Iterate through DEF-USE forward dependences.  */
-  for (link = INSN_DEPEND (insn); link; link = XEXP (link, 1))
+  FOR_EACH_DEP_LINK (link, INSN_FORW_DEPS (insn))
     {
-      rtx next = XEXP (link, 0);
+      rtx next = DEP_LINK_CON (link);
+
       if ((CONTAINING_RGN (BLOCK_NUM (next)) ==
           CONTAINING_RGN (BB_TO_BLOCK (load_insn_bb)))
          && IS_REACHABLE (INSN_BB (next), load_insn_bb)
          && load_insn_bb != INSN_BB (next)
-         && GET_MODE (link) == VOIDmode
+         && DEP_LINK_KIND (link) == REG_DEP_TRUE
          && (JUMP_P (next)
              || find_conditional_protection (next, load_insn_bb)))
        return 1;
@@ -1753,20 +1754,20 @@ find_conditional_protection (rtx insn, int load_insn_bb)
    and if insn1 is on the path
    region-entry -> ... -> bb_trg -> ... load_insn.
 
-   Locate insn1 by climbing on LOG_LINKS from load_insn.
-   Locate the branch by following INSN_DEPEND from insn1.  */
+   Locate insn1 by climbing on INSN_BACK_DEPS from load_insn.
+   Locate the branch by following INSN_FORW_DEPS from insn1.  */
 
 static int
 is_conditionally_protected (rtx load_insn, int bb_src, int bb_trg)
 {
-  rtx link;
+  dep_link_t link;
 
-  for (link = LOG_LINKS (load_insn); link; link = XEXP (link, 1))
+  FOR_EACH_DEP_LINK (link, INSN_BACK_DEPS (load_insn))
     {
-      rtx insn1 = XEXP (link, 0);
+      rtx insn1 = DEP_LINK_PRO (link);
 
       /* Must be a DEF-USE dependence upon non-branch.  */
-      if (GET_MODE (link) != VOIDmode
+      if (DEP_LINK_KIND (link) != REG_DEP_TRUE
          || JUMP_P (insn1))
        continue;
 
@@ -1809,28 +1810,27 @@ is_conditionally_protected (rtx load_insn, int bb_src, int bb_trg)
 static int
 is_pfree (rtx load_insn, int bb_src, int bb_trg)
 {
-  rtx back_link;
+  dep_link_t back_link;
   candidate *candp = candidate_table + bb_src;
 
   if (candp->split_bbs.nr_members != 1)
     /* Must have exactly one escape block.  */
     return 0;
 
-  for (back_link = LOG_LINKS (load_insn);
-       back_link; back_link = XEXP (back_link, 1))
+  FOR_EACH_DEP_LINK (back_link, INSN_BACK_DEPS (load_insn))
     {
-      rtx insn1 = XEXP (back_link, 0);
+      rtx insn1 = DEP_LINK_PRO (back_link);
 
-      if (GET_MODE (back_link) == VOIDmode)
+      if (DEP_LINK_KIND (back_link) == REG_DEP_TRUE)
        {
          /* Found a DEF-USE dependence (insn1, load_insn).  */
-         rtx fore_link;
+         dep_link_t fore_link;
 
-         for (fore_link = INSN_DEPEND (insn1);
-              fore_link; fore_link = XEXP (fore_link, 1))
+         FOR_EACH_DEP_LINK (fore_link, INSN_FORW_DEPS (insn1))
            {
-             rtx insn2 = XEXP (fore_link, 0);
-             if (GET_MODE (fore_link) == VOIDmode)
+             rtx insn2 = DEP_LINK_CON (fore_link);
+
+             if (DEP_LINK_KIND (fore_link) == REG_DEP_TRUE)
                {
                  /* Found a DEF-USE dependence (insn1, insn2).  */
                  if (haifa_classify_insn (insn2) != PFREE_CANDIDATE)
@@ -1863,7 +1863,7 @@ is_prisky (rtx load_insn, int bb_src, int bb_trg)
   if (FED_BY_SPEC_LOAD (load_insn))
     return 1;
 
-  if (LOG_LINKS (load_insn) == NULL)
+  if (deps_list_empty_p (INSN_BACK_DEPS (load_insn)))
     /* Dependence may 'hide' out of the region.  */
     return 1;
 
@@ -2284,7 +2284,9 @@ add_branch_dependences (rtx head, rtx tail)
     {
       if (!NOTE_P (insn))
        {
-         if (last != 0 && !find_insn_list (insn, LOG_LINKS (last)))
+         if (last != 0
+             && (find_link_by_pro_in_deps_list (INSN_BACK_DEPS (last), insn)
+                 == NULL))
            {
              if (! sched_insns_conditions_mutex_p (last, insn))
                add_dependence (last, insn, REG_DEP_ANTI);
@@ -2461,7 +2463,10 @@ propagate_deps (int bb, struct deps *pred_deps)
        = concat_INSN_LIST (pred_deps->last_pending_memory_flush,
                            succ_deps->last_pending_memory_flush);
 
-      succ_deps->pending_lists_length += pred_deps->pending_lists_length;
+      succ_deps->pending_read_list_length
+       += pred_deps->pending_read_list_length;
+      succ_deps->pending_write_list_length
+       += pred_deps->pending_write_list_length;
       succ_deps->pending_flush_length += pred_deps->pending_flush_length;
 
       /* last_function_call is inherited by successor.  */
@@ -2573,7 +2578,7 @@ debug_dependencies (void)
 
       for (insn = head; insn != next_tail; insn = NEXT_INSN (insn))
        {
-         rtx link;
+         dep_link_t link;
 
          if (! INSN_P (insn))
            {
@@ -2584,13 +2589,6 @@ debug_dependencies (void)
                  n = NOTE_LINE_NUMBER (insn);
                  if (n < 0)
                    fprintf (sched_dump, "%s\n", GET_NOTE_INSN_NAME (n));
-                 else
-                   {
-                     expanded_location xloc;
-                     NOTE_EXPANDED_LOCATION (xloc, insn);
-                     fprintf (sched_dump, "line %d, file %s\n",
-                              xloc.line, xloc.file);
-                   }
                }
              else
                fprintf (sched_dump, " {%s}\n", GET_RTX_NAME (GET_CODE (insn)));
@@ -2605,7 +2603,7 @@ debug_dependencies (void)
                   INSN_BB (insn),
                   INSN_DEP_COUNT (insn),
                   INSN_PRIORITY (insn),
-                  insn_cost (insn, 0, 0));
+                  insn_cost (insn));
 
          if (recog_memoized (insn) < 0)
            fprintf (sched_dump, "nothing");
@@ -2613,8 +2611,8 @@ debug_dependencies (void)
            print_reservation (sched_dump, insn);
 
          fprintf (sched_dump, "\t: ");
-         for (link = INSN_DEPEND (insn); link; link = XEXP (link, 1))
-           fprintf (sched_dump, "%d ", INSN_UID (XEXP (link, 0)));
+         FOR_EACH_DEP_LINK (link, INSN_FORW_DEPS (insn))
+           fprintf (sched_dump, "%d ", INSN_UID (DEP_LINK_CON (link)));
          fprintf (sched_dump, "\n");
        }
     }
@@ -2672,11 +2670,11 @@ schedule_region (int rgn)
       for (bb = 0; bb < current_nr_blocks; bb++)
        init_deps (bb_deps + bb);
 
-      /* Compute LOG_LINKS.  */
+      /* Compute backward dependencies.  */
       for (bb = 0; bb < current_nr_blocks; bb++)
         compute_block_backward_dependences (bb);
 
-      /* Compute INSN_DEPEND.  */
+      /* Compute forward dependencies.  */
       for (bb = current_nr_blocks - 1; bb >= 0; bb--)
         {
           rtx head, tail;
@@ -2768,7 +2766,6 @@ schedule_region (int rgn)
     {
       basic_block first_bb, last_bb, curr_bb;
       rtx head, tail;
-      int b = BB_TO_BLOCK (bb);
 
       first_bb = EBB_FIRST_BB (bb);
       last_bb = EBB_LAST_BB (bb);
@@ -2784,10 +2781,6 @@ schedule_region (int rgn)
       current_sched_info->prev_head = PREV_INSN (head);
       current_sched_info->next_tail = NEXT_INSN (tail);
 
-      if (write_symbols != NO_DEBUG)
-       {
-         save_line_notes (b, head, tail);
-       }
 
       /* rm_other_notes only removes notes which are _inside_ the
         block---that is, it won't remove notes before the first real insn
@@ -2838,17 +2831,6 @@ schedule_region (int rgn)
   /* Sanity check: verify that all region insns were scheduled.  */
   gcc_assert (sched_rgn_n_insns == rgn_n_insns);
 
-  /* Restore line notes.  */
-  if (write_symbols != NO_DEBUG)
-    {
-      for (bb = 0; bb < current_nr_blocks; bb++)
-       {
-         rtx head, tail;
-
-         get_ebb_head_tail (EBB_FIRST_BB (bb), EBB_LAST_BB (bb), &head, &tail);
-         restore_line_notes (head, tail);
-       }
-    }
 
   /* Done with this region.  */
 
@@ -3147,9 +3129,15 @@ add_block1 (basic_block bb, basic_block after)
         is _always_ valid for access.  */
 
       i = BLOCK_TO_BB (after->index) + 1;
-      for (pos = ebb_head[i]; rgn_bb_table[pos] != after->index; pos--);
+      pos = ebb_head[i] - 1;
+      /* Now POS is the index of the last block in the region.  */
+
+      /* Find index of basic block AFTER.  */
+      for (; rgn_bb_table[pos] != after->index; pos--);
+
       pos++;
       gcc_assert (pos > ebb_head[i - 1]);
+
       /* i - ebb right after "AFTER".  */
       /* ebb_head[i] - VALID.  */