Commit 74d27244 by Richard Guenther Committed by Richard Biener

re PR middle-end/14187 ([tree-ssa] C restricted pointers are not properly implemented)

2009-06-29  Richard Guenther  <rguenther@suse.de>

	PR middle-end/14187
	* tree-ssa-alias.h (struct pt_solution): Add vars_contains_restrict
	flag.
	(pt_solutions_same_restrict_base): Declare.
	* tree-ssa-structalias.c (struct variable_info): Add is_restrict_var
	flag.
	(new_var_info): Initialize is_global_var properly for SSA_NAMEs.
	(make_constraint_from, make_copy_constraint): Move earlier.
	(make_constraint_from_heapvar): New function.
	(make_constraint_from_restrict): Likewise.
	(handle_lhs_call): Use it.
	(find_func_aliases): Use it to track conversions to restrict
	qualified pointers.
	(struct fieldoff): Add only_restrict_pointers flag.
	(push_fields_onto_fieldstack): Initialize it.
	(create_variable_info_for): Track global restrict qualified pointers.
	(intra_create_variable_infos): Use make_constraint_from_heapvar.
	Track restrict qualified pointer arguments.
	(set_uids_in_ptset): Use varinfo is_global_var flag.
	(find_what_var_points_to): Set the vars_contains_restrict flag.
	Always create the points-to solution for sets including restrict tags.
	(pt_solutions_same_restrict_base): New function.
	* tree-ssa-alias.c (ptr_derefs_may_alias_p): For two restrict
	qualified pointers use pt_solutions_same_restrict_base as
	additional source for disambiguation.

	* gcc.dg/tree-ssa/restrict-1.c: New testcase.
	* gcc.dg/tree-ssa/restrict-2.c: Likewise.
	* gcc.dg/tree-ssa/restrict-3.c: Likewise.
	* gcc.c-torture/execute/20090623-1.c: Likewise.
	* gcc.dg/tree-ssa/ldist-13.c: Likewise.
	* gcc.dg/tree-ssa/ldist-14.c: Likewise.

