* unroll.c (loop_iterations): Handle EQ loops.
authorAlan Modra <amodra@bigpond.net.au>
Sun, 30 Jun 2002 05:06:01 +0000 (05:06 +0000)
committerAlan Modra <amodra@gcc.gnu.org>
Sun, 30 Jun 2002 05:06:01 +0000 (14:36 +0930)
From-SVN: r55111

gcc/ChangeLog
gcc/unroll.c

index 60cd8b809b7d3916ae7675e7c9ff3f6ed838549b..0ec03d0327be38ac50094b52d402b39772f7087d 100644 (file)
@@ -1,3 +1,7 @@
+2002-06-30  Alan Modra  <amodra@bigpond.net.au>
+
+       * unroll.c (loop_iterations): Handle EQ loops.
+
 2002-06-29  David Edelsohn  <edelsohn@gnu.org>
 
        * config/rs6000/rs6000.md (ctrdi): Allocate pseudo for FPR
index a795dcbc202c313e2f73765276fd42a36412256b..e0b0d36579d109b723cf8ab555c82f7c4c9298c8 100644 (file)
@@ -3941,12 +3941,6 @@ loop_iterations (loop)
        }
       return 0;
     }
-  else if (comparison_code == EQ)
-    {
-      if (loop_dump_stream)
-       fprintf (loop_dump_stream, "Loop iterations: EQ comparison loop.\n");
-      return 0;
-    }
   else if (GET_CODE (final_value) != CONST_INT)
     {
       if (loop_dump_stream)
@@ -3958,6 +3952,43 @@ loop_iterations (loop)
        }
       return 0;
     }
+  else if (comparison_code == EQ)
+    {
+      rtx inc_once;
+
+      if (loop_dump_stream)
+       fprintf (loop_dump_stream, "Loop iterations: EQ comparison loop.\n");
+
+      inc_once = gen_int_mode (INTVAL (initial_value) + INTVAL (increment),
+                              GET_MODE (iteration_var));
+
+      if (inc_once == final_value)
+       {
+         /* The iterator value once through the loop is equal to the
+            comparision value.  Either we have an infinite loop, or
+            we'll loop twice.  */
+         if (increment == const0_rtx)
+           return 0;
+         loop_info->n_iterations = 2;
+       }
+      else
+       loop_info->n_iterations = 1;
+
+      if (GET_CODE (loop_info->initial_value) == CONST_INT)
+       loop_info->final_value
+         = gen_int_mode ((INTVAL (loop_info->initial_value)
+                          + loop_info->n_iterations * INTVAL (increment)),
+                         GET_MODE (iteration_var));
+      else
+       loop_info->final_value
+         = plus_constant (loop_info->initial_value,
+                          loop_info->n_iterations * INTVAL (increment));
+      loop_info->final_equiv_value
+       = gen_int_mode ((INTVAL (initial_value)
+                        + loop_info->n_iterations * INTVAL (increment)),
+                       GET_MODE (iteration_var));
+      return loop_info->n_iterations;
+    }
 
   /* Final_larger is 1 if final larger, 0 if they are equal, otherwise -1.  */
   if (unsigned_p)