diff options
author | Richard Guenther <rguenther@suse.de> | 2011-08-11 15:34:46 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-08-11 15:34:46 +0000 |
commit | 25aa059e63fe5b759e18fdcb7cac4b51868a44d0 (patch) | |
tree | 3a96213939be6830b497510e57e5946effbabfec /gcc | |
parent | 3627ac1ad60986ccd4b6682ebc69d1be4bcb3d16 (diff) | |
download | gcc-25aa059e63fe5b759e18fdcb7cac4b51868a44d0.zip gcc-25aa059e63fe5b759e18fdcb7cac4b51868a44d0.tar.gz gcc-25aa059e63fe5b759e18fdcb7cac4b51868a44d0.tar.bz2 |
tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid redundant lookups, make looking through aggregate copies stronger.
2011-08-11 Richard Guenther <rguenther@suse.de>
* tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid redundant
lookups, make looking through aggregate copies stronger.
* g++.dg/tree-ssa/pr41186.C: Un-XFAIL.
From-SVN: r177672
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/tree-ssa/pr41186.C | 6 | ||||
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 36 |
4 files changed, 42 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e7ed90d..c2c62bc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-08-11 Richard Guenther <rguenther@suse.de> + + * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid redundant + lookups, make looking through aggregate copies stronger. + 2011-08-11 Richard Henderson <rth@redhat.com> PR bootstrap/50018 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d515387..8c1dcfd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-08-11 Richard Guenther <rguenther@suse.de> + + * g++.dg/tree-ssa/pr41186.C: Un-XFAIL. + 2011-08-11 Michael Matz <matz@suse.de> * gcc.dg/graphite/run-id-pr47593.c: Remove -m32. diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr41186.C b/gcc/testsuite/g++.dg/tree-ssa/pr41186.C index 8739ae9..cc685b2 100644 --- a/gcc/testsuite/g++.dg/tree-ssa/pr41186.C +++ b/gcc/testsuite/g++.dg/tree-ssa/pr41186.C @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O -fdump-tree-fre1-details" } */ +/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1-details" } */ struct Foo { Foo() {}; @@ -30,6 +30,6 @@ int main() } /* { dg-final { scan-tree-dump "Replaced b1.b with 1" "fre1" } } */ -/* { dg-final { scan-tree-dump "Replaced b1.i with 0" "fre1" { xfail *-*-* } } } */ -/* { dg-final { scan-tree-dump "Replaced b1.f with 1" "fre1" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "Replaced b1.D.\[0-9\]*.i with 0" "fre1" } } */ +/* { dg-final { scan-tree-dump "Replaced b1.D.\[0-9\]*.f with 1" "fre1" } } */ /* { dg-final { cleanup-tree-dump "fre1" } } */ diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 7cf6123..d65b9eb 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -1351,17 +1351,27 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) { VEC (vn_reference_op_s, heap) *tem; tree lhs = gimple_assign_lhs (def_stmt); + bool valueized_anything = false; /* Avoid re-allocation overhead. */ VEC_truncate (vn_reference_op_s, lhs_ops, 0); copy_reference_ops_from_ref (lhs, &lhs_ops); tem = lhs_ops; - lhs_ops = valueize_refs (lhs_ops); + lhs_ops = valueize_refs_1 (lhs_ops, &valueized_anything); gcc_assert (lhs_ops == tem); - lhs_ref_ok = ao_ref_init_from_vn_reference (&lhs_ref, get_alias_set (lhs), - TREE_TYPE (lhs), lhs_ops); - if (lhs_ref_ok - && !refs_may_alias_p_1 (ref, &lhs_ref, true)) - return NULL; + if (valueized_anything) + { + lhs_ref_ok = ao_ref_init_from_vn_reference (&lhs_ref, + get_alias_set (lhs), + TREE_TYPE (lhs), lhs_ops); + if (lhs_ref_ok + && !refs_may_alias_p_1 (ref, &lhs_ref, true)) + return NULL; + } + else + { + ao_ref_init (&lhs_ref, lhs); + lhs_ref_ok = true; + } } base = ao_ref_base (ref); @@ -1469,6 +1479,20 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_) j--; } + /* ??? The innermost op should always be a MEM_REF and we already + checked that the assignment to the lhs kills vr. Thus for + aggregate copies using char[] types the vn_reference_op_eq + may fail when comparing types for compatibility. But we really + don't care here - further lookups with the rewritten operands + will simply fail if we messed up types too badly. */ + if (j == 0 && i == 0 + && VEC_index (vn_reference_op_s, lhs_ops, 0)->opcode == MEM_REF + && VEC_index (vn_reference_op_s, vr->operands, i)->opcode == MEM_REF + && tree_int_cst_equal + (VEC_index (vn_reference_op_s, lhs_ops, 0)->op0, + VEC_index (vn_reference_op_s, vr->operands, i)->op0)) + i--, j--; + /* i now points to the first additional op. ??? LHS may not be completely contained in VR, one or more VIEW_CONVERT_EXPRs could be in its way. We could at least |