From-SVN: r149048
parent 5b21f0f3
2009-06-29 Richard Guenther <rguenther@suse.de>
PR middle-end/14187
* tree-ssa-alias.h (struct pt_solution): Add vars_contains_restrict
flag.
(pt_solutions_same_restrict_base): Declare.
* tree-ssa-structalias.c (struct variable_info): Add is_restrict_var
flag.
(new_var_info): Initialize is_global_var properly for SSA_NAMEs.
(make_constraint_from, make_copy_constraint): Move earlier.
(make_constraint_from_heapvar): New function.
(make_constraint_from_restrict): Likewise.
(handle_lhs_call): Use it.
(find_func_aliases): Use it to track conversions to restrict
qualified pointers.
(struct fieldoff): Add only_restrict_pointers flag.
(push_fields_onto_fieldstack): Initialize it.
(create_variable_info_for): Track global restrict qualified pointers.
(intra_create_variable_infos): Use make_constraint_from_heapvar.
Track restrict qualified pointer arguments.
(set_uids_in_ptset): Use varinfo is_global_var flag.
(find_what_var_points_to): Set the vars_contains_restrict flag.
Always create the points-to solution for sets including restrict tags.
(pt_solutions_same_restrict_base): New function.
* tree-ssa-alias.c (ptr_derefs_may_alias_p): For two restrict
qualified pointers use pt_solutions_same_restrict_base as
additional source for disambiguation.
2009-06-29 Richard Guenther <rguenther@suse.de>
PR middle-end/38212
* alias.c (find_base_decl): Remove.
(get_deref_alias_set_1): Remove restrict handling.
......
2009-06-29 Richard Guenther <rguenther@suse.de>
PR middle-end/14187
* gcc.dg/tree-ssa/restrict-1.c: New testcase.
* gcc.dg/tree-ssa/restrict-2.c: Likewise.
* gcc.dg/tree-ssa/restrict-3.c: Likewise.
* gcc.c-torture/execute/20090623-1.c: Likewise.
* gcc.dg/tree-ssa/ldist-13.c: Likewise.
* gcc.dg/tree-ssa/ldist-14.c: Likewise.
2009-06-29 Richard Guenther <rguenther@suse.de>
PR middle-end/38212
* gcc.c-torture/execute/pr38212.c: New testcase.
......
int * __restrict__ x;
int foo (int y)
{
*x = y;
return *x;
}
extern void abort (void);
int main()
{
int i = 0;
x = &i;
if (foo(1) != 1)
abort ();
return 0;
}
/* { dg-do compile } */
/* { dg-options "-O2 -ftree-loop-distribution -fdump-tree-ldist-details" } */
float * __restrict__ x;
float * __restrict__ y;
float foo (int n)
{
int i;
float tmp = 0.0;
for (i = 0; i < n; ++i)
{
x[i] = 0.0;
tmp += y[i];
}
return tmp;
}
/* We should apply loop distribution. */
/* { dg-final { scan-tree-dump "Loop 1 distributed: split to 2 loops" "ldist" } } */
/* { dg-final { cleanup-tree-dump "ldist" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fno-strict-aliasing -ftree-loop-distribution -fdump-tree-ldist-details" } */
struct desc {
int i;
void * __restrict__ data;
int j;
} a, b;
float foo (int n)
{
int i;
float * __restrict__ x, * __restrict__ y, tmp = 0.0;
x = (float * __restrict__)a.data;
y = (float * __restrict__)b.data;
for (i = 0; i < n; ++i)
{
x[i] = 0.0;
tmp += y[i];
}
return tmp;
}
/* We should apply loop distribution. */
/* { dg-final { scan-tree-dump "Loop 1 distributed: split to 2 loops" "ldist" } } */
/* { dg-final { cleanup-tree-dump "ldist" } } */
/* { dg-do link } */
/* { dg-options "-O -fno-strict-aliasing -fdump-tree-optimized" } */
extern void link_error (void);
void bar0 (int * __restrict__ arr1, int * __restrict__ arr2)
{
arr1[0] = 1;
arr2[0] = 1;
if (arr1[0] != 1)
link_error ();
}
int main()
{
return 0;
}
/* { dg-final { scan-tree-dump-not "link_error" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
/* { dg-do compile } */
/* { dg-options "-O -fno-strict-aliasing -fdump-tree-lim-details" } */
void foo (float * __restrict__ a, float * __restrict__ b, int n, int j)
{
int i;
for(i = 0; i < n; ++i)
a[i] = (b[j+50] + b[j-50]) * 0.5f;
}
/* We should move the RHS of the store out of the loop. */
/* { dg-final { scan-tree-dump-times "Moving statement" 11 "lim" } } */
/* { dg-final { cleanup-tree-dump "lim" } } */
/* { dg-do compile } */
/* { dg-options "-O -fno-strict-aliasing -fdump-tree-lim-details" } */
void f(int * __restrict__ r,
int a[__restrict__ 16][16],
int b[__restrict__ 16][16],
int i, int j)
{
int x;
*r = 0;
for (x = 1; x < 16; ++x)
*r = *r + a[i][x] * b[x][j];
}
/* We should apply store motion to the store to *r. */
/* { dg-final { scan-tree-dump "Executing store motion of \\\*r" "lim" } } */
/* { dg-final { cleanup-tree-dump "lim" } } */
......@@ -273,6 +273,13 @@ ptr_derefs_may_alias_p (tree ptr1, tree ptr2)
if (!pi1 || !pi2)
return true;
/* If both pointers are restrict-qualified try to disambiguate
with restrict information. */
if (TYPE_RESTRICT (TREE_TYPE (ptr1))
&& TYPE_RESTRICT (TREE_TYPE (ptr2))
&& !pt_solutions_same_restrict_base (&pi1->pt, &pi2->pt))
return false;
/* ??? This does not use TBAA to prune decls from the intersection
that not both pointers may access. */
return pt_solutions_intersect (&pi1->pt, &pi2->pt);
......
......@@ -49,6 +49,9 @@ struct GTY(()) pt_solution
/* Nonzero if the pt_vars bitmap includes a global variable. */
unsigned int vars_contains_global : 1;
/* Nonzero if the pt_vars bitmap includes a restrict tag variable. */
unsigned int vars_contains_restrict : 1;
/* Set of variables that this pointer may point to. */
bitmap vars;
};
......@@ -115,6 +118,8 @@ extern void delete_alias_heapvars (void);
extern bool pt_solution_includes_global (struct pt_solution *);
extern bool pt_solution_includes (struct pt_solution *, const_tree);
extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *);
extern bool pt_solutions_same_restrict_base (struct pt_solution *,
struct pt_solution *);
extern void pt_solution_reset (struct pt_solution *);
extern void dump_pta_stats (FILE *);
......
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