tree-ssa-structalias.c (push_fields_onto_fieldstack): Avoid pushing again if current...
authorRichard Guenther <rguenther@suse.de>
Wed, 27 Jul 2005 11:15:32 +0000 (11:15 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 27 Jul 2005 11:15:32 +0000 (11:15 +0000)
2005-07-27  Richard Guenther  <rguenther@suse.de>

* tree-ssa-structalias.c (push_fields_onto_fieldstack):
Avoid pushing again if current struct contains only
fields we decomposed.

* gcc.dg/tree-ssa/salias-1.c: New testcase.

From-SVN: r102424

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/salias-1.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index d975412f2345cb35d4aadc5f8f4865a4e0d723c4..a300071a9143c719ff47f7e59d67821cfcf31d3a 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-27  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-structalias.c (push_fields_onto_fieldstack):
+       Avoid pushing again if current struct contains only
+       fields we decomposed.
+
 2005-07-27  Jan Hubicka  <jh@suse.cz>
 
        PR tree-optimization/22574
index 14426f66ac42c18c31ff0d3cf6a04c8372e6c89e..60889ca7a6fdbef79fdf648916f984e25a78f7b4 100644 (file)
@@ -1,3 +1,7 @@
+2005-07-27  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.dg/tree-ssa/salias-1.c: New testcase.
+
 2005-07-27  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR fortran/22503
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/salias-1.c b/gcc/testsuite/gcc.dg/tree-ssa/salias-1.c
new file mode 100644 (file)
index 0000000..9933cc8
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-salias" } */
+
+struct {
+  struct {
+    struct {
+       int i, j;
+    } c;
+  } b;
+} a;
+
+int foo(void)
+{
+  a.b.c.i = 0;
+  return a.b.c.j;
+}
+
+/* { dg-final { scan-tree-dump-times "SFT" 2 "salias" } } */
+/* { dg-final { cleanup-tree-dump "salias" } } */
index 76ce7ab83c054528735cb47a37589b91ccc08e80..b01e9e705502bbab97aebd9a1453410bb1846f63 100644 (file)
@@ -2972,6 +2972,7 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
     if (TREE_CODE (field) == FIELD_DECL)
       {
        bool push = false;
+       int pushed = 0;
        
        if (has_union 
            && (TREE_CODE (TREE_TYPE (field)) == QUAL_UNION_TYPE
@@ -2980,7 +2981,7 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
        
        if (!var_can_have_subvars (field))
          push = true;
-       else if (!(push_fields_onto_fieldstack
+       else if (!(pushed = push_fields_onto_fieldstack
                   (TREE_TYPE (field), fieldstack,
                    offset + bitpos_of_field (field), has_union))
                 && DECL_SIZE (field)
@@ -2999,6 +3000,8 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
            pair->offset = offset + bitpos_of_field (field);
            count++;
          }
+       else
+         count += pushed;
       }
 
   return count;