Commit 10f30ac9 by Richard Biener Committed by Richard Biener

re PR tree-optimization/91756 (g++.dg/lto/alias-3 FAILs)

2019-09-16  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/91756
	PR tree-optimization/87132
	* tree-ssa-alias.h (enum translate_flags): New.
	(get_continuation_for_phi): Use it instead of simple bool flag.
	(walk_non_aliased_vuses): Likewise.
	* tree-ssa-alias.c (maybe_skip_until): Adjust.
	(get_continuation_for_phi): When looking across backedges only
	disallow valueization.
	(walk_non_aliased_vuses): Adjust.
	* tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid valueization
	if requested.

	* gcc.dg/tree-ssa/ssa-fre-81.c: New testcase.

From-SVN: r275747
parent ddc1a45b
2019-09-16 Richard Biener <rguenther@suse.de>
PR tree-optimization/91756
PR tree-optimization/87132
* tree-ssa-alias.h (enum translate_flags): New.
(get_continuation_for_phi): Use it instead of simple bool flag.
(walk_non_aliased_vuses): Likewise.
* tree-ssa-alias.c (maybe_skip_until): Adjust.
(get_continuation_for_phi): When looking across backedges only
disallow valueization.
(walk_non_aliased_vuses): Adjust.
* tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid valueization
if requested.
2019-09-14 Kewen Lin <linkw@gcc.gnu.org> 2019-09-14 Kewen Lin <linkw@gcc.gnu.org>
PR middle-end/80791 PR middle-end/80791
......
2019-09-16 Richard Biener <rguenther@suse.de>
PR tree-optimization/91756
PR tree-optimization/87132
* gcc.dg/tree-ssa/ssa-fre-81.c: New testcase.
2019-09-15 Marek Polacek <polacek@redhat.com> 2019-09-15 Marek Polacek <polacek@redhat.com>
PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF. PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF.
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-fre1-details" } */
struct a
{
int foo,bar;
};
struct b
{
struct a a[10];
};
struct b b, *bptr=&b, *bptr2=&b;
int j;
int i;
int n=1;
int
main ()
{
int jj=j;
bptr2->a[jj].bar = 0;
for (int i=0; i<n; i++)
bptr->a[i].foo=1;
if (!__builtin_constant_p (bptr2->a[jj].bar == 0))
__builtin_abort ();
return 0;
}
/* { dg-final { scan-tree-dump "Replaced __builtin_constant_p \\\(\[^)\]*\\\) with 1" "fre1" } } */
...@@ -3150,7 +3150,8 @@ static bool ...@@ -3150,7 +3150,8 @@ static bool
maybe_skip_until (gimple *phi, tree &target, basic_block target_bb, maybe_skip_until (gimple *phi, tree &target, basic_block target_bb,
ao_ref *ref, tree vuse, bool tbaa_p, unsigned int &limit, ao_ref *ref, tree vuse, bool tbaa_p, unsigned int &limit,
bitmap *visited, bool abort_on_visited, bitmap *visited, bool abort_on_visited,
void *(*translate)(ao_ref *, tree, void *, bool *), void *(*translate)(ao_ref *, tree, void *, translate_flags *),
translate_flags disambiguate_only,
void *data) void *data)
{ {
basic_block bb = gimple_bb (phi); basic_block bb = gimple_bb (phi);
...@@ -3185,7 +3186,7 @@ maybe_skip_until (gimple *phi, tree &target, basic_block target_bb, ...@@ -3185,7 +3186,7 @@ maybe_skip_until (gimple *phi, tree &target, basic_block target_bb,
return !abort_on_visited; return !abort_on_visited;
vuse = get_continuation_for_phi (def_stmt, ref, tbaa_p, limit, vuse = get_continuation_for_phi (def_stmt, ref, tbaa_p, limit,
visited, abort_on_visited, visited, abort_on_visited,
translate, data); translate, data, disambiguate_only);
if (!vuse) if (!vuse)
return false; return false;
continue; continue;
...@@ -3200,9 +3201,9 @@ maybe_skip_until (gimple *phi, tree &target, basic_block target_bb, ...@@ -3200,9 +3201,9 @@ maybe_skip_until (gimple *phi, tree &target, basic_block target_bb,
--limit; --limit;
if (stmt_may_clobber_ref_p_1 (def_stmt, ref, tbaa_p)) if (stmt_may_clobber_ref_p_1 (def_stmt, ref, tbaa_p))
{ {
bool disambiguate_only = true; translate_flags tf = disambiguate_only;
if (translate if (translate
&& (*translate) (ref, vuse, data, &disambiguate_only) == NULL) && (*translate) (ref, vuse, data, &tf) == NULL)
; ;
else else
return false; return false;
...@@ -3233,8 +3234,10 @@ tree ...@@ -3233,8 +3234,10 @@ tree
get_continuation_for_phi (gimple *phi, ao_ref *ref, bool tbaa_p, get_continuation_for_phi (gimple *phi, ao_ref *ref, bool tbaa_p,
unsigned int &limit, bitmap *visited, unsigned int &limit, bitmap *visited,
bool abort_on_visited, bool abort_on_visited,
void *(*translate)(ao_ref *, tree, void *, bool *), void *(*translate)(ao_ref *, tree, void *,
void *data) translate_flags *),
void *data,
translate_flags disambiguate_only)
{ {
unsigned nargs = gimple_phi_num_args (phi); unsigned nargs = gimple_phi_num_args (phi);
...@@ -3276,13 +3279,15 @@ get_continuation_for_phi (gimple *phi, ao_ref *ref, bool tbaa_p, ...@@ -3276,13 +3279,15 @@ get_continuation_for_phi (gimple *phi, ao_ref *ref, bool tbaa_p,
else if (! maybe_skip_until (phi, arg0, dom, ref, arg1, tbaa_p, else if (! maybe_skip_until (phi, arg0, dom, ref, arg1, tbaa_p,
limit, visited, limit, visited,
abort_on_visited, abort_on_visited,
/* Do not translate when walking over translate,
/* Do not valueize when walking over
backedges. */ backedges. */
dominated_by_p dominated_by_p
(CDI_DOMINATORS, (CDI_DOMINATORS,
gimple_bb (SSA_NAME_DEF_STMT (arg1)), gimple_bb (SSA_NAME_DEF_STMT (arg1)),
phi_bb) phi_bb)
? NULL : translate, data)) ? TR_DISAMBIGUATE
: disambiguate_only, data))
return NULL_TREE; return NULL_TREE;
} }
...@@ -3320,7 +3325,8 @@ get_continuation_for_phi (gimple *phi, ao_ref *ref, bool tbaa_p, ...@@ -3320,7 +3325,8 @@ get_continuation_for_phi (gimple *phi, ao_ref *ref, bool tbaa_p,
void * void *
walk_non_aliased_vuses (ao_ref *ref, tree vuse, bool tbaa_p, walk_non_aliased_vuses (ao_ref *ref, tree vuse, bool tbaa_p,
void *(*walker)(ao_ref *, tree, void *), void *(*walker)(ao_ref *, tree, void *),
void *(*translate)(ao_ref *, tree, void *, bool *), void *(*translate)(ao_ref *, tree, void *,
translate_flags *),
tree (*valueize)(tree), tree (*valueize)(tree),
unsigned &limit, void *data) unsigned &limit, void *data)
{ {
...@@ -3373,7 +3379,7 @@ walk_non_aliased_vuses (ao_ref *ref, tree vuse, bool tbaa_p, ...@@ -3373,7 +3379,7 @@ walk_non_aliased_vuses (ao_ref *ref, tree vuse, bool tbaa_p,
{ {
if (!translate) if (!translate)
break; break;
bool disambiguate_only = false; translate_flags disambiguate_only = TR_TRANSLATE;
res = (*translate) (ref, vuse, data, &disambiguate_only); res = (*translate) (ref, vuse, data, &disambiguate_only);
/* Failed lookup and translation. */ /* Failed lookup and translation. */
if (res == (void *)-1) if (res == (void *)-1)
...@@ -3385,7 +3391,7 @@ walk_non_aliased_vuses (ao_ref *ref, tree vuse, bool tbaa_p, ...@@ -3385,7 +3391,7 @@ walk_non_aliased_vuses (ao_ref *ref, tree vuse, bool tbaa_p,
else if (res != NULL) else if (res != NULL)
break; break;
/* Translation succeeded, continue walking. */ /* Translation succeeded, continue walking. */
translated = translated || !disambiguate_only; translated = translated || disambiguate_only == TR_TRANSLATE;
} }
vuse = gimple_vuse (def_stmt); vuse = gimple_vuse (def_stmt);
} }
......
...@@ -132,13 +132,18 @@ extern bool call_may_clobber_ref_p (gcall *, tree); ...@@ -132,13 +132,18 @@ extern bool call_may_clobber_ref_p (gcall *, tree);
extern bool call_may_clobber_ref_p_1 (gcall *, ao_ref *); extern bool call_may_clobber_ref_p_1 (gcall *, ao_ref *);
extern bool stmt_kills_ref_p (gimple *, tree); extern bool stmt_kills_ref_p (gimple *, tree);
extern bool stmt_kills_ref_p (gimple *, ao_ref *); extern bool stmt_kills_ref_p (gimple *, ao_ref *);
enum translate_flags
{ TR_TRANSLATE, TR_VALUEIZE_AND_DISAMBIGUATE, TR_DISAMBIGUATE };
extern tree get_continuation_for_phi (gimple *, ao_ref *, bool, extern tree get_continuation_for_phi (gimple *, ao_ref *, bool,
unsigned int &, bitmap *, bool, unsigned int &, bitmap *, bool,
void *(*)(ao_ref *, tree, void *, bool *), void *(*)(ao_ref *, tree, void *,
void *); translate_flags *),
void *, translate_flags
= TR_VALUEIZE_AND_DISAMBIGUATE);
extern void *walk_non_aliased_vuses (ao_ref *, tree, bool, extern void *walk_non_aliased_vuses (ao_ref *, tree, bool,
void *(*)(ao_ref *, tree, void *), void *(*)(ao_ref *, tree, void *),
void *(*)(ao_ref *, tree, void *, bool *), void *(*)(ao_ref *, tree, void *,
translate_flags *),
tree (*)(tree), unsigned &, void *); tree (*)(tree), unsigned &, void *);
extern int walk_aliased_vdefs (ao_ref *, tree, extern int walk_aliased_vdefs (ao_ref *, tree,
bool (*)(ao_ref *, tree, void *), bool (*)(ao_ref *, tree, void *),
......
...@@ -2189,7 +2189,7 @@ adjust_offsets_for_equal_base_address (tree base1, poly_int64 *offset1, ...@@ -2189,7 +2189,7 @@ adjust_offsets_for_equal_base_address (tree base1, poly_int64 *offset1,
static void * static void *
vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
bool *disambiguate_only) translate_flags *disambiguate_only)
{ {
vn_walk_cb_data *data = (vn_walk_cb_data *)data_; vn_walk_cb_data *data = (vn_walk_cb_data *)data_;
vn_reference_t vr = data->vr; vn_reference_t vr = data->vr;
...@@ -2210,8 +2210,11 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, ...@@ -2210,8 +2210,11 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
lhs_ops.truncate (0); lhs_ops.truncate (0);
basic_block saved_rpo_bb = vn_context_bb; basic_block saved_rpo_bb = vn_context_bb;
vn_context_bb = gimple_bb (def_stmt); vn_context_bb = gimple_bb (def_stmt);
copy_reference_ops_from_ref (lhs, &lhs_ops); if (*disambiguate_only <= TR_VALUEIZE_AND_DISAMBIGUATE)
lhs_ops = valueize_refs_1 (lhs_ops, &valueized_anything, true); {
copy_reference_ops_from_ref (lhs, &lhs_ops);
lhs_ops = valueize_refs_1 (lhs_ops, &valueized_anything, true);
}
vn_context_bb = saved_rpo_bb; vn_context_bb = saved_rpo_bb;
if (valueized_anything) if (valueized_anything)
{ {
...@@ -2221,7 +2224,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, ...@@ -2221,7 +2224,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
if (lhs_ref_ok if (lhs_ref_ok
&& !refs_may_alias_p_1 (ref, &lhs_ref, data->tbaa_p)) && !refs_may_alias_p_1 (ref, &lhs_ref, data->tbaa_p))
{ {
*disambiguate_only = true; *disambiguate_only = TR_VALUEIZE_AND_DISAMBIGUATE;
return NULL; return NULL;
} }
} }
...@@ -2248,7 +2251,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, ...@@ -2248,7 +2251,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
} }
if (!refs_may_alias_p_1 (&data->orig_ref, lref, data->tbaa_p)) if (!refs_may_alias_p_1 (&data->orig_ref, lref, data->tbaa_p))
{ {
*disambiguate_only = true; *disambiguate_only = (valueized_anything
? TR_VALUEIZE_AND_DISAMBIGUATE
: TR_DISAMBIGUATE);
return NULL; return NULL;
} }
} }
...@@ -2290,7 +2295,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, ...@@ -2290,7 +2295,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
} }
} }
} }
else if (gimple_call_builtin_p (def_stmt, BUILT_IN_NORMAL) else if (*disambiguate_only <= TR_VALUEIZE_AND_DISAMBIGUATE
&& gimple_call_builtin_p (def_stmt, BUILT_IN_NORMAL)
&& gimple_call_num_args (def_stmt) <= 4) && gimple_call_num_args (def_stmt) <= 4)
{ {
/* For builtin calls valueize its arguments and call the /* For builtin calls valueize its arguments and call the
...@@ -2319,7 +2325,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, ...@@ -2319,7 +2325,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
gimple_call_set_arg (def_stmt, i, oldargs[i]); gimple_call_set_arg (def_stmt, i, oldargs[i]);
if (!res) if (!res)
{ {
*disambiguate_only = true; *disambiguate_only = TR_VALUEIZE_AND_DISAMBIGUATE;
return NULL; return NULL;
} }
} }
...@@ -2327,7 +2333,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, ...@@ -2327,7 +2333,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
/* If we are looking for redundant stores do not create new hashtable /* If we are looking for redundant stores do not create new hashtable
entries from aliasing defs with made up alias-sets. */ entries from aliasing defs with made up alias-sets. */
if (*disambiguate_only || !data->tbaa_p) if (*disambiguate_only > TR_TRANSLATE || !data->tbaa_p)
return (void *)-1; return (void *)-1;
/* If we cannot constrain the size of the reference we cannot /* If we cannot constrain the size of the reference we cannot
......
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