diff options
author | Richard Biener <rguenther@suse.de> | 2016-02-15 08:42:38 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-02-15 08:42:38 +0000 |
commit | 1c48bff185df422d6f9f980fd02466606be2ccd4 (patch) | |
tree | ced0a83a15fa56f6e17922648bde552b105142be /gcc/tree-ssa-sccvn.c | |
parent | 9e074c0d6df7096f40fa0a046dfe6401c413d467 (diff) | |
download | gcc-1c48bff185df422d6f9f980fd02466606be2ccd4.zip gcc-1c48bff185df422d6f9f980fd02466606be2ccd4.tar.gz gcc-1c48bff185df422d6f9f980fd02466606be2ccd4.tar.bz2 |
re PR tree-optimization/69776 (Wrong optimization with aliasing)
2016-02-15 Richard Biener <rguenther@suse.de>
PR tree-optimization/69776
* tree-ssa-sccvn.h (vn_reference_lookup): Adjust prototype.
* tree-ssa-sccvn.c (vn_reference_lookup): Add parameter to
indicate whether we can use TBAA to disambiguate against stores.
Use alias-set zero if not.
(visit_reference_op_store): Do not use TBAA when looking up
redundant stores.
* tree-ssa-pre.c (compute_avail): Use TBAA here.
(eliminate_dom_walker::before_dom_children): But not when looking
up redundant stores.
* gcc.dg/torture/pr69776.c: New testcase.
From-SVN: r233418
Diffstat (limited to 'gcc/tree-ssa-sccvn.c')
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 726294e..5b78ba4 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2230,11 +2230,12 @@ vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type, number if it exists in the hash table. Return NULL_TREE if it does not exist in the hash table or if the result field of the structure was NULL.. VNRESULT will be filled in with the vn_reference_t - stored in the hashtable if one exists. */ + stored in the hashtable if one exists. When TBAA_P is false assume + we are looking up a store and treat it as having alias-set zero. */ tree vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind, - vn_reference_t *vnresult) + vn_reference_t *vnresult, bool tbaa_p) { vec<vn_reference_op_s> operands; struct vn_reference_s vr1; @@ -2264,6 +2265,8 @@ vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind, || !ao_ref_init_from_vn_reference (&r, vr1.set, vr1.type, vr1.operands)) ao_ref_init (&r, op); + if (! tbaa_p) + r.ref_alias_set = r.base_alias_set = 0; vn_walk_kind = kind; wvnresult = (vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse, @@ -3350,7 +3353,7 @@ visit_reference_op_load (tree lhs, tree op, gimple *stmt) last_vuse = gimple_vuse (stmt); last_vuse_ptr = &last_vuse; result = vn_reference_lookup (op, gimple_vuse (stmt), - default_vn_walk_kind, NULL); + default_vn_walk_kind, NULL, true); last_vuse_ptr = NULL; /* We handle type-punning through unions by value-numbering based @@ -3472,7 +3475,7 @@ visit_reference_op_store (tree lhs, tree op, gimple *stmt) Otherwise, the vdefs for the store are used when inserting into the table, since the store generates a new memory state. */ - result = vn_reference_lookup (lhs, vuse, VN_NOWALK, NULL); + result = vn_reference_lookup (lhs, vuse, VN_NOWALK, NULL, false); if (result) { @@ -3487,7 +3490,7 @@ visit_reference_op_store (tree lhs, tree op, gimple *stmt) && default_vn_walk_kind == VN_WALK) { assign = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, op); - vn_reference_lookup (assign, vuse, VN_NOWALK, &vnresult); + vn_reference_lookup (assign, vuse, VN_NOWALK, &vnresult, false); if (vnresult) { VN_INFO (vdef)->use_processed = true; |