2009-06-30 Martin Jambor <mjambor@suse.cz>
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Jun 2009 10:10:29 +0000 (10:10 +0000)
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 30 Jun 2009 10:10:29 +0000 (10:10 +0000)
PR tree-optimization/40582
* tree-sra.c (build_ref_for_offset_1): Use types_compatible_p rather
than useless_type_conversion_p.
(generate_subtree_copies): Increment sra_stats.subtree_copies at a
proper place.

* testsuite/gcc.c-torture/compile/pr40582.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149088 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr40582.c [new file with mode: 0644]
gcc/tree-sra.c

index 554de52..79637f0 100644 (file)
@@ -1,5 +1,13 @@
 2009-06-30  Martin Jambor  <mjambor@suse.cz>
 
+       PR tree-optimization/40582
+       * tree-sra.c (build_ref_for_offset_1): Use types_compatible_p rather
+       than useless_type_conversion_p.
+       (generate_subtree_copies): Increment sra_stats.subtree_copies at a
+       proper place.
+
+2009-06-30  Martin Jambor  <mjambor@suse.cz>
+
        PR middle-end/40554
        * tree-sra.c (sra_modify_expr): Add access->offset to start_offset.
 
index 42456c8..49ca9c1 100644 (file)
@@ -1,3 +1,8 @@
+2009-06-30  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/40582
+       * gcc.c-torture/compile/pr40582.c: New test.
+
 2009-06-30  Wei Guozhi  <carrot@google.com>
 
        PR/40416
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr40582.c b/gcc/testsuite/gcc.c-torture/compile/pr40582.c
new file mode 100644 (file)
index 0000000..51234da
--- /dev/null
@@ -0,0 +1,18 @@
+struct A
+{
+  void* q;
+  short i;
+};
+
+union U
+{
+  char* p;
+  struct A a;
+};
+
+struct A foo(union U u)
+{
+  struct A a = { 0, 0 };
+  a = u.a;
+  return a;
+}
index 4529754..2381ac3 100644 (file)
@@ -1036,7 +1036,7 @@ build_ref_for_offset_1 (tree *res, tree type, HOST_WIDE_INT offset,
       HOST_WIDE_INT el_size;
 
       if (offset == 0 && exp_type
-         && useless_type_conversion_p (exp_type, type))
+         && types_compatible_p (exp_type, type))
        return true;
 
       switch (TREE_CODE (type))
@@ -1760,7 +1760,6 @@ generate_subtree_copies (struct access *access, tree agg,
                                                 insert_after ? GSI_NEW_STMT
                                                 : GSI_SAME_STMT);
              stmt = gimple_build_assign (expr, repl);
-             sra_stats.subtree_copies++;
            }
 
          if (insert_after)
@@ -1768,6 +1767,7 @@ generate_subtree_copies (struct access *access, tree agg,
          else
            gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
          update_stmt (stmt);
+         sra_stats.subtree_copies++;
        }
 
       if (access->first_child)