Your patch for PR 17520
Sebastian Pop
sebastian.pop@cri.ensmp.fr
Thu Nov 11 21:23:00 GMT 2004
On Wed, Nov 10, 2004 at 01:53:37PM -0800, Mark Mitchell wrote:
> I've reveiewed some of your outstanding patches:
Thank you.
> 2) http://gcc.gnu.org/ml/gcc-patches/2004-10/msg01592.html
>
> I find the existing check for element_size being non-NULL, and the new
> check you added that it is an INTEGER_CST to be odd. Can we really have
> an array whose elements are not of a constant size? I didn't think that
> was allowed even in C99. I'm not sure about other languages, or how
> they are supposed to simplify things before the middle-end sees that.
>
> The array_size part of the patch is clearly OK, so please go ahead with
> that. I think I'd prefer an assert for the element_size part, or you
> can just leave it out. I don't think it's need to fix the PR. Correct?
>
Right. I've gcc_assert-ed the checks for element_size.
> 3) http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00192.html
>
> Oh, fun with math. :-)
>
> ! /* 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. */
> ! while ((x0 - i1) >= 0 && (y0 - j1) >= 0)
> ! {
> ! x0 -= i1;
> ! y0 -= j1;
> ! }
>
> Can't we do this more efficiently than repeated subtraction? Something
> like:
I didn't thought at this solution.
>
> max_multiple = max (x0 / i1, y0 / j1);
> x0 -= i1 * max_multiple;
> y0 -= j1 * max_multiple;
>
Because we want both x0 and y0 to be positive at the end, we have to
compute the min_multiple.
> OK with that change.
>
Thanks, here is what I'm bootstrapping and testing right now on i686.
I will commit these patches once they pass.
Sebastian
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 19:49:56 -0000
@@ -512,12 +512,14 @@ estimate_niter_from_size_of_data (struct
array_size = TYPE_SIZE (TREE_TYPE (opnd0));
element_size = TYPE_SIZE (TREE_TYPE (TREE_TYPE (opnd0)));
+ gcc_assert (element_size != NULL_TREE);
+ gcc_assert (TREE_CODE (element_size) == INTEGER_CST);
if (array_size == NULL_TREE
- || element_size == NULL_TREE)
+ || TREE_CODE (array_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 +1437,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;
More information about the Gcc-patches
mailing list