aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-06-03 08:02:10 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-06-03 08:02:10 +0000
commit4da60082232bc3dbf5782687e9f0ff25d733de10 (patch)
tree4a730c210522915db4aab6f110f5afa8c3aa58b7 /gcc
parentb9b79ba4264cf635fbd3cc66530c5eb83d3ce568 (diff)
downloadgcc-4da60082232bc3dbf5782687e9f0ff25d733de10.zip
gcc-4da60082232bc3dbf5782687e9f0ff25d733de10.tar.gz
gcc-4da60082232bc3dbf5782687e9f0ff25d733de10.tar.bz2
re PR tree-optimization/63916 (value-numbering fails to forward variable addresses)
2015-06-03 Richard Biener <rguenther@suse.de> PR tree-optimization/63916 * tree-ssa-sccvn.c (vn_reference_maybe_forwprop_address): Forward-propagate non-invariant addresses by splicing their reference ops if the result isn't going to be used by PRE. (vn_reference_lookup_3): Remove pointless assert. * gcc.dg/tree-ssa/ssa-fre-45.c: New testcase. From-SVN: r224061
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-45.c16
-rw-r--r--gcc/tree-ssa-sccvn.c30
4 files changed, 52 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 06dda14..8813ade 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2015-06-03 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/63916
+ * tree-ssa-sccvn.c (vn_reference_maybe_forwprop_address):
+ Forward-propagate non-invariant addresses by splicing their
+ reference ops if the result isn't going to be used by PRE.
+ (vn_reference_lookup_3): Remove pointless assert.
+
+2015-06-03 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/66375
* tree-scalar-evolution.c (follow_ssa_edge_binary): First
add to the evolution before following SSA edges.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9fd5941..026dd53 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2015-06-03 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/63916
+ * gcc.dg/tree-ssa/ssa-fre-45.c: New testcase.
+
+2015-06-03 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/66375
* gcc.dg/torture/pr66375.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-45.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-45.c
new file mode 100644
index 0000000..ea8957f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-45.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-fre1" } */
+
+struct S { float a, b; };
+
+float
+foo (int x, float y)
+{
+ struct S z[1024];
+ z[x].a = y;
+ struct S *p = &z[x];
+ float *q = (float *) p;
+ return *q;
+}
+
+/* { dg-final { scan-tree-dump "return y_\\d\+\\(D\\);" "fre1" } } */
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 19fb604..e7838ed 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -144,6 +144,10 @@ along with GCC; see the file COPYING3. If not see
*/
+static tree *last_vuse_ptr;
+static vn_lookup_kind vn_walk_kind;
+static vn_lookup_kind default_vn_walk_kind;
+
/* vn_nary_op hashtable helpers. */
struct vn_nary_op_hasher : typed_noop_remove <vn_nary_op_s>
@@ -1259,6 +1263,25 @@ vn_reference_maybe_forwprop_address (vec<vn_reference_op_s> *ops,
addr = gimple_assign_rhs1 (def_stmt);
addr_base = get_addr_base_and_unit_offset (TREE_OPERAND (addr, 0),
&addr_offset);
+ /* If that didn't work because the address isn't invariant propagate
+ the reference tree from the address operation in case the current
+ dereference isn't offsetted. */
+ if (!addr_base
+ && *i_p == ops->length () - 1
+ && off == 0
+ /* This makes us disable this transform for PRE where the
+ reference ops might be also used for code insertion which
+ is invalid. */
+ && default_vn_walk_kind == VN_WALKREWRITE)
+ {
+ auto_vec<vn_reference_op_s, 32> tem;
+ copy_reference_ops_from_ref (TREE_OPERAND (addr, 0), &tem);
+ ops->pop ();
+ ops->pop ();
+ ops->safe_splice (tem);
+ --*i_p;
+ return;
+ }
if (!addr_base
|| TREE_CODE (addr_base) != MEM_REF)
return;
@@ -1557,10 +1580,6 @@ vn_reference_lookup_1 (vn_reference_t vr, vn_reference_t *vnresult)
return NULL_TREE;
}
-static tree *last_vuse_ptr;
-static vn_lookup_kind vn_walk_kind;
-static vn_lookup_kind default_vn_walk_kind;
-
/* Callback for walk_non_aliased_vuses. Adjusts the vn_reference_t VR_
with the current VUSE and performs the expression lookup. */
@@ -1649,15 +1668,12 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
/* First try to disambiguate after value-replacing in the definitions LHS. */
if (is_gimple_assign (def_stmt))
{
- vec<vn_reference_op_s> tem;
tree lhs = gimple_assign_lhs (def_stmt);
bool valueized_anything = false;
/* Avoid re-allocation overhead. */
lhs_ops.truncate (0);
copy_reference_ops_from_ref (lhs, &lhs_ops);
- tem = lhs_ops;
lhs_ops = valueize_refs_1 (lhs_ops, &valueized_anything);
- gcc_assert (lhs_ops == tem);
if (valueized_anything)
{
lhs_ref_ok = ao_ref_init_from_vn_reference (&lhs_ref,