PR middle-end/20648
authorsteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 3 Apr 2005 11:26:41 +0000 (11:26 +0000)
committersteven <steven@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 3 Apr 2005 11:26:41 +0000 (11:26 +0000)
        * bb-reorder.c (duplicate_computed_gotos): Do not unfactor
        a computed goto if the edge to the computed goto block has
        incoming abnormal edges.  Clarify how the function works.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@97486 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/bb-reorder.c

index 0ed9106..fad5db2 100644 (file)
@@ -1,3 +1,10 @@
+2005-04-03  Steven Bosscher  <stevenb@suse.de>
+
+       PR middle-end/20648
+       * bb-reorder.c (duplicate_computed_gotos): Do not unfactor
+       a computed goto if the edge to the computed goto block has
+       incoming abnormal edges.  Clarify how the function works.
+
 2005-04-03  Nathan Sidwell  <nathan@codesourcery.com>
 
        * params.c (set_param_value): Use gcc_assert & gcc_unreachable.
        last_text_section_name as appropriate.
        (function_section): Change test for 'unlikely' to depend on
        first_function_block_is_cold (moved old test to 
-        current_function_section).
+       current_function_section).
        (current_function_section): New function.
        (assemble_start_function): Move code that frees 
        unlikely_text_section_name; initialize hot_section_end_label; 
 
 2005-03-31  Olivier Hainque  <hainque@adacore.com>
 
-        * dwarf2out.c (dwarf2out_frame_finish): Honor DWARF2_FRAME_INFO
-        defined and non-zero.
+       * dwarf2out.c (dwarf2out_frame_finish): Honor DWARF2_FRAME_INFO
+       defined and non-zero.
 
 2005-03-31  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
index f540ab1..6925114 100644 (file)
@@ -2013,33 +2013,49 @@ duplicate_computed_gotos (void)
   max_size = uncond_jump_length * PARAM_VALUE (PARAM_MAX_GOTO_DUPLICATION_INSNS);
   candidates = BITMAP_ALLOC (NULL);
 
-  /* Build the reorder chain for the original order of blocks.
-     Look for a computed jump while we are at it.  */
+  /* Look for blocks that end in a computed jump, and see if such blocks
+     are suitable for unfactoring.  If a block is a candidate for unfactoring,
+     mark it in the candidates.  */
   FOR_EACH_BB (bb)
     {
+      rtx insn;
+      edge e;
+      edge_iterator ei;
+      int size, all_flags;
+
+      /* Build the reorder chain for the original order of blocks.  */
       if (bb->next_bb != EXIT_BLOCK_PTR)
        bb->rbi->next = bb->next_bb;
 
-      /* If the block ends in a computed jump and it is small enough,
-        make it a candidate for duplication.  */
-      if (computed_jump_p (BB_END (bb))
-         && !find_reg_note (BB_END (bb), REG_CROSSING_JUMP, NULL_RTX))
-       {
-         rtx insn;
-         int size = 0;
+      /* Obviously the block has to end in a computed jump.  */
+      if (!computed_jump_p (BB_END (bb)))
+       continue;
 
-         FOR_BB_INSNS (bb, insn)
-           if (INSN_P (insn))
-             {
-               size += get_attr_length (insn);
-               if (size > max_size)
-                 break;
-             }
+      /* Only consider blocks that can be duplicated.  */
+      if (find_reg_note (BB_END (bb), REG_CROSSING_JUMP, NULL_RTX)
+         || !can_duplicate_block_p (bb))
+       continue;
 
-         if (size <= max_size
-             && can_duplicate_block_p (bb))
-           bitmap_set_bit (candidates, bb->index);
-       }
+      /* Make sure that the block is small enough.  */
+      size = 0;
+      FOR_BB_INSNS (bb, insn)
+       if (INSN_P (insn))
+         {
+           size += get_attr_length (insn);
+           if (size > max_size)
+              break;
+         }
+      if (size > max_size)
+       continue;
+
+      /* Final check: there must not be any incoming abnormal edges.  */
+      all_flags = 0;
+      FOR_EACH_EDGE (e, ei, bb->preds)
+       all_flags |= e->flags;
+      if (all_flags & EDGE_COMPLEX)
+       continue;
+
+      bitmap_set_bit (candidates, bb->index);
     }
 
   /* Nothing to do if there is no computed jump here.  */