re PR tree-optimization/14784 ([Tree-ssa] alias analysis deficiency)
authorZdenek Dvorak <dvorakz@suse.cz>
Tue, 24 Oct 2006 00:12:16 +0000 (02:12 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Tue, 24 Oct 2006 00:12:16 +0000 (00:12 +0000)
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
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/alias-10.c [new file with mode: 0644]
gcc/tree-flow.h
gcc/tree-ssa-operands.c
gcc/tree-ssa-structalias.c

index 8e31f4b5e57beddd4605eac37667680299b1a3ac..22f7d0c5e6002a976ad61f8d1203d6e9099acc9a 100644 (file)
@@ -1,3 +1,12 @@
+2006-10-23  Zdenek Dvorak <dvorakz@suse.cz>
+
+       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  <ghazi@caip.rutgers.edu>
 
        PR middle-end/29335
index 0e48cd74144009160e93ecb3dbca7bee7f3e0fc9..1af046debbd240076ef844691e73f27080578f70 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-23  Zdenek Dvorak <dvorakz@suse.cz>
+
+       PR tree-optimization/14784
+       * gcc.dg/alias-10.c: New test.
+
 2006-10-23  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * 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 (file)
index 0000000..6e9cb3f
--- /dev/null
@@ -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" } } */
index 447b7328ffd32d2a2ed16e7076261b251b3a0438..ff1006f339c8a3049b2f23db740aabedbf4cfa77 100644 (file)
@@ -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
index 4fa876de39c9e6d3e399f5d31a4a33618f100631..234eace9b4c2e1c4c2be729c8535ef25697b2609 100644 (file)
@@ -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))
index 1c4a46e75ee846f12e611039dd49bd6d5d6d13f0..98ab99b4c927b9343eb09bcd3c1555195e1134d3 100644 (file)
@@ -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);