tree-vectorizer.h (stmt_vec_info): Add vect_dr_base field.

2004-09-19  Ira Rosen  <irar@il.ibm.com>

        * tree-vectorizer.h (stmt_vec_info): Add vect_dr_base field.
        (STMT_VINFO_VECT_DR_BASE): Declare.
        (VECT_SMODULO): Declare.
        * tree-vectorizer.c (vect_compute_array_ref_alignment): New function.
        (vect_compute_array_base_alignment): New function.
        (vect_analyze_data_ref_access): Check array indices. Remove one
        dimensional arrays restriction.
        (vect_get_ptr_offset): New function.
        (vect_get_symbl_and_dr): New function.
        (vect_get_base_and_bit_offset): Support additional data refs. Renamed
        (former name vect_get_base_decl_and_bit_offset).
        (vect_create_index_for_array_ref): Removed.
        (vect_create_index_for_vector_ref): New function.
        (vect_create_addr_base_for_vector_ref): New function.
        (vect_create_data_ref): Handle additional data refs. Call
        vect_create_index_for_vector_ref and vect_create_addr_base_for_vector_ref.
        (vect_compute_data_ref_alignment): Support the changes. Call
        vect_get_base_and_bit_offset.
        (vect_analyze_data_refs): Call vect_get_symbl_and_dr. Support additional
        data refs. Store vect_dr_base.
        (vect_analyze_data_ref_accesses): Support nonconstant init.
        (new_stmt_vec_info): Initialize vect_dr_base field.
        (vect_is_simple_iv_evolution): Call initial_condition_in_loop_num.
        (get_vectype_for_scalar_type): Check for BLKmode.
        * tree-chrec.h (initial_condition_in_loop_num): Declare.
        * tree-chrec.c (initial_condition_in_loop_num): New function.
        (chrec_component_in_loop_num): New function.
        (evolution_part_in_loop_num): Call chrec_component_in_loop_num.
        * tree-data-ref.c (analyze_array_indexes): Change parameter (access_fns)
        to be pointer to varray_type.

From-SVN: r87731
This commit is contained in:
Ira Rosen 2004-09-19 18:01:51 +00:00 committed by Dorit Nuzman
parent 15db5571d1
commit 6775f1f3a7
14 changed files with 1365 additions and 387 deletions

View File

@ -1,3 +1,36 @@
2004-09-19 Ira Rosen <irar@il.ibm.com>
* tree-vectorizer.h (stmt_vec_info): Add vect_dr_base field.
(STMT_VINFO_VECT_DR_BASE): Declare.
(VECT_SMODULO): Declare.
* tree-vectorizer.c (vect_compute_array_ref_alignment): New function.
(vect_compute_array_base_alignment): New function.
(vect_analyze_data_ref_access): Check array indices. Remove one
dimensional arrays restriction.
(vect_get_ptr_offset): New function.
(vect_get_symbl_and_dr): New function.
(vect_get_base_and_bit_offset): Support additional data refs. Renamed
(former name vect_get_base_decl_and_bit_offset).
(vect_create_index_for_array_ref): Removed.
(vect_create_index_for_vector_ref): New function.
(vect_create_addr_base_for_vector_ref): New function.
(vect_create_data_ref): Handle additional data refs. Call
vect_create_index_for_vector_ref and vect_create_addr_base_for_vector_ref.
(vect_compute_data_ref_alignment): Support the changes. Call
vect_get_base_and_bit_offset.
(vect_analyze_data_refs): Call vect_get_symbl_and_dr. Support additional
data refs. Store vect_dr_base.
(vect_analyze_data_ref_accesses): Support nonconstant init.
(new_stmt_vec_info): Initialize vect_dr_base field.
(vect_is_simple_iv_evolution): Call initial_condition_in_loop_num.
(get_vectype_for_scalar_type): Check for BLKmode.
* tree-chrec.h (initial_condition_in_loop_num): Declare.
* tree-chrec.c (initial_condition_in_loop_num): New function.
(chrec_component_in_loop_num): New function.
(evolution_part_in_loop_num): Call chrec_component_in_loop_num.
* tree-data-ref.c (analyze_array_indexes): Change parameter (access_fns)
to be pointer to varray_type.
2004-09-19 Jan Hubicka <jh@suse.cz>
* basic-block.h (update_bb_profile_after_threading): Declare.

View File

@ -1,3 +1,13 @@
2004-09-19 Ira Rosen <irar@il.ibm.com>
* gcc.dg/vect/vect-13.c: Now vectorized on ppc*.
* gcc.dg/vect/vect-73.c: New testcase.
* gcc.dg/vect/vect-74.c: New testcase.
* gcc.dg/vect/vect-75.c: New testcase.
* gcc.dg/vect/vect-76.c: New testcase.
* gcc.dg/vect/vect-77.c: New testcase.
* gcc.dg/vect/vect-78.c: New testcase
2004-09-18 Paul Brook <paul@codesourcery.com>
* g++.old-deja/g++.pt/static11.C: XFAIL on arm*-*-eabi.

