This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFC] Enable saliasing for structs with arrays
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Cc: dvorakz at suse dot cz
- Date: Tue, 19 Jul 2005 11:10:32 +0200 (CEST)
- Subject: [RFC] Enable saliasing for structs with arrays
This simple patch enables structure aliasing for structs containing
arrays (_not_ enabling subvars for the arrays). Unfortunately, the
patch breaks bootstrap due to IVOPTs and friends. This is sad, as
it may even help for better alias analysis for GCCs tree structure.
Maybe some IVOPTs folks can help out here.
Richard.
2005-07-19 Richard Guenther <rguenther@suse.de>
PR tree-optimization/22555
* tree-ssa-alias.c (create_overlap_variables_for): Do not
give up, if one structure field is an array.
* tree-ssa-structalias.c (create_variable_info_for): Likewise.
* gcc.dg/tree-ssa/alias-3.c: New testcase.
Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.104
diff -c -3 -p -r2.104 tree-ssa-alias.c
*** tree-ssa-alias.c 16 Jul 2005 18:56:52 -0000 2.104
--- tree-ssa-alias.c 19 Jul 2005 09:00:54 -0000
*************** create_overlap_variables_for (tree var)
*** 2532,2538 ****
{
if (!DECL_SIZE (fo->field)
|| TREE_CODE (DECL_SIZE (fo->field)) != INTEGER_CST
- || TREE_CODE (TREE_TYPE (fo->field)) == ARRAY_TYPE
|| fo->offset < 0)
{
notokay = true;
--- 2532,2537 ----
Index: tree-ssa-structalias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-structalias.c,v
retrieving revision 2.21
diff -c -3 -p -r2.21 tree-ssa-structalias.c
*** tree-ssa-structalias.c 16 Jul 2005 22:27:21 -0000 2.21
--- tree-ssa-structalias.c 19 Jul 2005 09:00:54 -0000
*************** create_variable_info_for (tree decl, con
*** 3017,3023 ****
vi->has_union = hasunion;
if (!TYPE_SIZE (decltype)
|| TREE_CODE (TYPE_SIZE (decltype)) != INTEGER_CST
- || TREE_CODE (decltype) == ARRAY_TYPE
|| TREE_CODE (decltype) == UNION_TYPE
|| TREE_CODE (decltype) == QUAL_UNION_TYPE)
{
--- 3017,3022 ----
*************** create_variable_info_for (tree decl, con
*** 3051,3057 ****
{
if (!DECL_SIZE (fo->field)
|| TREE_CODE (DECL_SIZE (fo->field)) != INTEGER_CST
- || TREE_CODE (TREE_TYPE (fo->field)) == ARRAY_TYPE
|| fo->offset < 0)
{
notokay = true;
--- 3050,3055 ----
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vars" } */
struct {
int i;
int j;
int x[2];
} a;
int foo(void)
{
a.i = 1;
a.j = 0;
a.x[0] = 0;
return a.i + a.j;
}
/* { dg-final { scan-tree-dump "return 1;" "vars" } } */
/* { dg-final { cleanup-tree-dump "vars" } } */