cfgbuild.c (make_edges): Use tablejump_p.
authorRichard Henderson <rth@redhat.com>
Sun, 30 Mar 2003 20:46:57 +0000 (12:46 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Sun, 30 Mar 2003 20:46:57 +0000 (12:46 -0800)
        * cfgbuild.c (make_edges): Use tablejump_p.
        * cfgcleanup.c (label_is_jump_target_p): Likewise.
        * cfglayout.c (cfg_layout_can_duplicate_bb_p): Likewise.
        * cfgrtl.c (flow_delete_block_noexpunge): Likewise.
        (try_redirect_by_replacing_jump): Likewise.
        (redirect_edge_and_branch): Likewise.
        * cse.c (fold_rtx): Likewise.
        * jump.c (delete_related_insns): Likewise.
        * rtlanal.c (get_jump_table_offset): Likewise.
        * ssa-ccp.c (ssa_ccp_df_delete_unreachable_insns): Likewise.

From-SVN: r65054

gcc/ChangeLog
gcc/cfgbuild.c
gcc/cfgcleanup.c
gcc/cfglayout.c
gcc/cfgrtl.c
gcc/cse.c
gcc/jump.c
gcc/rtlanal.c
gcc/ssa-ccp.c

index 4599a07564499326a1ac150e2ca4cd3adb47949a..3b02fd168b1692bf58a4688fda10c66b0f2b6343 100644 (file)
@@ -1,3 +1,16 @@
+2003-03-30  Richard Henderson  <rth@redhat.com>
+
+       * cfgbuild.c (make_edges): Use tablejump_p.
+       * cfgcleanup.c (label_is_jump_target_p): Likewise.
+       * cfglayout.c (cfg_layout_can_duplicate_bb_p): Likewise.
+       * cfgrtl.c (flow_delete_block_noexpunge): Likewise.
+       (try_redirect_by_replacing_jump): Likewise.
+       (redirect_edge_and_branch): Likewise.
+       * cse.c (fold_rtx): Likewise.
+       * jump.c (delete_related_insns): Likewise.
+       * rtlanal.c (get_jump_table_offset): Likewise.
+       * ssa-ccp.c (ssa_ccp_df_delete_unreachable_insns): Likewise.
+
 2003-03-30  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
         * Makefile.in (STRICT_WARN): Don't warn for ISO C constructs.
index d698f3b057a2142d4ceccdf10541c43142618caf..889ae9da23ddaf37ca10cf209c0fb3855ad8595a 100644 (file)
@@ -343,12 +343,8 @@ make_edges (label_value_list, min, max, update_p)
          else if (find_reg_note (insn, REG_NON_LOCAL_GOTO, NULL_RTX))
            ;
 
-         /* ??? Recognize a tablejump and do the right thing.  */
-         else if ((tmp = JUMP_LABEL (insn)) != NULL_RTX
-                  && (tmp = NEXT_INSN (tmp)) != NULL_RTX
-                  && GET_CODE (tmp) == JUMP_INSN
-                  && (GET_CODE (PATTERN (tmp)) == ADDR_VEC
-                      || GET_CODE (PATTERN (tmp)) == ADDR_DIFF_VEC))
+         /* Recognize a tablejump and do the right thing.  */
+         else if (tablejump_p (insn, NULL, &tmp))
            {
              rtvec vec;
              int j;
index 23436d599f102420ee2e4a2bb32906c8b79ee09b..8ca6c41c3f21d639a43b0d2797f2e27ff702b27a 100644 (file)
@@ -656,12 +656,7 @@ label_is_jump_target_p (label, jump_insn)
   if (label == tmp)
     return true;
 
-  if (tmp != NULL_RTX
-      && (tmp = NEXT_INSN (tmp)) != NULL_RTX
-      && GET_CODE (tmp) == JUMP_INSN
-      && (tmp = PATTERN (tmp),
-         GET_CODE (tmp) == ADDR_VEC
-         || GET_CODE (tmp) == ADDR_DIFF_VEC))
+  if (tablejump_p (jump_insn, NULL, &tmp))
     {
       rtvec vec = XVEC (tmp, GET_CODE (tmp) == ADDR_DIFF_VEC);
       int i, veclen = GET_NUM_ELEM (vec);
index c95ac3845356e6b7b3b921581b1caf24a05d378d..b5be7ca29b32f67a498149e8761cb091607f60bb 100644 (file)
@@ -760,7 +760,6 @@ bool
 cfg_layout_can_duplicate_bb_p (bb)
      basic_block bb;
 {
-  rtx next;
   edge s;
 
   if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR)
@@ -775,11 +774,7 @@ cfg_layout_can_duplicate_bb_p (bb)
   /* Do not attempt to duplicate tablejumps, as we need to unshare
      the dispatch table.  This is difficult to do, as the instructions
      computing jump destination may be hoisted outside the basic block.  */
-  if (GET_CODE (bb->end) == JUMP_INSN && JUMP_LABEL (bb->end)
-      && (next = next_nonnote_insn (JUMP_LABEL (bb->end)))
-      && GET_CODE (next) == JUMP_INSN
-      && (GET_CODE (PATTERN (next)) == ADDR_VEC
-         || GET_CODE (PATTERN (next)) == ADDR_DIFF_VEC))
+  if (tablejump_p (bb->end, NULL, NULL))
     return false;
 
   /* Do not duplicate blocks containing insns that can't be copied.  */
index 5e47236b4cea58448478ec2ed245f0ae2d4c477c..c7194b56c4a4e5ffd2c504655b946cdd81aaf027 100644 (file)
@@ -383,12 +383,7 @@ flow_delete_block_noexpunge (b)
 
   /* Include any jump table following the basic block.  */
   end = b->end;
-  if (GET_CODE (end) == JUMP_INSN
-      && (tmp = JUMP_LABEL (end)) != NULL_RTX
-      && (tmp = NEXT_INSN (tmp)) != NULL_RTX
-      && GET_CODE (tmp) == JUMP_INSN
-      && (GET_CODE (PATTERN (tmp)) == ADDR_VEC
-         || GET_CODE (PATTERN (tmp)) == ADDR_DIFF_VEC))
+  if (tablejump_p (end, NULL, &tmp))
     end = tmp;
 
   /* Include any barrier that may follow the basic block.  */
@@ -674,7 +669,7 @@ try_redirect_by_replacing_jump (e, target)
   basic_block src = e->src;
   rtx insn = src->end, kill_from;
   edge tmp;
-  rtx set, table;
+  rtx set;
   int fallthru = 0;
 
   /* Verify that all targets will be TARGET.  */
@@ -684,11 +679,7 @@ try_redirect_by_replacing_jump (e, target)
 
   if (tmp || !onlyjump_p (insn))
     return false;
-  if (flow2_completed && JUMP_LABEL (insn)
-      && (table = NEXT_INSN (JUMP_LABEL (insn))) != NULL_RTX
-      && GET_CODE (table) == JUMP_INSN
-      && (GET_CODE (PATTERN (table)) == ADDR_VEC
-         || GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC))
+  if ((!optimize || flow2_completed) && tablejump_p (insn, NULL, NULL))
     return false;
 
   /* Avoid removing branch with side effects.  */
@@ -739,7 +730,7 @@ try_redirect_by_replacing_jump (e, target)
   else
     {
       rtx target_label = block_label (target);
-      rtx barrier, tmp;
+      rtx barrier, label, table;
 
       emit_jump_insn_after (gen_jump (target_label), insn);
       JUMP_LABEL (src->end) = target_label;
@@ -754,14 +745,8 @@ try_redirect_by_replacing_jump (e, target)
       /* Recognize a tablejump that we are converting to a
         simple jump and remove its associated CODE_LABEL
         and ADDR_VEC or ADDR_DIFF_VEC.  */
-      if ((tmp = JUMP_LABEL (insn)) != NULL_RTX
-         && (tmp = NEXT_INSN (tmp)) != NULL_RTX
-         && GET_CODE (tmp) == JUMP_INSN
-         && (GET_CODE (PATTERN (tmp)) == ADDR_VEC
-             || GET_CODE (PATTERN (tmp)) == ADDR_DIFF_VEC))
-       {
-         delete_insn_chain (JUMP_LABEL (insn), tmp);
-       }
+      if (tablejump_p (insn, &label, &table))
+       delete_insn_chain (label, table);
 
       barrier = next_nonnote_insn (src->end);
       if (!barrier || GET_CODE (barrier) != BARRIER)
@@ -854,11 +839,7 @@ redirect_edge_and_branch (e, target)
     return false;
 
   /* Recognize a tablejump and adjust all matching cases.  */
-  if ((tmp = JUMP_LABEL (insn)) != NULL_RTX
-      && (tmp = NEXT_INSN (tmp)) != NULL_RTX
-      && GET_CODE (tmp) == JUMP_INSN
-      && (GET_CODE (PATTERN (tmp)) == ADDR_VEC
-         || GET_CODE (PATTERN (tmp)) == ADDR_DIFF_VEC))
+  if (tablejump_p (insn, NULL, &tmp))
     {
       rtvec vec;
       int j;
index 9f6b96d20ceb328baef3ec8688aac95cfe963951..94eb8d0018806c9ca9a8e0b61344958d1a1606bd 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -3352,17 +3352,11 @@ fold_rtx (x, insn)
       /* If the next insn is a CODE_LABEL followed by a jump table,
         PC's value is a LABEL_REF pointing to that label.  That
         lets us fold switch statements on the VAX.  */
-      if (insn && GET_CODE (insn) == JUMP_INSN)
-       {
-         rtx next = next_nonnote_insn (insn);
-
-         if (next && GET_CODE (next) == CODE_LABEL
-             && NEXT_INSN (next) != 0
-             && GET_CODE (NEXT_INSN (next)) == JUMP_INSN
-             && (GET_CODE (PATTERN (NEXT_INSN (next))) == ADDR_VEC
-                 || GET_CODE (PATTERN (NEXT_INSN (next))) == ADDR_DIFF_VEC))
-           return gen_rtx_LABEL_REF (Pmode, next);
-       }
+      {
+       rtx next;
+       if (tablejump_p (insn, &next, NULL))
+         return gen_rtx_LABEL_REF (Pmode, next);
+      }
       break;
 
     case SUBREG:
index 15c9d36618f53dc09cb30a7d752d0425208d03c6..6e0479081581193ee679bea570eb496ecd9c6439 100644 (file)
@@ -1757,10 +1757,7 @@ delete_related_insns (insn)
            next = NEXT_INSN (next);
          return next;
        }
-      else if ((lab_next = next_nonnote_insn (lab)) != NULL
-              && GET_CODE (lab_next) == JUMP_INSN
-              && (GET_CODE (PATTERN (lab_next)) == ADDR_VEC
-                  || GET_CODE (PATTERN (lab_next)) == ADDR_DIFF_VEC))
+      else if (tablejump_p (insn, NULL, &lab_next))
        {
          /* If we're deleting the tablejump, delete the dispatch table.
             We may not be able to kill the label immediately preceding
index dc87e451ac372ea5e4c5d9a6db783339274e7ce8..f7923c2a87dbea55087c0498834e7c67cc1c25e3 100644 (file)
@@ -466,13 +466,7 @@ get_jump_table_offset (insn, earliest)
   rtx old_y;
   int i;
 
-  if (GET_CODE (insn) != JUMP_INSN
-      || ! (label = JUMP_LABEL (insn))
-      || ! (table = NEXT_INSN (label))
-      || GET_CODE (table) != JUMP_INSN
-      || (GET_CODE (PATTERN (table)) != ADDR_VEC
-         && GET_CODE (PATTERN (table)) != ADDR_DIFF_VEC)
-      || ! (set = single_set (insn)))
+  if (!tablejump_p (insn, &label, &table) || !(set = single_set (insn)))
     return NULL_RTX;
 
   x = SET_SRC (set);
index 085f18f27f8335636015bd063b93a9faf27b546c..abd557e3242576c07df2934a18b62efc85875221 100644 (file)
@@ -948,12 +948,7 @@ ssa_ccp_df_delete_unreachable_insns ()
 
          /* Include any jump table following the basic block.  */
          end = b->end;
-         if (GET_CODE (end) == JUMP_INSN
-             && (tmp = JUMP_LABEL (end)) != NULL_RTX
-             && (tmp = NEXT_INSN (tmp)) != NULL_RTX
-             && GET_CODE (tmp) == JUMP_INSN
-             && (GET_CODE (PATTERN (tmp)) == ADDR_VEC
-                 || GET_CODE (PATTERN (tmp)) == ADDR_DIFF_VEC))
+         if (tablejump_p (end, NULL, &tmp))
            end = tmp;
 
          while (1)