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]
Other format: [Raw text]

Re: Your patch for PR 17520


On Thu, Nov 11, 2004 at 01:40:12PM -0800, Mark Mitchell wrote:
> 
> That looks great, modulo the element_size issue.   I apologize for 
> leading you astray on that issue.
> 

Here is the patch that I have committed after a bootstrap and
regression testing on i686:

Index: tree-data-ref.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-data-ref.c,v
retrieving revision 2.16
diff -d -u -p -r2.16 tree-data-ref.c
--- tree-data-ref.c	10 Nov 2004 21:32:09 -0000	2.16
+++ tree-data-ref.c	11 Nov 2004 23:58:43 -0000
@@ -513,11 +513,12 @@ estimate_niter_from_size_of_data (struct
   array_size = TYPE_SIZE (TREE_TYPE (opnd0));
   element_size = TYPE_SIZE (TREE_TYPE (TREE_TYPE (opnd0)));
   if (array_size == NULL_TREE 
-      || element_size == NULL_TREE)
+      || TREE_CODE (array_size) != INTEGER_CST
+      || TREE_CODE (element_size) != INTEGER_CST)
     return;
 
   data_size = fold (build2 (EXACT_DIV_EXPR, integer_type_node, 
-			   array_size, element_size));
+			    array_size, element_size));
 
   if (init != NULL_TREE
       && step != NULL_TREE
@@ -1435,12 +1436,21 @@ analyze_subscript_affine_affine (tree ch
 
 		  if (j1 > 0)
 		    {
-		      int last_conflict;
+		      int last_conflict, min_multiple;
 		      tau1 = MAX (tau1, CEIL (-j0, j1));
 		      tau2 = MIN (tau2, FLOOR_DIV (niter - j0, j1));
 
-		      x0 = (i1 * tau1 + i0) % i1;
-		      y0 = (j1 * tau1 + j0) % j1;
+		      x0 = i1 * tau1 + i0;
+		      y0 = j1 * tau1 + j0;
+
+		      /* At this point (x0, y0) is one of the
+			 solutions to the Diophantine equation.  The
+			 next step has to compute the smallest
+			 positive solution: the first conflicts.  */
+		      min_multiple = MIN (x0 / i1, y0 / j1);
+		      x0 -= i1 * min_multiple;
+		      y0 -= j1 * min_multiple;
+
 		      tau1 = (x0 - i0)/i1;
 		      last_conflict = tau2 - tau1;
 


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