View File

@ -22,4 +22,4 @@ int main ()
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */

View File

@ -0,0 +1,42 @@
/* { dg-do run { target powerpc*-*-* } } */
/* { dg-do run { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* x86_64-*-* } } */
#include <stdarg.h>
#include "tree-vect.h"
#define N 16
int ic[N*2];
#define ia (ic+N)
int main1 ()
{
int i, j;
int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
for (i = 0; i < N; i++)
{
ia[i] = ib[i];
}
/* check results: */
for (i = 0; i < N; i++)
{
if (ia[i] != ib[i])
abort();
}
return 0;
}
int main (void)
{
check_vect ();
return main1 ();
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */

View File

@ -0,0 +1,97 @@
/* { dg-do run { target powerpc*-*-* } } */
/* { dg-do run { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse2" { target i?86-*-* x86_64-*-* } } */
#include <stdarg.h>
#include "tree-vect.h"
#define N 16
typedef float afloat __attribute__ ((__aligned__(16)));
afloat a[N];
afloat b[N+4] = {0.2, 1.3, 2.3, 3.4, 4.5, 5.6, 7.8, 9.0, 10.11, 11.12, 12.13, 13.14, 14.15, 15.16, 16.17, 17.18, 18.19, 19.20};
afloat c[N] = {0.2, 1.3, 2.3, 3.4, 4.5, 5.6, 7.8, 9.0, 10.11, 11.12, 12.13, 13.14, 14.15, 15.16};
float fa[N];
float fb[N+4] = {0.2, 1.3, 2.3, 3.4, 4.5, 5.6, 7.8, 9.0, 10.11, 11.12, 12.13, 13.14, 14.15, 15.16,
16.17, 17.18, 18.19, 19.20};
float fc[N] = {0.2, 1.3, 2.3, 3.4, 4.5, 5.6, 7.8, 9.0, 10.11, 11.12, 12.13, 13.14, 14.15, 15.16};
int
main1 (afloat *__restrict__ pa, afloat * __restrict__ pb, afloat * __restrict__ pc)
{
int i;
afloat *q = pb + 4;
for (i = 0; i < N; i++)
{
pa[i] = q[i] * pc[i];
}
for (i = 0; i < N; i++)
{
if (pa[i] != q[i] * pc[i])
abort();
}
return 0;
}
/* Not vectorizable. Alias. */
int
main2 (afloat *pa, afloat *pb, afloat *pc)
{
int i;
afloat *q = pb + 4;
for (i = 0; i < N; i++)
{
pa[i] = q[i] * pc[i];
}
for (i = 0; i < N; i++)
{
if (pa[i] != q[i] * pc[i])
abort();
}
return 0;
}
/* Not vectorizable: not aligned pointers. */
int
main3 (float * __restrict__ pa, float * __restrict__ pb, float *__restrict__ pc)
{
int i;
afloat *q = pb + 4;
for (i = 0; i < N; i++)
{
pa[i] = q[i] * pc[i];
}
for (i = 0; i < N; i++)
{
if (pa[i] != q[i] * pc[i])
abort();
}
return 0;
}
int main (void)
{
check_vect ();
main1 (a, b, c);
main2 (a, b, c);
main3 (fa, fb, fc);
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 2 "vect" } } */

View File

