From: David S. Miller Date: Sun, 30 Oct 2011 07:48:05 +0000 (+0000) Subject: Properly limit backwards label scanning in reorg. X-Git-Tag: releases/gcc-4.7.0~2706 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dbeee82924bc45e9990c2205e2768a52ffda5fbf;p=thirdparty%2Fgcc.git Properly limit backwards label scanning in reorg. * reorg.c (label_before_next_insn): New function. (relax_delay_slots): Use it instead of prev_label. * rtl.h (prev_label): Delete declaration. * emit-rtl.c (prev_label): Remove. From-SVN: r180674 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0eb34e5efad1..e9bda2b793a7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-10-30 David S. Miller + + * reorg.c (label_before_next_insn): New function. + (relax_delay_slots): Use it instead of prev_label. + * rtl.h (prev_label): Delete declaration. + * emit-rtl.c (prev_label): Remove. + 2011-10-30 Revital Eres * modulo-sched.c (generate_prolog_epilog): Mark prolog and epilog diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 8465237da60f..c2bc56b9758f 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -3330,21 +3330,6 @@ next_label (rtx insn) return insn; } -/* Return the last CODE_LABEL before the insn INSN, or 0 if there is none. */ - -rtx -prev_label (rtx insn) -{ - while (insn) - { - insn = PREV_INSN (insn); - if (insn == 0 || LABEL_P (insn)) - break; - } - - return insn; -} - /* Return the last label to mark the same position as LABEL. Return LABEL itself if it is null or any return rtx. */ diff --git a/gcc/reorg.c b/gcc/reorg.c index f77a3a0f1d09..40d73a76a717 100644 --- a/gcc/reorg.c +++ b/gcc/reorg.c @@ -3349,6 +3349,21 @@ delete_jump (rtx insn) delete_computation (insn); } +static rtx +label_before_next_insn (rtx x, rtx scan_limit) +{ + rtx insn = next_active_insn (x); + while (insn) + { + insn = PREV_INSN (insn); + if (insn == scan_limit || insn == NULL_RTX) + return NULL_RTX; + if (LABEL_P (insn)) + break; + } + return insn; +} + /* Once we have tried two ways to fill a delay slot, make a pass over the code to try to improve the results and to do such things as more jump @@ -3634,7 +3649,7 @@ relax_delay_slots (rtx first) identical to the one in its delay slot. In this case, we can just delete the branch and the insn in its delay slot. */ if (next && NONJUMP_INSN_P (next) - && prev_label (next_active_insn (next)) == target_label + && label_before_next_insn (next, insn) == target_label && simplejump_p (insn) && XVECLEN (pat, 0) == 2 && rtx_equal_p (PATTERN (next), PATTERN (XVECEXP (pat, 0, 1)))) diff --git a/gcc/rtl.h b/gcc/rtl.h index 81958a59c2ef..41536bea02c0 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1812,7 +1812,6 @@ extern rtx next_real_insn (rtx); extern rtx prev_active_insn (rtx); extern rtx next_active_insn (rtx); extern int active_insn_p (const_rtx); -extern rtx prev_label (rtx); extern rtx next_label (rtx); extern rtx skip_consecutive_labels (rtx); extern rtx next_cc0_user (rtx);