This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Fix execute/loop-7.c


Hi!

This patch seems to fix loop-7.c. In there, loop_iterations chooses as
iteration_var pseudo for `j' which is set only if some condition is true, so
we cannot base computation of loop iterations on that (previous unroll code
would happily see it is initially -1 and set to biv `i', so it must be 0
after first iteration and 0 is not < 0. I'm not 100% sure whether the
maybe_multiple test is needed as well, maybe !always_executed would suffice.
If one swaps the && operands in loop condition (i < 10 && j < 0 to j < 0 && i < 10)
then the test works just fine even without this patch, because
loop_iterations chooses `i' as iteration var and that one is always_executed
and not maybe_multiple.
Bootstrap pending, ok to commit assuming it has no regressions?

2000-11-29  Jakub Jelinek  <jakub@redhat.com>

	* unroll.c (loop_iterations): If we cannot prove iteration variable
	is set once in each iteration, punt.

--- gcc/unroll.c.jj	Sun Nov 12 22:32:51 2000
+++ gcc/unroll.c	Wed Nov 29 19:42:33 2000
@@ -3600,6 +3600,13 @@ loop_iterations (loop)
       /* Grab initial value, only useful if it is a constant.  */
       bl = ivs->reg_biv_class[REGNO (iteration_var)];
       initial_value = bl->initial_value;
+      if (!bl->biv->always_executed || bl->biv->maybe_multiple)
+	{
+	  if (loop_dump_stream)
+	    fprintf (loop_dump_stream,
+		     "Loop iterations: Basic induction var not set once in each iteration.\n");
+	  return 0;
+	}
 
       increment = biv_total_increment (bl);
     }
@@ -3611,6 +3618,14 @@ loop_iterations (loop)
 
       if (REGNO (v->src_reg) >= max_reg_before_loop)
 	abort ();
+
+      if (!v->always_executed || v->maybe_multiple)
+	{
+	  if (loop_dump_stream)
+	    fprintf (loop_dump_stream,
+		     "Loop iterations: General induction var not set once in each iteration.\n");
+	  return 0;
+	}
 
       bl = ivs->reg_biv_class[REGNO (v->src_reg)];
 

	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]