aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2009-12-19 11:24:49 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2009-12-19 11:24:49 +0000
commitd0ca0bcb2cc8291e2b4d8135fc623c40768b9642 (patch)
treeb2745fd77ee90ccd6501acc10afa4c7477cba226 /gcc
parenta8572b62e71dc5b453f3390e4e9111b466201fc8 (diff)
downloadgcc-d0ca0bcb2cc8291e2b4d8135fc623c40768b9642.zip
gcc-d0ca0bcb2cc8291e2b4d8135fc623c40768b9642.tar.gz
gcc-d0ca0bcb2cc8291e2b4d8135fc623c40768b9642.tar.bz2
re PR tree-optimization/42108 (50% performance regression)
2009-12-19 Richard Guenther <rguenther@suse.de> PR tree-optimization/42108 * tree-ssa-sccvn.c (last_vuse_ptr): New variable. (vn_reference_lookup_2): Update last seen VUSE. (vn_reference_lookup_3): Avoid updating last seen VUSE after translating. (visit_reference_op_load): Use last seen VUSE from the first lookup when entering into the table. * gfortran.dg/pr42108.f90: New testcase. From-SVN: r155360
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr42108.f9027
-rw-r--r--gcc/tree-ssa-sccvn.c18
4 files changed, 58 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2c21b32..136083c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-19 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/42108
+ * tree-ssa-sccvn.c (last_vuse_ptr): New variable.
+ (vn_reference_lookup_2): Update last seen VUSE.
+ (vn_reference_lookup_3): Avoid updating last seen VUSE after
+ translating.
+ (visit_reference_op_load): Use last seen VUSE from the first
+ lookup when entering into the table.
+
2009-12-19 Joern Rennecke <amylaar@spamcop.net>
* Makefile.in (PLUGIN_HEADERS): Add more headers.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8909ecf..b97694b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-12-19 Richard Guenther <rguenther@suse.de>
+
+ PR tree-optimization/42108
+ * gfortran.dg/pr42108.f90: New testcase.
+
2009-12-18 Jason Merrill <jason@redhat.com>
PR c++/28300
diff --git a/gcc/testsuite/gfortran.dg/pr42108.f90 b/gcc/testsuite/gfortran.dg/pr42108.f90
new file mode 100644
index 0000000..e97dc37
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr42108.f90
@@ -0,0 +1,27 @@
+! { dg-do compile }
+! { dg-options "-O2 -fdump-tree-fre" }
+
+subroutine eval(foo1,foo2,foo3,foo4,x,n,nnd)
+ implicit real*8 (a-h,o-z)
+ dimension foo3(n),foo4(n),x(nnd)
+ nw=0
+ foo3(1)=foo2*foo4(1)
+ do i=2,n
+ foo3(i)=foo2*foo4(i)
+ do j=1,i-1
+ temp=0.0d0
+ jmini=j-i
+ do k=i,nnd,n
+ temp=temp+(x(k)-x(k+jmini))**2
+ end do
+ temp = sqrt(temp+foo1)
+ foo3(i)=foo3(i)+temp*foo4(j)
+ foo3(j)=foo3(j)+temp*foo4(i)
+ end do
+ end do
+end subroutine eval
+
+! There should be only one load from n left
+
+! { dg-final { scan-tree-dump-times "\\*n_" 1 "fre" } }
+! { dg-final { cleanup-tree-dump "fre" } }
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 058da5c9..e914087 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -984,6 +984,8 @@ vn_reference_lookup_1 (vn_reference_t vr, vn_reference_t *vnresult)
return NULL_TREE;
}
+static tree *last_vuse_ptr;
+
/* Callback for walk_non_aliased_vuses. Adjusts the vn_reference_t VR_
with the current VUSE and performs the expression lookup. */
@@ -994,6 +996,9 @@ vn_reference_lookup_2 (ao_ref *op ATTRIBUTE_UNUSED, tree vuse, void *vr_)
void **slot;
hashval_t hash;
+ if (last_vuse_ptr)
+ *last_vuse_ptr = vuse;
+
/* Fixup vuse and hash. */
vr->hashcode = vr->hashcode - iterative_hash_expr (vr->vuse, 0);
vr->vuse = SSA_VAL (vuse);
@@ -1161,6 +1166,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_)
return (void *)-1;
*ref = r;
+ /* Do not update last seen VUSE after translating. */
+ last_vuse_ptr = NULL;
+
/* Keep looking for the adjusted *REF / VR pair. */
return NULL;
}
@@ -1961,7 +1969,13 @@ static bool
visit_reference_op_load (tree lhs, tree op, gimple stmt)
{
bool changed = false;
- tree result = vn_reference_lookup (op, gimple_vuse (stmt), true, NULL);
+ tree last_vuse;
+ tree result;
+
+ last_vuse = gimple_vuse (stmt);
+ last_vuse_ptr = &last_vuse;
+ result = vn_reference_lookup (op, gimple_vuse (stmt), true, NULL);
+ last_vuse_ptr = NULL;
/* If we have a VCE, try looking up its operand as it might be stored in
a different type. */
@@ -2045,7 +2059,7 @@ visit_reference_op_load (tree lhs, tree op, gimple stmt)
else
{
changed = set_ssa_val_to (lhs, lhs);
- vn_reference_insert (op, lhs, gimple_vuse (stmt));
+ vn_reference_insert (op, lhs, last_vuse);
}
return changed;