Commit 61e189a8 by Richard Biener Committed by Richard Biener

re PR middle-end/87610 (wrong-code with restrict)

2018-10-15  Richard Biener  <rguenther@suse.de>

	PR middle-end/87610
	* tree-ssa-structalias.c (struct vls_data): Add escaped_p member.
	(visit_loadstore): When a used restrict tag escaped verify that
	the points-to solution of "other" pointers do not include
	escaped.
	(compute_dependence_clique): If a used restrict tag escaped
	communicated that down to visit_loadstore.

	* gcc.dg/torture/restrict-6.c: New testcase.

From-SVN: r265160
parent cab5fe16
2018-10-15 Richard Biener <rguenther@suse.de>
PR middle-end/87610
* tree-ssa-structalias.c (struct vls_data): Add escaped_p member.
(visit_loadstore): When a used restrict tag escaped verify that
the points-to solution of "other" pointers do not include
escaped.
(compute_dependence_clique): If a used restrict tag escaped
communicated that down to visit_loadstore.
2018-10-15 Andreas Krebbel <krebbel@linux.ibm.com> 2018-10-15 Andreas Krebbel <krebbel@linux.ibm.com>
* config/s390/s390.c (s390_expand_vec_init): Force vector element * config/s390/s390.c (s390_expand_vec_init): Force vector element
2018-10-15 Richard Biener <rguenther@suse.de>
PR middle-end/87610
* gcc.dg/torture/restrict-6.c: New testcase.
2018-10-15 Andreas Krebbel <krebbel@linux.ibm.com> 2018-10-15 Andreas Krebbel <krebbel@linux.ibm.com>
* g++.dg/vec-init-1.C: New test. * g++.dg/vec-init-1.C: New test.
......
/* { dg-do run } */
extern void abort (void);
void __attribute__((noinline)) g(int **a, int *b)
{
*a = b;
}
int foo(int * restrict p, int *q)
{
g(&q, p);
*p = 1;
*q = 2;
return *p + *q;
}
int main()
{
int x, y;
if (foo(&x, &y) != 4)
abort ();
return 0;
}
...@@ -7397,6 +7397,7 @@ delete_points_to_sets (void) ...@@ -7397,6 +7397,7 @@ delete_points_to_sets (void)
struct vls_data struct vls_data
{ {
unsigned short clique; unsigned short clique;
bool escaped_p;
bitmap rvars; bitmap rvars;
}; };
...@@ -7408,6 +7409,7 @@ visit_loadstore (gimple *, tree base, tree ref, void *data) ...@@ -7408,6 +7409,7 @@ visit_loadstore (gimple *, tree base, tree ref, void *data)
{ {
unsigned short clique = ((vls_data *) data)->clique; unsigned short clique = ((vls_data *) data)->clique;
bitmap rvars = ((vls_data *) data)->rvars; bitmap rvars = ((vls_data *) data)->rvars;
bool escaped_p = ((vls_data *) data)->escaped_p;
if (TREE_CODE (base) == MEM_REF if (TREE_CODE (base) == MEM_REF
|| TREE_CODE (base) == TARGET_MEM_REF) || TREE_CODE (base) == TARGET_MEM_REF)
{ {
...@@ -7428,7 +7430,8 @@ visit_loadstore (gimple *, tree base, tree ref, void *data) ...@@ -7428,7 +7430,8 @@ visit_loadstore (gimple *, tree base, tree ref, void *data)
return false; return false;
vi = get_varinfo (find (vi->id)); vi = get_varinfo (find (vi->id));
if (bitmap_intersect_p (rvars, vi->solution)) if (bitmap_intersect_p (rvars, vi->solution)
|| (escaped_p && bitmap_bit_p (vi->solution, escaped_id)))
return false; return false;
} }
...@@ -7505,6 +7508,7 @@ compute_dependence_clique (void) ...@@ -7505,6 +7508,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); bitmap rvars = BITMAP_ALLOC (NULL);
bool escaped_p = false;
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);
...@@ -7574,7 +7578,12 @@ compute_dependence_clique (void) ...@@ -7574,7 +7578,12 @@ compute_dependence_clique (void)
last_ruid); last_ruid);
} }
if (used) if (used)
{
bitmap_set_bit (rvars, restrict_var->id); bitmap_set_bit (rvars, restrict_var->id);
varinfo_t escaped = get_varinfo (find (escaped_id));
if (bitmap_bit_p (escaped->solution, restrict_var->id))
escaped_p = true;
}
} }
} }
...@@ -7587,7 +7596,7 @@ compute_dependence_clique (void) ...@@ -7587,7 +7596,7 @@ compute_dependence_clique (void)
parameters) we can't restrict scoping properly thus the following parameters) we can't restrict scoping properly thus the following
is too aggressive there. For now we have excluded those globals from is too aggressive there. For now we have excluded those globals from
getting into the MR_DEPENDENCE machinery. */ getting into the MR_DEPENDENCE machinery. */
vls_data data = { clique, rvars }; vls_data data = { clique, escaped_p, rvars };
basic_block bb; basic_block bb;
FOR_EACH_BB_FN (bb, cfun) FOR_EACH_BB_FN (bb, cfun)
for (gimple_stmt_iterator gsi = gsi_start_bb (bb); for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
......
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