diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 180fc69f843..1a78a427f4c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-07-21 Josef Zlomek + + * cfgcleanup.c (merge_blocks_move_successor_nojumps): Use tablejump_p. + * rtlanal.c (tablejump_p): Use next_active_insn for finding the jump + table. + 2003-07-17 Eric Botcazou PR optimization/11536 diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 7dbed9b9705..d03a16d88f9 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -714,25 +714,20 @@ static void merge_blocks_move_successor_nojumps (basic_block a, basic_block b) { rtx barrier, real_b_end; + rtx label, table; real_b_end = b->end; - barrier = NEXT_INSN (b->end); - /* Recognize a jump table following block B. */ - if (barrier - && GET_CODE (barrier) == CODE_LABEL - && NEXT_INSN (barrier) - && GET_CODE (NEXT_INSN (barrier)) == JUMP_INSN - && (GET_CODE (PATTERN (NEXT_INSN (barrier))) == ADDR_VEC - || GET_CODE (PATTERN (NEXT_INSN (barrier))) == ADDR_DIFF_VEC)) + /* If there is a jump table following block B temporarily add the jump table + to block B so that it will also be moved to the correct location. */ + if (tablejump_p (b->end, &label, &table) + && prev_active_insn (label) == b->end) { - /* Temporarily add the table jump insn to b, so that it will also - be moved to the correct location. */ - b->end = NEXT_INSN (barrier); - barrier = NEXT_INSN (b->end); + b->end = table; } /* There had better have been a barrier there. Delete it. */ + barrier = NEXT_INSN (b->end); if (barrier && GET_CODE (barrier) == BARRIER) delete_insn (barrier); diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index a7d410267d6..55c1020f3fb 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -2795,26 +2795,25 @@ rtx_referenced_p (rtx x, rtx body) return for_each_rtx (&body, rtx_referenced_p_1, x); } -/* If INSN is a jump to jumptable insn rturn true and store the label (which - INSN jumps to) to *LABEL and the tablejump insn to *TABLE. - LABEL and TABLE may be NULL. */ +/* If INSN is a tablejump return true and store the label (before jump table) to + *LABELP and the jump table to *TABLEP. LABELP and TABLEP may be NULL. */ bool -tablejump_p (rtx insn, rtx *label, rtx *table) +tablejump_p (rtx insn, rtx *labelp, rtx *tablep) { - rtx l, t; + rtx label, table; - if (onlyjump_p (insn) - && (l = JUMP_LABEL (insn)) != NULL_RTX - && (t = NEXT_INSN (l)) != NULL_RTX - && GET_CODE (t) == JUMP_INSN - && (GET_CODE (PATTERN (t)) == ADDR_VEC - || GET_CODE (PATTERN (t)) == ADDR_DIFF_VEC)) + if (GET_CODE (insn) == JUMP_INSN + && (label = JUMP_LABEL (insn)) != NULL_RTX + && (table = next_active_insn (label)) != NULL_RTX + && GET_CODE (table) == JUMP_INSN + && (GET_CODE (PATTERN (table)) == ADDR_VEC + || GET_CODE (PATTERN (table)) == ADDR_DIFF_VEC)) { - if (label) - *label = l; - if (table) - *table = t; + if (labelp) + *labelp = label; + if (tablep) + *tablep = table; return true; } return false;