This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: loop optimizer naivety


> The patch for PR opt/10087 was minimal and as non-intrusive as possible
> to fix the testcase.  I wasn't very familiar with the loop optimizer and
> didn't want to change variables such as 'biv_count' and 'incremented'
> without fully understanding what effect it would have in other parts of
> the code.

Yes, I've attached a patch of the same flavor which fixes PR opt/12340.

> I'm willing to look into this, but unfortunately the testcase for PR
> opt/12340 is difficult to work with and apparently doesn't segfault on my
> system even with a vanilla 3.3 branch build.

Weird, it segfaults on mine. Do you use the right options?

-- 
Eric Botcazou
Index: unroll.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/unroll.c,v
retrieving revision 1.184.2.5
diff -u -p -r1.184.2.5 unroll.c
--- unroll.c	21 Jul 2003 17:49:59 -0000	1.184.2.5
+++ unroll.c	23 Sep 2003 10:22:41 -0000
@@ -2478,7 +2478,13 @@ biv_total_increment (bl)
       if (v->always_computable && v->mult_val == const1_rtx
 	  && ! v->maybe_multiple
 	  && SCALAR_INT_MODE_P (v->mode))
-	result = fold_rtx_mult_add (result, const1_rtx, v->add_val, v->mode);
+	{
+	  /* If we have already counted it, skip it.  */
+	  if (v->same)
+	    continue;
+
+	  result = fold_rtx_mult_add (result, const1_rtx, v->add_val, v->mode);
+	}
       else
 	return 0;
     }
@@ -3538,6 +3544,9 @@ loop_iterations (loop)
 				 REGNO (biv_inc->add_val));
 			return 0;
 		    }
+		  /* If we have already counted it, skip it.  */
+		  else if (biv_inc->same)
+		    continue;
 
 		  offset -= INTVAL (biv_inc->add_val);
 		}

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