Commit 0720f6fb by Mark Mitchell Committed by Jeff Law

stmt.c (expand_end_loop): Tidy.

        * stmt.c (expand_end_loop): Tidy.  Allow unconditional
        jumps out of the loop to be treated as part of the exit test.

From-SVN: r21782
parent 804a4e13
Mon Aug 17 10:28:52 1998 Mark Mitchell <mark@markmitchell.com>
* stmt.c (expand_end_loop): Tidy. Allow unconditional
jumps out of the loop to be treated as part of the exit test.
Mon Aug 17 10:06:11 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> Mon Aug 17 10:06:11 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
Jeff Law <law@cygnus.com> Jeff Law <law@cygnus.com>
......
...@@ -1911,13 +1911,8 @@ expand_loop_continue_here () ...@@ -1911,13 +1911,8 @@ expand_loop_continue_here ()
void void
expand_end_loop () expand_end_loop ()
{ {
register rtx insn; rtx start_label = loop_stack->data.loop.start_label;
register rtx start_label; rtx insn = get_last_insn ();
rtx last_test_insn = 0;
int num_insns = 0;
insn = get_last_insn ();
start_label = loop_stack->data.loop.start_label;
/* Mark the continue-point at the top of the loop if none elsewhere. */ /* Mark the continue-point at the top of the loop if none elsewhere. */
if (start_label == loop_stack->data.loop.continue_label) if (start_label == loop_stack->data.loop.continue_label)
...@@ -1938,7 +1933,7 @@ expand_end_loop () ...@@ -1938,7 +1933,7 @@ expand_end_loop ()
if (test) goto end_label; if (test) goto end_label;
body; body;
goto start_label; goto start_label;
end_label; end_label:
transform it to look like: transform it to look like:
...@@ -1948,10 +1943,11 @@ expand_end_loop () ...@@ -1948,10 +1943,11 @@ expand_end_loop ()
start_label: start_label:
if (test) goto end_label; if (test) goto end_label;
goto newstart_label; goto newstart_label;
end_label; end_label:
Here, the `test' may actually consist of some reasonably complex Here, the `test' may actually consist of some reasonably complex
code, terminating in a test. */ code, terminating in a test. */
if (optimize if (optimize
&& &&
! (GET_CODE (insn) == JUMP_INSN ! (GET_CODE (insn) == JUMP_INSN
...@@ -1960,6 +1956,8 @@ expand_end_loop () ...@@ -1960,6 +1956,8 @@ expand_end_loop ()
&& GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE)) && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE))
{ {
int eh_regions = 0; int eh_regions = 0;
int num_insns = 0;
rtx last_test_insn = NULL_RTX;
/* Scan insns from the top of the loop looking for a qualified /* Scan insns from the top of the loop looking for a qualified
conditional exit. */ conditional exit. */
...@@ -2036,31 +2034,46 @@ expand_end_loop () ...@@ -2036,31 +2034,46 @@ expand_end_loop ()
So we don't look for tests within an EH region. */ So we don't look for tests within an EH region. */
continue; continue;
if (GET_CODE (insn) == JUMP_INSN && GET_CODE (PATTERN (insn)) == SET if (GET_CODE (insn) == JUMP_INSN
&& SET_DEST (PATTERN (insn)) == pc_rtx
&& GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE
&& ((GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 1)) == LABEL_REF
&& ((XEXP (XEXP (SET_SRC (PATTERN (insn)), 1), 0)
== loop_stack->data.loop.end_label)
|| (XEXP (XEXP (SET_SRC (PATTERN (insn)), 1), 0)
== loop_stack->data.loop.alt_end_label)))
|| (GET_CODE (XEXP (SET_SRC (PATTERN (insn)), 2)) == LABEL_REF
&& ((XEXP (XEXP (SET_SRC (PATTERN (insn)), 2), 0)
== loop_stack->data.loop.end_label)
|| (XEXP (XEXP (SET_SRC (PATTERN (insn)), 2), 0)
== loop_stack->data.loop.alt_end_label)))))
last_test_insn = insn;
if (last_test_insn == 0 && GET_CODE (insn) == JUMP_INSN
&& GET_CODE (PATTERN (insn)) == SET && GET_CODE (PATTERN (insn)) == SET
&& SET_DEST (PATTERN (insn)) == pc_rtx && SET_DEST (PATTERN (insn)) == pc_rtx)
&& GET_CODE (SET_SRC (PATTERN (insn))) == LABEL_REF {
&& ((XEXP (SET_SRC (PATTERN (insn)), 0) /* This is indeed a jump. */
== loop_stack->data.loop.end_label) rtx dest1 = NULL_RTX;
|| (XEXP (SET_SRC (PATTERN (insn)), 0) rtx dest2 = NULL_RTX;
== loop_stack->data.loop.alt_end_label))) rtx potential_last_test;
/* Include BARRIER. */ if (GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE)
last_test_insn = NEXT_INSN (insn); {
/* A conditional jump. */
dest1 = XEXP (SET_SRC (PATTERN (insn)), 1);
dest2 = XEXP (SET_SRC (PATTERN (insn)), 2);
potential_last_test = insn;
}
else
{
/* An unconditional jump. */
dest1 = SET_SRC (PATTERN (insn));
/* Include the BARRIER after the JUMP. */
potential_last_test = NEXT_INSN (insn);
}
do {
if (dest1 && GET_CODE (dest1) == LABEL_REF
&& ((XEXP (dest1, 0)
== loop_stack->data.loop.alt_end_label)
|| (XEXP (dest1, 0)
== loop_stack->data.loop.end_label)))
{
last_test_insn = potential_last_test;
break;
}
/* If this was a conditional jump, there may be
another label at which we should look. */
dest1 = dest2;
dest2 = NULL_RTX;
} while (dest1);
}
} }
if (last_test_insn != 0 && last_test_insn != get_last_insn ()) if (last_test_insn != 0 && last_test_insn != get_last_insn ())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment