From: Richard Biener Date: Mon, 16 Sep 2019 11:58:35 +0000 (+0000) Subject: re PR tree-optimization/91756 (g++.dg/lto/alias-3 FAILs) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=10f30ac9cda947d117e50f0cbd4cf94ee70a944f;p=gcc.git re PR tree-optimization/91756 (g++.dg/lto/alias-3 FAILs) 2019-09-16 Richard Biener 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 41cf9267c95..49b7902e3a8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2019-09-16 Richard Biener + + 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 PR middle-end/80791 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6a5ba09391e..b893ed0d462 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-09-16 Richard Biener + + PR tree-optimization/91756 + PR tree-optimization/87132 + * gcc.dg/tree-ssa/ssa-fre-81.c: New testcase. + 2019-09-15 Marek Polacek PR c++/91740 - ICE with constexpr call and ?: in ARRAY_REF. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-81.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-81.c new file mode 100644 index 00000000000..e88f6663aaa --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-81.c @@ -0,0 +1,29 @@ +/* { 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; ia[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" } } */ diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index dd2a43e1409..52cda38c2aa 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -3150,7 +3150,8 @@ static bool maybe_skip_until (gimple *phi, tree &target, basic_block target_bb, ao_ref *ref, tree vuse, bool tbaa_p, unsigned int &limit, 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) { basic_block bb = gimple_bb (phi); @@ -3185,7 +3186,7 @@ maybe_skip_until (gimple *phi, tree &target, basic_block target_bb, return !abort_on_visited; vuse = get_continuation_for_phi (def_stmt, ref, tbaa_p, limit, visited, abort_on_visited, - translate, data); + translate, data, disambiguate_only); if (!vuse) return false; continue; @@ -3200,9 +3201,9 @@ maybe_skip_until (gimple *phi, tree &target, basic_block target_bb, --limit; if (stmt_may_clobber_ref_p_1 (def_stmt, ref, tbaa_p)) { - bool disambiguate_only = true; + translate_flags tf = disambiguate_only; if (translate - && (*translate) (ref, vuse, data, &disambiguate_only) == NULL) + && (*translate) (ref, vuse, data, &tf) == NULL) ; else return false; @@ -3233,8 +3234,10 @@ tree get_continuation_for_phi (gimple *phi, ao_ref *ref, bool tbaa_p, unsigned int &limit, bitmap *visited, bool abort_on_visited, - void *(*translate)(ao_ref *, tree, void *, bool *), - void *data) + void *(*translate)(ao_ref *, tree, void *, + translate_flags *), + void *data, + translate_flags disambiguate_only) { unsigned nargs = gimple_phi_num_args (phi); @@ -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, limit, visited, abort_on_visited, - /* Do not translate when walking over + translate, + /* Do not valueize when walking over backedges. */ dominated_by_p (CDI_DOMINATORS, gimple_bb (SSA_NAME_DEF_STMT (arg1)), phi_bb) - ? NULL : translate, data)) + ? TR_DISAMBIGUATE + : disambiguate_only, data)) return NULL_TREE; } @@ -3320,7 +3325,8 @@ get_continuation_for_phi (gimple *phi, ao_ref *ref, bool tbaa_p, void * walk_non_aliased_vuses (ao_ref *ref, tree vuse, bool tbaa_p, void *(*walker)(ao_ref *, tree, void *), - void *(*translate)(ao_ref *, tree, void *, bool *), + void *(*translate)(ao_ref *, tree, void *, + translate_flags *), tree (*valueize)(tree), unsigned &limit, void *data) { @@ -3373,7 +3379,7 @@ walk_non_aliased_vuses (ao_ref *ref, tree vuse, bool tbaa_p, { if (!translate) break; - bool disambiguate_only = false; + translate_flags disambiguate_only = TR_TRANSLATE; res = (*translate) (ref, vuse, data, &disambiguate_only); /* Failed lookup and translation. */ if (res == (void *)-1) @@ -3385,7 +3391,7 @@ walk_non_aliased_vuses (ao_ref *ref, tree vuse, bool tbaa_p, else if (res != NULL) break; /* Translation succeeded, continue walking. */ - translated = translated || !disambiguate_only; + translated = translated || disambiguate_only == TR_TRANSLATE; } vuse = gimple_vuse (def_stmt); } diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h index c7c6020efc0..6d72c2fcdc2 100644 --- a/gcc/tree-ssa-alias.h +++ b/gcc/tree-ssa-alias.h @@ -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 stmt_kills_ref_p (gimple *, tree); 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, unsigned int &, bitmap *, bool, - void *(*)(ao_ref *, tree, void *, bool *), - void *); + void *(*)(ao_ref *, tree, void *, + translate_flags *), + void *, translate_flags + = TR_VALUEIZE_AND_DISAMBIGUATE); extern void *walk_non_aliased_vuses (ao_ref *, tree, bool, void *(*)(ao_ref *, tree, void *), - void *(*)(ao_ref *, tree, void *, bool *), + void *(*)(ao_ref *, tree, void *, + translate_flags *), tree (*)(tree), unsigned &, void *); extern int walk_aliased_vdefs (ao_ref *, tree, bool (*)(ao_ref *, tree, void *), diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index f5d75bdfc99..c29e2de61ac 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2189,7 +2189,7 @@ adjust_offsets_for_equal_base_address (tree base1, poly_int64 *offset1, static void * 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_reference_t vr = data->vr; @@ -2210,8 +2210,11 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, lhs_ops.truncate (0); basic_block saved_rpo_bb = vn_context_bb; vn_context_bb = gimple_bb (def_stmt); - copy_reference_ops_from_ref (lhs, &lhs_ops); - lhs_ops = valueize_refs_1 (lhs_ops, &valueized_anything, true); + if (*disambiguate_only <= TR_VALUEIZE_AND_DISAMBIGUATE) + { + copy_reference_ops_from_ref (lhs, &lhs_ops); + lhs_ops = valueize_refs_1 (lhs_ops, &valueized_anything, true); + } vn_context_bb = saved_rpo_bb; if (valueized_anything) { @@ -2221,7 +2224,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, if (lhs_ref_ok && !refs_may_alias_p_1 (ref, &lhs_ref, data->tbaa_p)) { - *disambiguate_only = true; + *disambiguate_only = TR_VALUEIZE_AND_DISAMBIGUATE; return NULL; } } @@ -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)) { - *disambiguate_only = true; + *disambiguate_only = (valueized_anything + ? TR_VALUEIZE_AND_DISAMBIGUATE + : TR_DISAMBIGUATE); return NULL; } } @@ -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) { /* For builtin calls valueize its arguments and call the @@ -2319,7 +2325,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, gimple_call_set_arg (def_stmt, i, oldargs[i]); if (!res) { - *disambiguate_only = true; + *disambiguate_only = TR_VALUEIZE_AND_DISAMBIGUATE; return NULL; } } @@ -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 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; /* If we cannot constrain the size of the reference we cannot