OSDN Git Service

2011-01-27 Martin Jambor <mjambor@suse.cz>
authorjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Jan 2011 13:41:51 +0000 (13:41 +0000)
committerjamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 27 Jan 2011 13:41:51 +0000 (13:41 +0000)
PR tree-optimization/47228
* tree-sra.c (sra_modify_assign): Use build_ref_for_model instead of
build_ref_for_offset.

* testsuite/gcc.dg/torture/pr47228.c: New test.

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

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

index 0362a0a..3bee8dd 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-27  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/47228
+       * tree-sra.c (sra_modify_assign): Use build_ref_for_model instead of
+       build_ref_for_offset.
+
 2011-01-27  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
        * config/spu/spu-elf.h (ASM_SPEC): Remove.
index d1b7651..acaa862 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-27  Martin Jambor  <mjambor@suse.cz>
+
+       PR tree-optimization/47228
+       * gcc.dg/torture/pr47228.c: New test.
+
 2011-01-27  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
        * gcc.dg/tree-ssa/pr42585.c: Disable on s390 and s390x.
diff --git a/gcc/testsuite/gcc.dg/torture/pr47228.c b/gcc/testsuite/gcc.dg/torture/pr47228.c
new file mode 100644 (file)
index 0000000..5bc9f0a
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+
+struct S4
+{
+  unsigned f0:24;
+} __attribute__((__packed__));
+
+struct S4 g_10 = {
+  6210831
+};
+
+struct S4 func_2 (int x)
+{
+  struct S4 l_8[2] = {
+    {0}, {0}
+  };
+  g_10 = l_8[1];
+  for (; x<2; x++) {
+    struct S4 tmp = {
+      11936567
+    };
+    l_8[x] = tmp;
+  }
+  return g_10;
+}
+
+int main (void)
+{
+  func_2 (0);
+  return 0;
+}
index 47613f6..82d7601 100644 (file)
@@ -2739,15 +2739,13 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi)
              && !contains_bitfld_comp_ref_p (lhs)
              && !access_has_children_p (lacc))
            {
-             lhs = build_ref_for_offset (loc, lhs, 0, TREE_TYPE (rhs),
-                                         gsi, false);
+             lhs = build_ref_for_model (loc, lhs, 0, racc, gsi, false);
              gimple_assign_set_lhs (*stmt, lhs);
            }
          else if (AGGREGATE_TYPE_P (TREE_TYPE (rhs))
                   && !contains_vce_or_bfcref_p (rhs)
                   && !access_has_children_p (racc))
-           rhs = build_ref_for_offset (loc, rhs, 0, TREE_TYPE (lhs),
-                                       gsi, false);
+           rhs = build_ref_for_model (loc, rhs, 0, lacc, gsi, false);
 
          if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs)))
            {