From: Richard Guenther Date: Sat, 19 Dec 2009 11:24:49 +0000 (+0000) Subject: re PR tree-optimization/42108 (50% performance regression) X-Git-Tag: releases/gcc-4.5.0~1572 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0ca0bcb2cc8291e2b4d8135fc623c40768b9642;p=thirdparty%2Fgcc.git re PR tree-optimization/42108 (50% performance regression) 2009-12-19 Richard Guenther 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2c21b321a4b4..136083c4f569 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2009-12-19 Richard Guenther + + 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 * Makefile.in (PLUGIN_HEADERS): Add more headers. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8909ecfeffbd..b97694b7d25f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-12-19 Richard Guenther + + PR tree-optimization/42108 + * gfortran.dg/pr42108.f90: New testcase. + 2009-12-18 Jason Merrill PR c++/28300 diff --git a/gcc/testsuite/gfortran.dg/pr42108.f90 b/gcc/testsuite/gfortran.dg/pr42108.f90 new file mode 100644 index 000000000000..e97dc3756f8c --- /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 058da5c97a55..e91408775bb4 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;