From edf711a4e4e345ea0c165d7ad3b823b81360d43a Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Wed, 26 Jul 1995 08:43:24 -0400 Subject: [PATCH] (find_and_verify_loops): When moving blocks of code, verify that the just destination is not in an inner nested loop. (find_and_verify_loops): When moving blocks of code, verify that the just destination is not in an inner nested loop. (mark_loop_jump): Don't mark label as loop exit if it jumps to an inner nested loop. From-SVN: r10164 --- gcc/loop.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/gcc/loop.c b/gcc/loop.c index 027e1aa9e8d..2729450a389 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -2338,6 +2338,8 @@ find_and_verify_loops (f) { rtx p; rtx our_next = next_real_insn (insn); + int dest_loop = uid_loop_num[INSN_UID (JUMP_LABEL (insn))]; + int outer_loop; /* Go backwards until we reach the start of the loop, a label, or a JUMP_INSN. */ @@ -2349,6 +2351,19 @@ find_and_verify_loops (f) p = PREV_INSN (p)) ; + /* Check for the case where we have a jump to an inner nested + loop, and do not perform the optimization in that case. */ + + if (dest_loop != -1) + { + for (outer_loop = dest_loop; outer_loop != -1; + outer_loop = loop_outer_loop[outer_loop]) + if (outer_loop == this_loop_num) + break; + } + else + outer_loop = -1; + /* If we stopped on a JUMP_INSN to the next insn after INSN, we have a block of code to try to move. @@ -2358,7 +2373,8 @@ find_and_verify_loops (f) of the block, invert the jump in P and point it to that label, and move the block of code to the spot we found. */ - if (GET_CODE (p) == JUMP_INSN + if (outer_loop == -1 + && GET_CODE (p) == JUMP_INSN && JUMP_LABEL (p) != 0 /* Just ignore jumps to labels that were never emitted. These always indicate compilation errors. */ @@ -2522,7 +2538,19 @@ mark_loop_jump (x, loop_num) mark this LABEL_REF so we know that this branch should predict false. */ - if (dest_loop != loop_num && loop_num != -1) + /* A check to make sure the label is not in an inner nested loop, + since this does not count as a loop exit. */ + if (dest_loop != -1) + { + for (outer_loop = dest_loop; outer_loop != -1; + outer_loop = loop_outer_loop[outer_loop]) + if (outer_loop == loop_num) + break; + } + else + outer_loop = -1; + + if (loop_num != -1 && outer_loop == -1) { LABEL_OUTSIDE_LOOP_P (x) = 1; LABEL_NEXTREF (x) = loop_number_exit_labels[loop_num]; -- 2.30.2