Commit 8270b82d by Richard Biener Committed by Richard Biener

re PR tree-optimization/43434 (Missed vectorization: "not vectorized: data ref…

re PR tree-optimization/43434 (Missed vectorization: "not vectorized: data ref analysis": pointer incremented by a parameter)

2016-04-18  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/43434
	* tree-ssa-structalias.c (struct vls_data): New.
	(visit_loadstore): Handle all pointer-based accesses.
	(compute_dependence_clique): Compute a bitmap of restrict tags
	assigned bases and pass it to visit_loadstore.

	* gcc.dg/vect/pr43434.c: New testcase.
	* c-c++-common/goacc/kernels-alias-3.c: Adjust.
	* c-c++-common/goacc/kernels-alias-4.c: Likewise.
	* c-c++-common/goacc/kernels-alias-5.c: Likewise.
	* c-c++-common/goacc/kernels-alias-6.c: Likewise.
	* c-c++-common/goacc/kernels-alias-7.c: Likewise.
	* c-c++-common/goacc/kernels-alias-8.c: Likewise.
	* gcc.dg/gomp/pr68640.c: Likewise.
	* gfortran.dg/goacc/kernels-alias-3.f95: Likewise.
	* gfortran.dg/goacc/kernels-alias-4.f95: Likewise.

From-SVN: r235147
parent be035558
2016-04-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/43434
* tree-ssa-structalias.c (struct vls_data): New.
(visit_loadstore): Handle all pointer-based accesses.
(compute_dependence_clique): Compute a bitmap of restrict tags
assigned bases and pass it to visit_loadstore.
2016-04-18 Matthew Wahab <matthew.wahab@arm.com> 2016-04-18 Matthew Wahab <matthew.wahab@arm.com>
PR target/70711 PR target/70711
......
2016-04-18 Richard Biener <rguenther@suse.de> 2016-04-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/43434
* gcc.dg/vect/pr43434.c: New testcase.
* c-c++-common/goacc/kernels-alias-3.c: Adjust.
* c-c++-common/goacc/kernels-alias-4.c: Likewise.
* c-c++-common/goacc/kernels-alias-5.c: Likewise.
* c-c++-common/goacc/kernels-alias-6.c: Likewise.
* c-c++-common/goacc/kernels-alias-7.c: Likewise.
* c-c++-common/goacc/kernels-alias-8.c: Likewise.
* gcc.dg/gomp/pr68640.c: Likewise.
* gfortran.dg/goacc/kernels-alias-3.f95: Likewise.
* gfortran.dg/goacc/kernels-alias-4.f95: Likewise.
2016-04-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/70701 PR tree-optimization/70701
* gcc.dg/tree-ssa/ssa-fre-53.c: New testcase. * gcc.dg/tree-ssa/ssa-fre-53.c: New testcase.
......
...@@ -14,7 +14,8 @@ foo (void) ...@@ -14,7 +14,8 @@ foo (void)
} }
} }
/* Only the omp_data_i related loads should be annotated with cliques. */ /* Only the omp_data_i related loads should be annotated with
non-base 0 cliques. */
/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */
...@@ -16,7 +16,8 @@ foo (void) ...@@ -16,7 +16,8 @@ foo (void)
} }
} }
/* Only the omp_data_i related loads should be annotated with cliques. */ /* Only the omp_data_i related loads should be annotated with
non-base 0 cliques. */
/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */
...@@ -15,5 +15,5 @@ foo (int *a) ...@@ -15,5 +15,5 @@ foo (int *a)
/* Only the omp_data_i related loads should be annotated with cliques. */ /* Only the omp_data_i related loads should be annotated with cliques. */
/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 4 "ealias" } } */
...@@ -19,5 +19,5 @@ foo (void) ...@@ -19,5 +19,5 @@ foo (void)
/* Only the omp_data_i related loads should be annotated with cliques. */ /* Only the omp_data_i related loads should be annotated with cliques. */
/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */
...@@ -21,5 +21,5 @@ foo (void) ...@@ -21,5 +21,5 @@ foo (void)
/* Only the omp_data_i related loads should be annotated with cliques. */ /* Only the omp_data_i related loads should be annotated with cliques. */
/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */
...@@ -18,5 +18,5 @@ foo (int *a, size_t n) ...@@ -18,5 +18,5 @@ foo (int *a, size_t n)
/* Only the omp_data_i related loads should be annotated with cliques. */ /* Only the omp_data_i related loads should be annotated with cliques. */
/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } } */
...@@ -13,4 +13,4 @@ foo (int *__restrict__ ap) ...@@ -13,4 +13,4 @@ foo (int *__restrict__ ap)
} }
/* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } */
/* { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } */ /* { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 2 "ealias" } } */
/* { dg-do compile } */
typedef short DCTELEM;
typedef unsigned char uint8_t;
void diff_pixels_c(DCTELEM *__restrict__ block, const uint8_t *s1,
const uint8_t *s2, int stride)
{
int i;
for(i=0;i<8;i++)
{
block[0] = s1[0] - s2[0];
block[1] = s1[1] - s2[1];
block[2] = s1[2] - s2[2];
block[3] = s1[3] - s2[3];
block[4] = s1[4] - s2[4];
block[5] = s1[5] - s2[5];
block[6] = s1[6] - s2[6];
block[7] = s1[7] - s2[7];
s1 += stride;
s2 += stride;
block += 8;
}
}
/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target { vect_int && { vect_unpack && vect_hw_misalign } } } } } */
...@@ -16,4 +16,4 @@ end program main ...@@ -16,4 +16,4 @@ end program main
! Only the omp_data_i related loads should be annotated with cliques. ! Only the omp_data_i related loads should be annotated with cliques.
! { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } } ! { dg-final { scan-tree-dump-times "clique 1 base 1" 2 "ealias" } }
! { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 2 "ealias" } } ! { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 3 "ealias" } }
...@@ -17,4 +17,4 @@ end program main ...@@ -17,4 +17,4 @@ end program main
! Only the omp_data_i related loads should be annotated with cliques. ! Only the omp_data_i related loads should be annotated with cliques.
! { dg-final { scan-tree-dump-times "clique 1 base 1" 3 "ealias" } } ! { dg-final { scan-tree-dump-times "clique 1 base 1" 3 "ealias" } }
! { dg-final { scan-tree-dump-times "(?n)clique .* base .*" 3 "ealias" } } ! { dg-final { scan-tree-dump-times "(?n)clique 1 base 0" 4 "ealias" } }
...@@ -7182,13 +7182,20 @@ delete_points_to_sets (void) ...@@ -7182,13 +7182,20 @@ delete_points_to_sets (void)
obstack_free (&final_solutions_obstack, NULL); obstack_free (&final_solutions_obstack, NULL);
} }
struct vls_data
{
unsigned short clique;
bitmap rvars;
};
/* Mark "other" loads and stores as belonging to CLIQUE and with /* Mark "other" loads and stores as belonging to CLIQUE and with
base zero. */ base zero. */
static bool static bool
visit_loadstore (gimple *, tree base, tree ref, void *clique_) visit_loadstore (gimple *, tree base, tree ref, void *data)
{ {
unsigned short clique = (uintptr_t)clique_; unsigned short clique = ((vls_data *) data)->clique;
bitmap rvars = ((vls_data *) data)->rvars;
if (TREE_CODE (base) == MEM_REF if (TREE_CODE (base) == MEM_REF
|| TREE_CODE (base) == TARGET_MEM_REF) || TREE_CODE (base) == TARGET_MEM_REF)
{ {
...@@ -7196,12 +7203,16 @@ visit_loadstore (gimple *, tree base, tree ref, void *clique_) ...@@ -7196,12 +7203,16 @@ visit_loadstore (gimple *, tree base, tree ref, void *clique_)
if (TREE_CODE (ptr) == SSA_NAME if (TREE_CODE (ptr) == SSA_NAME
&& ! SSA_NAME_IS_DEFAULT_DEF (ptr)) && ! SSA_NAME_IS_DEFAULT_DEF (ptr))
{ {
/* ??? We need to make sure 'ptr' doesn't include any of /* We need to make sure 'ptr' doesn't include any of
the restrict tags we added bases for in its points-to set. */ the restrict tags we added bases for in its points-to set. */
return false; varinfo_t vi = lookup_vi_for_tree (ptr);
} if (! vi)
return false;
/* For now let decls through. */ vi = get_varinfo (find (vi->id));
if (bitmap_intersect_p (rvars, vi->solution))
return false;
}
/* Do not overwrite existing cliques (that includes clique, base /* Do not overwrite existing cliques (that includes clique, base
pairs we just set). */ pairs we just set). */
...@@ -7275,6 +7286,7 @@ compute_dependence_clique (void) ...@@ -7275,6 +7286,7 @@ compute_dependence_clique (void)
{ {
unsigned short clique = 0; unsigned short clique = 0;
unsigned short last_ruid = 0; unsigned short last_ruid = 0;
bitmap rvars = BITMAP_ALLOC (NULL);
for (unsigned i = 0; i < num_ssa_names; ++i) for (unsigned i = 0; i < num_ssa_names; ++i)
{ {
tree ptr = ssa_name (i); tree ptr = ssa_name (i);
...@@ -7330,38 +7342,46 @@ compute_dependence_clique (void) ...@@ -7330,38 +7342,46 @@ compute_dependence_clique (void)
/* Now look at possible dereferences of ptr. */ /* Now look at possible dereferences of ptr. */
imm_use_iterator ui; imm_use_iterator ui;
gimple *use_stmt; gimple *use_stmt;
bool used = false;
FOR_EACH_IMM_USE_STMT (use_stmt, ui, ptr) FOR_EACH_IMM_USE_STMT (use_stmt, ui, ptr)
{ {
/* ??? Calls and asms. */ /* ??? Calls and asms. */
if (!gimple_assign_single_p (use_stmt)) if (!gimple_assign_single_p (use_stmt))
continue; continue;
maybe_set_dependence_info (gimple_assign_lhs (use_stmt), ptr, used |= maybe_set_dependence_info (gimple_assign_lhs (use_stmt),
clique, restrict_var, last_ruid); ptr, clique, restrict_var,
maybe_set_dependence_info (gimple_assign_rhs1 (use_stmt), ptr, last_ruid);
clique, restrict_var, last_ruid); used |= maybe_set_dependence_info (gimple_assign_rhs1 (use_stmt),
ptr, clique, restrict_var,
last_ruid);
} }
if (used)
bitmap_set_bit (rvars, restrict_var->id);
} }
} }
if (clique == 0) if (clique != 0)
return; {
/* Assign the BASE id zero to all accesses not based on a restrict
pointer. That way they get disambiguated against restrict
accesses but not against each other. */
/* ??? For restricts derived from globals (thus not incoming
parameters) we can't restrict scoping properly thus the following
is too aggressive there. For now we have excluded those globals from
getting into the MR_DEPENDENCE machinery. */
vls_data data = { clique, rvars };
basic_block bb;
FOR_EACH_BB_FN (bb, cfun)
for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
!gsi_end_p (gsi); gsi_next (&gsi))
{
gimple *stmt = gsi_stmt (gsi);
walk_stmt_load_store_ops (stmt, &data,
visit_loadstore, visit_loadstore);
}
}
/* Assign the BASE id zero to all accesses not based on a restrict BITMAP_FREE (rvars);
pointer. That way they get disabiguated against restrict
accesses but not against each other. */
/* ??? For restricts derived from globals (thus not incoming
parameters) we can't restrict scoping properly thus the following
is too aggressive there. For now we have excluded those globals from
getting into the MR_DEPENDENCE machinery. */
basic_block bb;
FOR_EACH_BB_FN (bb, cfun)
for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
!gsi_end_p (gsi); gsi_next (&gsi))
{
gimple *stmt = gsi_stmt (gsi);
walk_stmt_load_store_ops (stmt, (void *)(uintptr_t)clique,
visit_loadstore, visit_loadstore);
}
} }
/* Compute points-to information for every SSA_NAME pointer in the /* Compute points-to information for every SSA_NAME pointer in the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment