This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[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 14:19:31 +0200 (CEST)
- Subject: [PATCH] Remove redundant checking from may_propagate_copy, allow copyprop through (void *) conversion
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.
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.
* gcc.dg/tree-ssa/ssa-copyprop-2.c: New testcase.
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" } } */