]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/42108 (50% performance regression)
authorRichard Guenther <rguenther@suse.de>
Sat, 19 Dec 2009 11:24:49 +0000 (11:24 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sat, 19 Dec 2009 11:24:49 +0000 (11:24 +0000)
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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr42108.f90 [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index 2c21b321a4b4266a3ee8cdcd91bafae349a837e9..136083c4f5697e1e9d9dc44d37194f47aa648a32 100644 (file)
@@ -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.
index 8909ecfeffbda4e33bf73bf26904a2cdad12e7f4..b97694b7d25f3b5e7d9105f089cacbe39693cad1 100644 (file)
@@ -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 (file)
index 0000000..e97dc37
--- /dev/null
@@ -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" } }
index 058da5c97a558adef74b40d03c9be8dd6bb168eb..e91408775bb4291f5eaf5d3b119d04e3ce773415 100644 (file)
@@ -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;