This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR44656, value-replace for disambiugation during VN
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 4 Jul 2010 12:48:27 +0200 (CEST)
- Subject: [PATCH] Fix PR44656, value-replace for disambiugation during VN
This makes sure we value-replace references we try to disambiguate
against. The easiest place is to do in the translation hook when
we failed to disambiguate against the reference as it is in the IL.
gcc.dg/tree-ssa/loadpre6.c which I XFAILed during the mem-ref2
merge shows how we can leverage more PTA (and not rely on false
TBAA as we do for 4.5 and previous releases).
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2010-07-04 Richard Guenther <rguenther@suse.de>
PR tree-optimization/44656
* tree-ssa-sccvn.c (vn_reference_lookup_3): Try disambiguation
again after value-replacing in the defintions lhs.
* gcc.dg/tree-ssa/loadpre6.c: Remove XFAIL.
Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c (revision 161718)
--- gcc/tree-ssa-sccvn.c (working copy)
*************** vn_reference_lookup_3 (ao_ref *ref, tree
*** 1212,1217 ****
--- 1212,1234 ----
tree base;
HOST_WIDE_INT offset, maxsize;
+ /* First try to disambiguate after value-replacing in the definitions LHS. */
+ if (is_gimple_assign (def_stmt))
+ {
+ tree lhs = gimple_assign_lhs (def_stmt);
+ ao_ref ref1;
+ VEC (vn_reference_op_s, heap) *operands = NULL;
+ bool res;
+ copy_reference_ops_from_ref (lhs, &operands);
+ operands = valueize_refs (operands);
+ ao_ref_init_from_vn_reference (&ref1, get_alias_set (lhs),
+ TREE_TYPE (lhs), operands);
+ res = refs_may_alias_p_1 (ref, &ref1, true);
+ VEC_free (vn_reference_op_s, heap, operands);
+ if (!res)
+ return NULL;
+ }
+
base = ao_ref_base (ref);
offset = ref->offset;
maxsize = ref->max_size;
Index: gcc/testsuite/gcc.dg/tree-ssa/loadpre6.c
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/loadpre6.c (revision 161718)
--- gcc/testsuite/gcc.dg/tree-ssa/loadpre6.c (working copy)
*************** main (void)
*** 73,80 ****
return 0;
}
! /* See PR44656. The last elimination is only done by PRE. */
! /* { dg-final { scan-tree-dump-not "= unexpanded_var_list;" "fre" { xfail *-*-* } } } */
! /* { dg-final { scan-tree-dump-times "Eliminated: 1" 2 "pre" } } */
/* { dg-final { scan-tree-dump-times "Insertions: 2" 1 "pre" } } */
/* { dg-final { cleanup-tree-dump "pre" } } */
--- 73,79 ----
return 0;
}
! /* { dg-final { scan-tree-dump-not "= unexpanded_var_list;" "fre" } } */
! /* { dg-final { scan-tree-dump-times "Eliminated: 1" 1 "pre" } } */
/* { dg-final { scan-tree-dump-times "Insertions: 2" 1 "pre" } } */
/* { dg-final { cleanup-tree-dump "pre" } } */