summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-15 08:42:38 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2016-02-15 08:42:38 +0000
commit0b3619e679a031ff598144bd36c66e2f52660fae (patch)
treeced0a83a15fa56f6e17922648bde552b105142be
parentc44214d37487d229b8d7f5d7fdc63f12e924cc82 (diff)
downloadgcc-0b3619e679a031ff598144bd36c66e2f52660fae.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233418 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr69776.c28
-rw-r--r--gcc/tree-ssa-pre.c4
-rw-r--r--gcc/tree-ssa-sccvn.c13
-rw-r--r--gcc/tree-ssa-sccvn.h2
6 files changed, 57 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fda12cf1f36..565b50598c4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+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.
+
2016-02-14 John David Anglin <danglin@gcc.gnu.org>
* config/pa/pa.md (absqi2, absghi2, bswaphi2, bswapsi2, bswapdi2): New.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9dfdc7694b2..4d129d810f6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-02-15 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/69776
+ * gcc.dg/torture/pr69776.c: New testcase.
+
2016-02-14 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/60526
diff --git a/gcc/testsuite/gcc.dg/torture/pr69776.c b/gcc/testsuite/gcc.dg/torture/pr69776.c
new file mode 100644
index 00000000000..f2d971caabc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr69776.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fstrict-aliasing" } */
+
+extern void *malloc (__SIZE_TYPE__);
+extern void abort (void);
+
+void __attribute__((noinline,noclone))
+foo (int *pi)
+{
+ if (*pi != 1)
+ abort ();
+}
+
+int
+main()
+{
+ void *p = malloc(sizeof (double));
+ int *pi = p;
+ double *pd = p;
+
+ *pi = 1;
+ int a = *pi;
+ *pd = 0;
+ *pi = a;
+ foo (pi);
+
+ return 0;
+}
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 3570ee92a2b..b2d63acf930 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -3745,7 +3745,7 @@ compute_avail (void)
vn_reference_t ref;
vn_reference_lookup (gimple_assign_rhs1 (stmt),
gimple_vuse (stmt),
- VN_WALK, &ref);
+ VN_WALK, &ref, true);
if (!ref)
continue;
@@ -4208,7 +4208,7 @@ eliminate_dom_walker::before_dom_children (basic_block b)
tree val;
tree rhs = gimple_assign_rhs1 (stmt);
val = vn_reference_lookup (gimple_assign_lhs (stmt),
- gimple_vuse (stmt), VN_WALK, NULL);
+ gimple_vuse (stmt), VN_WALK, NULL, false);
if (TREE_CODE (rhs) == SSA_NAME)
rhs = VN_INFO (rhs)->valnum;
if (val
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 726294e2c2c..5b78ba4a750 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;
diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h
index e8e710b0c55..a3f9fa26ad3 100644
--- a/gcc/tree-ssa-sccvn.h
+++ b/gcc/tree-ssa-sccvn.h
@@ -216,7 +216,7 @@ bool ao_ref_init_from_vn_reference (ao_ref *, alias_set_type, tree,
tree vn_reference_lookup_pieces (tree, alias_set_type, tree,
vec<vn_reference_op_s> ,
vn_reference_t *, vn_lookup_kind);
-tree vn_reference_lookup (tree, tree, vn_lookup_kind, vn_reference_t *);
+tree vn_reference_lookup (tree, tree, vn_lookup_kind, vn_reference_t *, bool);
void vn_reference_lookup_call (gcall *, vn_reference_t *, vn_reference_t);
vn_reference_t vn_reference_insert_pieces (tree, alias_set_type, tree,
vec<vn_reference_op_s> ,