@ -0,0 +1,47 @@
/* { dg-do run { target powerpc*-*-* } } */
/* { dg-do run { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse" { target i?86-*-* x86_64-*-* } } */
#include <stdarg.h>
#include "tree-vect.h"
#define N 8
#define OFF 8
typedef int aint __attribute__ ((__aligned__(16)));
aint ib[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34};
int main1 (aint *ib)
{
int i;
int ia[N];
for (i = 0; i < N; i++)
{
ia[i] = ib[i+OFF];
}
/* check results: */
for (i = 0; i < N; i++)
{
if (ia[i] != ib[i+OFF])
abort ();
}
return 0;
}
int main (void)
{
check_vect ();
main1 (ib);
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */

View File

@ -0,0 +1,74 @@
/* { dg-do run { target powerpc*-*-* } } */
/* { dg-do run { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse" { target i?86-*-* x86_64-*-* } } */
#include <stdarg.h>
#include "tree-vect.h"
#define N 8
#define OFF 4
typedef int aint __attribute__ ((__aligned__(16)));
aint ib[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10};
int main1 (aint *pib)
{
int i;
int ia[N+OFF];
int ic[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10};
for (i = OFF; i < N; i++)
{
ia[i] = pib[i - OFF];
}
/* check results: */
for (i = OFF; i < N; i++)
{
if (ia[i] != pib[i - OFF])
abort ();
}
for (i = 0; i < N; i++)
{
ia[i] = pib[i - OFF];
}
/* check results: */
for (i = 0; i < N; i++)
{
if (ia[i] != pib[i - OFF])
abort ();
}
for (i = OFF; i < N; i++)
{
ia[i] = ic[i - OFF];
}
/* check results: */
for (i = OFF; i < N; i++)
{
if (ia[i] != ic[i - OFF])
abort ();
}
return 0;
}
int main (void)
{
check_vect ();
main1 (&ib[OFF]);
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */

View File

@ -0,0 +1,47 @@
/* { dg-do run { target powerpc*-*-* } } */
/* { dg-do run { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse" { target i?86-*-* x86_64-*-* } } */
#include <stdarg.h>
#include "tree-vect.h"
#define N 8
#define OFF 8
typedef int aint __attribute__ ((__aligned__(16)));
aint ib[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34};
int main1 (aint *ib, int off)
{
int i;
int ia[N];
for (i = 0; i < N; i++)
{
ia[i] = ib[i+off];
}
/* check results: */
for (i = 0; i < N; i++)
{
if (ia[i] != ib[i+off])
abort ();
}
return 0;
}
int main (void)
{
check_vect ();
main1 (ib, 8);
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */

View File

@ -0,0 +1,48 @@
/* { dg-do run { target powerpc*-*-* } } */
/* { dg-do run { target i?86-*-* x86_64-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -msse" { target i?86-*-* x86_64-*-* } } */
#include <stdarg.h>
#include "tree-vect.h"
#define N 8
#define OFF 8
typedef int aint __attribute__ ((__aligned__(16)));
aint ib[N+OFF] = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34};
int off = 8;
int main1 (aint *ib)
{
int i;
int ia[N];
for (i = 0; i < N; i++)
{
ia[i] = ib[i+off];
}
/* check results: */
for (i = 0; i < N; i++)
{
if (ia[i] != ib[i+off])
abort ();
}
return 0;
}
int main (void)
{
check_vect ();
main1 (ib);
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */

View File

@ -583,14 +583,16 @@ hide_evolution_in_other_loops_than_loop (tree chrec,
}
}
/* Returns the evolution part in LOOP_NUM. Example: the call
get_evolution_in_loop (1, {{0, +, 1}_1, +, 2}_1) returns
{1, +, 2}_1 */
/* Returns the evolution part of CHREC in LOOP_NUM when RIGHT is
true, otherwise returns the initial condition in LOOP_NUM. */
tree
evolution_part_in_loop_num (tree chrec,
unsigned loop_num)
static tree
chrec_component_in_loop_num (tree chrec,
unsigned loop_num,
bool right)
{
tree component;
if (automatically_generated_chrec_p (chrec))
return chrec;
@ -599,15 +601,22 @@ evolution_part_in_loop_num (tree chrec,
case POLYNOMIAL_CHREC:
if (CHREC_VARIABLE (chrec) == loop_num)
{
if (right)
component = CHREC_RIGHT (chrec);
else
component = CHREC_LEFT (chrec);
if (TREE_CODE (CHREC_LEFT (chrec)) != POLYNOMIAL_CHREC
|| CHREC_VARIABLE (CHREC_LEFT (chrec)) != CHREC_VARIABLE (chrec))
return CHREC_RIGHT (chrec);
return component;
else
return build_polynomial_chrec
(loop_num,
evolution_part_in_loop_num (CHREC_LEFT (chrec), loop_num),
CHREC_RIGHT (chrec));
chrec_component_in_loop_num (CHREC_LEFT (chrec),
loop_num,
right),
component);
}
else if (CHREC_VARIABLE (chrec) < loop_num)
@ -615,13 +624,40 @@ evolution_part_in_loop_num (tree chrec,
return NULL_TREE;
else
return evolution_part_in_loop_num (CHREC_LEFT (chrec), loop_num);
return chrec_component_in_loop_num (CHREC_LEFT (chrec),
loop_num,
right);
default:
return NULL_TREE;
default:
if (right)
return NULL_TREE;
else
return chrec;
}
}
/* Returns the evolution part in LOOP_NUM. Example: the call
evolution_part_in_loop_num (1, {{0, +, 1}_1, +, 2}_1) returns
{1, +, 2}_1 */
tree
evolution_part_in_loop_num (tree chrec,
unsigned loop_num)
{
return chrec_component_in_loop_num (chrec, loop_num, true);
}
/* Returns the initial condition in LOOP_NUM. Example: the call
initial_condition_in_loop_num ({{0, +, 1}_1, +, 2}_2, 1) returns
{0, +, 1}_1 */
tree
initial_condition_in_loop_num (tree chrec,
unsigned loop_num)
{
return chrec_component_in_loop_num (chrec, loop_num, false);
}
/* Set or reset the evolution of CHREC to NEW_EVOL in loop LOOP_NUM.
This function is essentially used for setting the evolution to
chrec_dont_know, for example after having determined that it is

View File

@ -76,6 +76,7 @@ extern tree chrec_apply (unsigned, tree, tree);
extern tree chrec_replace_initial_condition (tree, tree);
extern tree update_initial_condition_to_origin (tree);
extern tree initial_condition (tree);
extern tree initial_condition_in_loop_num (tree, unsigned);
extern tree evolution_part_in_loop_num (tree, unsigned);
extern tree hide_evolution_in_other_loops_than_loop (tree, unsigned);
extern tree reset_evolution_in_loop (unsigned, tree, tree);

View File

@ -498,7 +498,7 @@ dump_data_dependence_direction (FILE *file,
static tree
analyze_array_indexes (struct loop *loop,
varray_type access_fns,
varray_type *access_fns,
tree ref)
{
tree opnd0, opnd1;
@ -514,7 +514,7 @@ analyze_array_indexes (struct loop *loop,
access_fn = instantiate_parameters
(loop, analyze_scalar_evolution (loop, opnd1));
VARRAY_PUSH_TREE (access_fns, access_fn);
VARRAY_PUSH_TREE (*access_fns, access_fn);
/* Recursively record other array access functions. */
if (TREE_CODE (opnd0) == ARRAY_REF)
@ -549,7 +549,7 @@ analyze_array (tree stmt, tree ref, bool is_read)
DR_REF (res) = ref;
VARRAY_TREE_INIT (DR_ACCESS_FNS (res), 3, "access_fns");
DR_BASE_NAME (res) = analyze_array_indexes
(loop_containing_stmt (stmt), DR_ACCESS_FNS (res), ref);
(loop_containing_stmt (stmt), &(DR_ACCESS_FNS (res)), ref);
DR_IS_READ (res) = is_read;
if (dump_file && (dump_flags & TDF_DETAILS))

File diff suppressed because it is too large Load Diff

View File

@ -76,17 +76,27 @@ typedef struct _stmt_vec_info {
/* Aliasing information. */
tree memtag;
/* Data reference base. This field holds the entire invariant part of the
data-reference (with respect to the relevant loop), as opposed to the
field DR_BASE of the STMT_VINFO_DATA_REF struct, which holds only the
initial base; e.g:
REF BR_BASE VECT_DR_BASE
a[i] a a
a[i][j] a a[i] */
tree vect_dr_base;
} *stmt_vec_info;
/* Access Functions. */
#define STMT_VINFO_TYPE(S) (S)->type
#define STMT_VINFO_STMT(S) (S)->stmt
#define STMT_VINFO_LOOP(S) (S)->loop
#define STMT_VINFO_RELEVANT_P(S) (S)->relevant
#define STMT_VINFO_VECTYPE(S) (S)->vectype
#define STMT_VINFO_VEC_STMT(S) (S)->vectorized_stmt
#define STMT_VINFO_DATA_REF(S) (S)->data_ref_info
#define STMT_VINFO_MEMTAG(S) (S)->memtag
#define STMT_VINFO_TYPE(S) (S)->type
#define STMT_VINFO_STMT(S) (S)->stmt
#define STMT_VINFO_LOOP(S) (S)->loop
#define STMT_VINFO_RELEVANT_P(S) (S)->relevant
#define STMT_VINFO_VECTYPE(S) (S)->vectype
#define STMT_VINFO_VEC_STMT(S) (S)->vectorized_stmt
#define STMT_VINFO_DATA_REF(S) (S)->data_ref_info
#define STMT_VINFO_MEMTAG(S) (S)->memtag
#define STMT_VINFO_VECT_DR_BASE(S) (S)->vect_dr_base
static inline void set_stmt_info (stmt_ann_t ann, stmt_vec_info stmt_info);
static inline stmt_vec_info vinfo_for_stmt (tree stmt);
@ -123,6 +133,9 @@ unknown_alignment_for_access_p (struct data_reference *data_ref_info)
return (DR_MISALIGNMENT (data_ref_info) == -1);
}
/* Perform signed modulo, always returning a non-negative value. */
#define VECT_SMODULO(x,y) ((x) % (y) < 0 ? ((x) % (y) + (y)) : (x) % (y))
/*-----------------------------------------------------------------*/
/* Info on vectorized loops. */