re PR tree-optimization/31995 (can't determine dependence between p->a[x+i] and p->a[x+i+1])

2007-05-21  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/31995
        * tree-chrec.c (evolution_function_is_affine_multivariate_p):
        Add loopno argument.  Use evolution_function_is_invariant_rec_p
        instead of evolution_function_is_constant_p.
        Update calls to evolution_function_is_affine_multivariate_p.
        * tree-chrec.h  (evolution_function_is_affine_multivariate_p):
        Add loopno argument.
        * tree-scalar-evolution.c (gather_chrec_stats): Call
        evolution_function_is_affine_multivariate_p with a  loop
        number of 0.
        * tree-data-ref.c (analyze_miv_subscript): Likewise.
        (analyze_overlapping_iterations): Likewise.
        (access_functions_are_affine_or_constant_p):
        Likewise.
        (build_classic_dist_vector_1): If the access functions
        are equal, don't do anything.

2007-05-21  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/31995
        * gcc.dg/vect/vect-102a.c: New test.

From-SVN: r124927
This commit is contained in:
Andrew Pinski 2007-05-21 23:08:54 +00:00 committed by Andrew Pinski
parent 60c4429c7e
commit a50411de14
7 changed files with 97 additions and 16 deletions

View File

@ -1,3 +1,22 @@
2007-05-21 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR middle-end/31995
* tree-chrec.c (evolution_function_is_affine_multivariate_p):
Add loopno argument. Use evolution_function_is_invariant_rec_p
instead of evolution_function_is_constant_p.
Update calls to evolution_function_is_affine_multivariate_p.
* tree-chrec.h (evolution_function_is_affine_multivariate_p):
Add loopno argument.
* tree-scalar-evolution.c (gather_chrec_stats): Call
evolution_function_is_affine_multivariate_p with a loop
number of 0.
* tree-data-ref.c (analyze_miv_subscript): Likewise.
(analyze_overlapping_iterations): Likewise.
(access_functions_are_affine_or_constant_p):
Likewise.
(build_classic_dist_vector_1): If the access functions
are equal, don't do anything.
2007-05-21 Paolo Bonzini <bonzini@gnu.org>
Paolo Carlini <pcarlini@suse.de>
Uros Bizjak <ubizjak@gmail.com>

View File

@ -1,3 +1,8 @@
2007-05-21 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR middle-end/31995
* gcc.dg/vect/vect-102a.c: New test.
2007-05-21 Paolo Bonzini <bonzini@gnu.org>
Paolo Carlini <pcarlini@suse.de>
Uros Bizjak <ubizjak@gmail.com>

View File

@ -0,0 +1,57 @@
/* { dg-require-effective-target vect_int } */
#include <stdlib.h>
#include <stdarg.h>
#include "tree-vect.h"
#define N 9
struct extraction
{
int a[N];
int b[N];
};
static int a[N] = {1,2,3,4,5,6,7,8,9};
static int b[N] = {2,3,4,5,6,7,8,9,9};
volatile int foo;
int main1 (int x, int y) {
int i;
struct extraction *p;
p = (struct extraction *) malloc (sizeof (struct extraction));
for (i = 0; i < N; i++)
{
p->a[i] = a[i];
if (foo == 135)
abort (); /* to avoid vectorization */
}
/* Not vectorizable: distance 1. */
for (i = 0; i < N - 1; i++)
{
p->a[x + i] = p->a[x + i + 1];
}
/* check results: */
for (i = 0; i < N; i++)
{
if (p->a[i] != b[i])
abort();
}
return 0;
}
int main (void)
{
check_vect ();
foo = 0;
return main1 (0, N);
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
/* { dg-final { scan-tree-dump-times "possible dependence between data-refs" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */

View File

@ -987,7 +987,7 @@ evolution_function_is_invariant_p (tree chrec, int loopnum)
evolution. */
bool
evolution_function_is_affine_multivariate_p (tree chrec)
evolution_function_is_affine_multivariate_p (tree chrec, int loopnum)
{
if (chrec == NULL_TREE)
return false;
@ -995,9 +995,9 @@ evolution_function_is_affine_multivariate_p (tree chrec)
switch (TREE_CODE (chrec))
{
case POLYNOMIAL_CHREC:
if (evolution_function_is_constant_p (CHREC_LEFT (chrec)))
if (evolution_function_is_invariant_rec_p (CHREC_LEFT (chrec), loopnum))
{
if (evolution_function_is_constant_p (CHREC_RIGHT (chrec)))
if (evolution_function_is_invariant_rec_p (CHREC_RIGHT (chrec), loopnum))
return true;
else
{
@ -1005,7 +1005,7 @@ evolution_function_is_affine_multivariate_p (tree chrec)
&& CHREC_VARIABLE (CHREC_RIGHT (chrec))
!= CHREC_VARIABLE (chrec)
&& evolution_function_is_affine_multivariate_p
(CHREC_RIGHT (chrec)))
(CHREC_RIGHT (chrec), loopnum))
return true;
else
return false;
@ -1013,11 +1013,11 @@ evolution_function_is_affine_multivariate_p (tree chrec)
}
else
{
if (evolution_function_is_constant_p (CHREC_RIGHT (chrec))
if (evolution_function_is_invariant_rec_p (CHREC_RIGHT (chrec), loopnum)
&& TREE_CODE (CHREC_LEFT (chrec)) == POLYNOMIAL_CHREC
&& CHREC_VARIABLE (CHREC_LEFT (chrec)) != CHREC_VARIABLE (chrec)
&& evolution_function_is_affine_multivariate_p
(CHREC_LEFT (chrec)))
(CHREC_LEFT (chrec), loopnum))
return true;
else
return false;

View File

@ -79,7 +79,7 @@ extern bool chrec_contains_symbols (tree);
extern bool chrec_contains_symbols_defined_in_loop (tree, unsigned);
extern bool chrec_contains_undetermined (tree);
extern bool tree_contains_chrecs (tree, int *);
extern bool evolution_function_is_affine_multivariate_p (tree);
extern bool evolution_function_is_affine_multivariate_p (tree, int);
extern bool evolution_function_is_univariate_p (tree);
extern unsigned nb_vars_in_chrec (tree);

View File

@ -2458,7 +2458,7 @@ analyze_miv_subscript (tree chrec_a,
else if (evolution_function_is_constant_p (difference)
/* For the moment, the following is verified:
evolution_function_is_affine_multivariate_p (chrec_a) */
evolution_function_is_affine_multivariate_p (chrec_a, 0) */
&& !gcd_of_steps_may_divide_p (chrec_a, difference))
{
/* testsuite/.../ssa-chrec-33.c
@ -2472,9 +2472,9 @@ analyze_miv_subscript (tree chrec_a,
dependence_stats.num_miv_independent++;
}
else if (evolution_function_is_affine_multivariate_p (chrec_a)
else if (evolution_function_is_affine_multivariate_p (chrec_a, 0)
&& !chrec_contains_symbols (chrec_a)
&& evolution_function_is_affine_multivariate_p (chrec_b)
&& evolution_function_is_affine_multivariate_p (chrec_b, 0)
&& !chrec_contains_symbols (chrec_b))
{
/* testsuite/.../ssa-chrec-35.c
@ -2563,7 +2563,7 @@ analyze_overlapping_iterations (tree chrec_a,
/* If they are the same chrec, and are affine, they overlap
on every iteration. */
else if (eq_evolutions_p (chrec_a, chrec_b)
&& evolution_function_is_affine_multivariate_p (chrec_a))
&& evolution_function_is_affine_multivariate_p (chrec_a, 0))
{
dependence_stats.num_same_subscript_function++;
*overlap_iterations_a = conflict_fn (1, affine_fn_cst (integer_zero_node));
@ -2575,8 +2575,8 @@ analyze_overlapping_iterations (tree chrec_a,
yet. */
else if ((chrec_contains_symbols (chrec_a)
|| chrec_contains_symbols (chrec_b))
&& (!evolution_function_is_affine_multivariate_p (chrec_a)
|| !evolution_function_is_affine_multivariate_p (chrec_b)))
&& (!evolution_function_is_affine_multivariate_p (chrec_a, 0)
|| !evolution_function_is_affine_multivariate_p (chrec_b, 0)))
{
dependence_stats.num_subscript_undetermined++;
*overlap_iterations_a = conflict_fn_not_known ();
@ -2745,7 +2745,7 @@ build_classic_dist_vector_1 (struct data_dependence_relation *ddr,
init_v[index] = 1;
*init_b = true;
}
else
else if (!operand_equal_p (access_fn_a, access_fn_b, 0))
{
/* This can be for example an affine vs. constant dependence
(T[i] vs. T[3]) that is not an affine dependence and is
@ -3182,7 +3182,7 @@ access_functions_are_affine_or_constant_p (struct data_reference *a)
for (i = 0; VEC_iterate (tree, fns, i, t); i++)
if (!evolution_function_is_constant_p (t)
&& !evolution_function_is_affine_multivariate_p (t))
&& !evolution_function_is_affine_multivariate_p (t, 0))
return false;
return true;

View File

@ -2615,7 +2615,7 @@ gather_chrec_stats (tree chrec, struct chrec_stats *stats)
fprintf (dump_file, " affine_univariate\n");
stats->nb_affine++;
}
else if (evolution_function_is_affine_multivariate_p (chrec))
else if (evolution_function_is_affine_multivariate_p (chrec, 0))
{
if (dump_file && (dump_flags & TDF_STATS))
fprintf (dump_file, " affine_multivariate\n");