+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.
+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
--- /dev/null
+! { 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" } }
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. */
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);
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;
}
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. */
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;