This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Remove redundant checking from may_propagate_copy, allow copyprop through (void *) conversion
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 4 Sep 2007 16:51:42 +0200 (CEST)
- Subject: Re: [PATCH] Remove redundant checking from may_propagate_copy, allow copyprop through (void *) conversion
- References: <Pine.LNX.4.64.0709041415400.4343@s68.fhfr.qr>
On Tue, 4 Sep 2007, Richard Guenther wrote:
>
> This removes redundant checking done by may_propagate_copy. First it
> calls useless_type_conversion_p twice, second it does compare alias set
> numbers which useless_type_conversion_p does as well. As
> useless_type_conversion_p special-cases conversions to (void *) this
> enables us to copypropagate in the testcase added.
>
> Bootstrapping and testing on x86_64-unknown-linux-gnu in progress.
And the following actually passed bootstrapping and testing. I'll
install after the usual wait-for-comments. The new testcase would
ICE in the assert in get_smt_for if we didn't specialize VOID_TYPE
there (I tried to avoid generating a SMT for void, but that was too
tricky).
Richard.
2007-08-04 Richard Guenther <rguenther@suse.de>
* tree-ssa-copy.c (may_propagate_copy): Remove redundant
call to useless_type_conversion_p and alias set comparison.
(merge_alias_info): Remove redundant alias set comparison.
* tree-ssa-alias.c (get_smt_for): Ignore differing alias sets
if one is for VOID.
* gcc.dg/tree-ssa/ssa-copyprop-2.c: New testcase.
* gcc.c-torture/compile/20070904-1.c: Likewise.
Index: tree-ssa-copy.c
===================================================================
*** tree-ssa-copy.c (revision 128067)
--- tree-ssa-copy.c (working copy)
*************** may_propagate_copy (tree dest, tree orig
*** 129,139 ****
tree mt_orig = symbol_mem_tag (SSA_NAME_VAR (orig));
if (mt_dest && mt_orig && mt_dest != mt_orig)
return false;
- else if (!useless_type_conversion_p (type_d, type_o))
- return false;
- else if (get_alias_set (TREE_TYPE (type_d)) !=
- get_alias_set (TREE_TYPE (type_o)))
- return false;
/* Also verify flow-sensitive information is compatible. */
if (SSA_NAME_PTR_INFO (orig) && SSA_NAME_PTR_INFO (dest))
--- 129,134 ----
*************** merge_alias_info (tree orig_name, tree n
*** 223,234 ****
#if defined ENABLE_CHECKING
gcc_assert (useless_type_conversion_p (TREE_TYPE (orig_name),
TREE_TYPE (new_name)));
-
- /* If the pointed-to alias sets are different, these two pointers
- would never have the same memory tag. In this case, NEW should
- not have been propagated into ORIG. */
- gcc_assert (get_alias_set (TREE_TYPE (TREE_TYPE (new_sym)))
- == get_alias_set (TREE_TYPE (TREE_TYPE (orig_sym))));
#endif
/* Synchronize the symbol tags. If both pointers had a tag and they
--- 218,223 ----
Index: testsuite/gcc.dg/tree-ssa/ssa-copyprop-2.c
===================================================================
*** testsuite/gcc.dg/tree-ssa/ssa-copyprop-2.c (revision 0)
--- testsuite/gcc.dg/tree-ssa/ssa-copyprop-2.c (revision 0)
***************
*** 0 ****
--- 1,21 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O -fdump-tree-copyprop1" } */
+
+ struct Foo;
+
+ void bar(struct Foo *);
+
+ void foo(void)
+ {
+ int i[2];
+ char *p1;
+ void *p2;
+ struct Foo *p3;
+ p1 = (char *)&i;
+ p2 = p1;
+ p3 = p2;
+ bar (p3);
+ }
+
+ /* { dg-final { scan-tree-dump "\\(struct Foo \\*\\) p1" "copyprop1" } } */
+ /* { dg-final { cleanup-tree-dump "copyprop1" } } */
Index: testsuite/gcc.c-torture/compile/20070904-1.c
===================================================================
*** testsuite/gcc.c-torture/compile/20070904-1.c (revision 0)
--- testsuite/gcc.c-torture/compile/20070904-1.c (revision 0)
***************
*** 0 ****
--- 1,11 ----
+ static struct typeinfo *typevec;
+ void ggc_set_mark (struct typeinfo*);
+ void gt_ggc_ma_typevec (void)
+ {
+ if (typevec != ((void *)0))
+ {
+ void *a__ = typevec;
+ ggc_set_mark (a__);
+ }
+ }
+
Index: tree-ssa-alias.c
===================================================================
*** tree-ssa-alias.c (revision 128067)
--- tree-ssa-alias.c (working copy)
*************** get_smt_for (tree ptr, struct alias_info
*** 3117,3123 ****
/* Make sure that the symbol tag has the same alias set as the
pointed-to type. */
! gcc_assert (tag_set == get_alias_set (tag));
return tag;
}
--- 3117,3124 ----
/* Make sure that the symbol tag has the same alias set as the
pointed-to type. */
! gcc_assert (VOID_TYPE_P (TREE_TYPE (tag))
! || tag_set == get_alias_set (tag));
return tag;
}