From ae5360407bc31e22ac1c79c7a20ef1e225377203 Mon Sep 17 00:00:00 2001 From: Zdenek Dvorak Date: Tue, 24 Oct 2006 02:12:16 +0200 Subject: [PATCH] re PR tree-optimization/14784 ([Tree-ssa] alias analysis deficiency) PR tree-optimization/14784 * tree-flow.h (struct var_ann_d): Add is_heapvar bit. * tree-ssa-structalias.c (get_constraint_for, intra_create_variable_infos): Set is_heapvar. * tree-ssa-operands.c (access_can_touch_variable): Do not handle non-heapvar pointer variables specially. * gcc.dg/alias-10.c: New test. From-SVN: r117986 --- gcc/ChangeLog | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/alias-10.c | 32 ++++++++++++++++++++++++++++++++ gcc/tree-flow.h | 3 +++ gcc/tree-ssa-operands.c | 2 +- gcc/tree-ssa-structalias.c | 2 ++ 6 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/alias-10.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8e31f4b5e57..22f7d0c5e60 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2006-10-23 Zdenek Dvorak + + PR tree-optimization/14784 + * tree-flow.h (struct var_ann_d): Add is_heapvar bit. + * tree-ssa-structalias.c (get_constraint_for, + intra_create_variable_infos): Set is_heapvar. + * tree-ssa-operands.c (access_can_touch_variable): Do not handle + non-heapvar pointer variables specially. + 2006-10-23 Kaveh R. Ghazi PR middle-end/29335 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0e48cd74144..1af046debbd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-10-23 Zdenek Dvorak + + PR tree-optimization/14784 + * gcc.dg/alias-10.c: New test. + 2006-10-23 Kaveh R. Ghazi * gcc.dg/torture/builtin-sin-mpfr-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/alias-10.c b/gcc/testsuite/gcc.dg/alias-10.c new file mode 100644 index 00000000000..6e9cb3f3c42 --- /dev/null +++ b/gcc/testsuite/gcc.dg/alias-10.c @@ -0,0 +1,32 @@ +/* For PR tree-optimization/14784 */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */ + +typedef struct bitmap_element_def +{ + unsigned int indx; +} bitmap_element; + +typedef struct bitmap_head_def { + bitmap_element *first; + int using_obstack; +} bitmap_head; +typedef struct bitmap_head_def *bitmap; + +bitmap_element *bitmap_free; + +void foo (bitmap head, bitmap_element *elt) +{ + while (1) + { + /* Alias analysis problems used to prevent us from recognizing + that this condition is invariant. */ + if (head->using_obstack) + bitmap_free = elt; + } +} + + +/* { dg-final { scan-tree-dump-times "Unswitching" 1 "unswitch"} } */ +/* { dg-final { cleanup-tree-dump "unswitch" } } */ diff --git a/gcc/tree-flow.h b/gcc/tree-flow.h index 447b7328ffd..ff1006f339c 100644 --- a/gcc/tree-flow.h +++ b/gcc/tree-flow.h @@ -184,6 +184,9 @@ struct var_ann_d GTY(()) in the v_may_def list. */ unsigned in_v_may_def_list : 1; + /* True for HEAP and PARM_NOALIAS artificial variables. */ + unsigned is_heapvar : 1; + /* An artificial variable representing the memory location pointed-to by all the pointer symbols that flow-insensitive alias analysis (mostly type-based) considers to be aliased. If the variable is diff --git a/gcc/tree-ssa-operands.c b/gcc/tree-ssa-operands.c index 4fa876de39c..234eace9b4c 100644 --- a/gcc/tree-ssa-operands.c +++ b/gcc/tree-ssa-operands.c @@ -1151,11 +1151,11 @@ access_can_touch_variable (tree ref, tree alias, HOST_WIDE_INT offset, && flag_strict_aliasing && TREE_CODE (ref) != INDIRECT_REF && !MTAG_P (alias) + && !var_ann (alias)->is_heapvar && (TREE_CODE (base) != INDIRECT_REF || TREE_CODE (TREE_TYPE (base)) != UNION_TYPE) && !AGGREGATE_TYPE_P (TREE_TYPE (alias)) && TREE_CODE (TREE_TYPE (alias)) != COMPLEX_TYPE - && !POINTER_TYPE_P (TREE_TYPE (alias)) /* When the struct has may_alias attached to it, we need not to return true. */ && get_alias_set (base)) diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 1c4a46e75ee..98ab99b4c92 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -2640,6 +2640,7 @@ get_constraint_for (tree t, VEC (ce_s, heap) **results) { heapvar = create_tmp_var_raw (ptr_type_node, "HEAP"); DECL_EXTERNAL (heapvar) = 1; + get_var_ann (heapvar)->is_heapvar = 1; if (referenced_vars) add_referenced_var (heapvar); heapvar_insert (t, heapvar); @@ -4281,6 +4282,7 @@ intra_create_variable_infos (void) { heapvar = create_tmp_var_raw (TREE_TYPE (TREE_TYPE (t)), "PARM_NOALIAS"); + get_var_ann (heapvar)->is_heapvar = 1; DECL_EXTERNAL (heapvar) = 1; if (referenced_vars) add_referenced_var (heapvar); -- 2.30.2