]> gcc.gnu.org Git - gcc.git/commitdiff
stmt.c (expand_end_loop): Tidy.
authorMark Mitchell <mark@markmitchell.com>
Mon, 17 Aug 1998 09:30:15 +0000 (09:30 +0000)
committerJeff Law <law@gcc.gnu.org>
Mon, 17 Aug 1998 09:30:15 +0000 (03:30 -0600)
        * 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

gcc/ChangeLog
gcc/stmt.c

index 2a5f70a4269bb2a4ac0249e6b66cfca5c952bbfb..fae6f12c17c636e9870a850ce9a0241d65f69360 100644 (file)
@@ -1,3 +1,8 @@
+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>
                          Jeff Law <law@cygnus.com>
 
index 9ebe6705e0f629f1958458dcceac461199b9e210..61766bf13ce2c26ad1b0324feb0d53fecba825ea 100644 (file)
@@ -1911,13 +1911,8 @@ expand_loop_continue_here ()
 void
 expand_end_loop ()
 {
-  register rtx insn;
-  register rtx start_label;
-  rtx last_test_insn = 0;
-  int num_insns = 0;
-    
-  insn = get_last_insn ();
-  start_label = loop_stack->data.loop.start_label;
+  rtx start_label = loop_stack->data.loop.start_label;
+  rtx insn = get_last_insn ();
 
   /* Mark the continue-point at the top of the loop if none elsewhere.  */
   if (start_label == loop_stack->data.loop.continue_label)
@@ -1938,7 +1933,7 @@ expand_end_loop ()
          if (test) goto end_label;
         body;
         goto start_label;
-        end_label;
+        end_label:
         
      transform it to look like:
 
@@ -1948,10 +1943,11 @@ expand_end_loop ()
         start_label:
         if (test) goto end_label;
         goto newstart_label;
-        end_label;
+        end_label:
 
      Here, the `test' may actually consist of some reasonably complex
      code, terminating in a test.  */
+
   if (optimize
       &&
       ! (GET_CODE (insn) == JUMP_INSN
@@ -1960,6 +1956,8 @@ expand_end_loop ()
         && GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE))
     {
       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
         conditional exit.  */
@@ -2036,31 +2034,46 @@ expand_end_loop ()
                So we don't look for tests within an EH region.  */
            continue;
 
-         if (GET_CODE (insn) == JUMP_INSN && GET_CODE (PATTERN (insn)) == SET
-             && 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
+         if (GET_CODE (insn) == JUMP_INSN 
              && GET_CODE (PATTERN (insn)) == SET
-             && SET_DEST (PATTERN (insn)) == pc_rtx
-             && GET_CODE (SET_SRC (PATTERN (insn))) == LABEL_REF
-             && ((XEXP (SET_SRC (PATTERN (insn)), 0)
-                  == loop_stack->data.loop.end_label)
-                 || (XEXP (SET_SRC (PATTERN (insn)), 0)
-                     == loop_stack->data.loop.alt_end_label)))
-           /* Include BARRIER.  */
-           last_test_insn = NEXT_INSN (insn);
+             && SET_DEST (PATTERN (insn)) == pc_rtx)
+           {
+             /* This is indeed a jump.  */
+             rtx dest1 = NULL_RTX;
+             rtx dest2 = NULL_RTX;
+             rtx potential_last_test;
+             if (GET_CODE (SET_SRC (PATTERN (insn))) == IF_THEN_ELSE)
+               {
+                 /* 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 ())
This page took 0.088959 seconds and 5 git commands to generate.