* loop.c (strength_reduce): Do not clear NOT_EVERY_ITERATION at the
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 May 1999 13:43:22 +0000 (13:43 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 May 1999 13:43:22 +0000 (13:43 +0000)
last CODE_LABEL in a loop if we have previously passed a jump
to the top of the loop.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@27125 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/loop.c

index 5f6903d..7ff15a4 100644 (file)
@@ -1,3 +1,9 @@
+Mon May 24 14:35:24 1999  Jeffrey A Law  (law@cygnus.com)
+
+       * loop.c (strength_reduce): Do not clear NOT_EVERY_ITERATION at the
+       last CODE_LABEL in a loop if we have previously passed a jump
+       to the top of the loop.
+
 Mon May 24 07:56:29 1999  Nick Clifton  <nickc@cygnus.com>
 
        * config/arm/arm.h (OUTPUT_INT_ADDR_CONST): Fix blunder made when
index 244d939..7ee6532 100644 (file)
@@ -3669,6 +3669,9 @@ strength_reduce (scan_start, end, loop_top, insn_count,
   /* This is 1 if current insn may be executed more than once for every
      loop iteration.  */
   int maybe_multiple = 0;
+  /* This is 1 if we have past a branch back to the top of the loop
+     (aka a loop latch).  */
+  int past_loop_latch = 0;
   /* Temporary list pointers for traversing loop_iv_list.  */
   struct iv_class *bl, **backbl;
   /* Ratio of extra register life span we can justify
@@ -3836,16 +3839,30 @@ strength_reduce (scan_start, end, loop_top, insn_count,
            loop_depth--;
        }
 
+      /* Note if we pass a loop latch.  If we do, then we can not clear
+        NOT_EVERY_ITERATION below when we pass the last CODE_LABEL in
+        a loop since a jump before the last CODE_LABEL may have started
+        a new loop iteration.
+
+        Note that LOOP_TOP is only set for rotated loops and we need
+        this check for all loops, so compare against the CODE_LABEL
+        which immediately follows LOOP_START.  */
+      if (GET_CODE (p) == JUMP_INSN && JUMP_LABEL (p) == NEXT_INSN (loop_start))
+       past_loop_latch = 1;
+
       /* Unlike in the code motion pass where MAYBE_NEVER indicates that
         an insn may never be executed, NOT_EVERY_ITERATION indicates whether
         or not an insn is known to be executed each iteration of the
         loop, whether or not any iterations are known to occur.
 
         Therefore, if we have just passed a label and have no more labels
-        between here and the test insn of the loop, we know these insns
-        will be executed each iteration.  */
+        between here and the test insn of the loop, and we have not passed
+        a jump to the top of the loop, then we know these insns will be
+        executed each iteration.  */
 
-      if (not_every_iteration && GET_CODE (p) == CODE_LABEL
+      if (not_every_iteration 
+         && ! past_loop_latch
+         && GET_CODE (p) == CODE_LABEL
          && no_labels_between_p (p, loop_end)
          && loop_insn_first_p (p, loop_cont))
        not_every_iteration = 0;