]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/7120 (Run once loop should *always* be unrolled)
authorAlan Modra <amodra@bigpond.net.au>
Fri, 13 Sep 2002 08:04:22 +0000 (08:04 +0000)
committerAlan Modra <amodra@gcc.gnu.org>
Fri, 13 Sep 2002 08:04:22 +0000 (17:34 +0930)
2002-06-30  Alan Modra  <amodra@bigpond.net.au>
PR optimization/7120
* unroll.c (loop_iterations): Handle EQ loops.

From-SVN: r57100

gcc/ChangeLog
gcc/unroll.c

index f1ed0be1e255ddbdd2b01dcbbc0b56156e6dd281..aa7900e36bd6b68b6ee3f5a0d8fa739d694715d4 100644 (file)
        * config/rs6000/linux64.h (ASM_OUTPUT_REG_PUSH): Undef.
        (ASM_OUTPUT_REG_POP): Undef.
 
+       2002-06-30  Alan Modra  <amodra@bigpond.net.au>
+       PR optimization/7120
+       * unroll.c (loop_iterations): Handle EQ loops.
+
 2002-09-13  Alan Modra  <amodra@bigpond.net.au>
 
        * config/rs6000/rs6000.c (rs6000_emit_load_toc_table): Remove "if"
index 6be951e279223b385fd7a8b7a24c3b09d44236cb..032d675a3b65dc21be6ab641426c70d4e705dda5 100644 (file)
@@ -3997,12 +3997,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)
@@ -4014,6 +4008,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)