PATCH: Fix PR 10087

Mark Mitchell mark@codesourcery.com
Mon Mar 24 18:42:00 GMT 2003


I've reviewed and committed the attached patch, which fixes PR 10087.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2003-03-21  Glen Nakamura  <glen@imodulo.com>

	PR opt/10087
	* gcc.dg/20030324-1.c: New test.

2003-03-21  Glen Nakamura  <glen@imodulo.com>

	PR opt/10087
	* gcc.dg/20030324-1.c: New test.

diff -Nru3p gcc-3.3.orig/gcc/loop.c gcc-3.3/gcc/loop.c
--- gcc-3.3.orig/gcc/loop.c	2003-01-31 23:51:21.000000000 +0000
+++ gcc-3.3/gcc/loop.c	2003-01-31 23:51:21.000000000 +0000
@@ -4769,6 +4769,9 @@ loop_givs_reduce (loop, bl)
 	    {
 	      rtx insert_before;
 
+	      /* Skip if location is the same as a previous one.  */
+	      if (tv->same)
+		continue;
 	      if (! auto_inc_opt)
 		insert_before = NEXT_INSN (tv->insn);
 	      else if (auto_inc_opt == 1)
@@ -5676,6 +5679,7 @@ record_biv (loop, v, insn, dest_reg, inc
   v->always_computable = ! not_every_iteration;
   v->always_executed = ! not_every_iteration;
   v->maybe_multiple = maybe_multiple;
+  v->same = 0;
 
   /* Add this to the reg's iv_class, creating a class
      if this is the first incrementation of the reg.  */
@@ -5713,6 +5717,17 @@ record_biv (loop, v, insn, dest_reg, inc
       /* Put it in the array of biv register classes.  */
       REG_IV_CLASS (ivs, REGNO (dest_reg)) = bl;
     }
+  else
+    {
+      /* Check if location is the same as a previous one.  */
+      struct induction *induction;
+      for (induction = bl->biv; induction; induction = induction->next_iv)
+	if (location == induction->location)
+	  {
+	    v->same = induction;
+	    break;
+	  }
+    }
 
   /* Update IV_CLASS entry for this biv.  */
   v->next_iv = bl->biv;

Index: testsuite/gcc.dg/20030324-1.c
===================================================================
RCS file: testsuite/gcc.dg/20030324-1.c
diff -N testsuite/gcc.dg/20030324-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/20030324-1.c	24 Mar 2003 18:36:41 -0000
***************
*** 0 ****
--- 1,33 ----
+ /* { dg-do run } */
+ /* { dg-options "-O -fstrength-reduce -fstrict-aliasing -fforce-mem -fgcse" } */
+ 
+ void b(int*,int*);
+     
+ typedef struct {
+     double T1;
+     char c;
+ } S;
+ 
+ int main(void)
+ {
+   int i,j;
+   double s;
+ 
+   S x1[2][2];
+   S *x[2] = { x1[0], x1[1] };
+   S **E = x;
+ 
+   for( i=0; i < 2; i++ )
+     for( j=0; j < 2; j++ )
+       E[j][i].T1 = 1;
+ 
+   for( i=0; i < 2; i++ )
+     for( j=0; j < 2; j++ )
+       s = E[j][i].T1;
+ 
+   b(&j,&i);
+   printf( "result %.6e\n", s);
+   return 0;
+ }
+ 
+ void b(int *i, int *j) {}



More information about the Gcc-patches mailing list