]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/45144 (SRA optimization issue of bit-field)
authorJie Zhang <jie@codesourcery.com>
Thu, 5 Aug 2010 03:05:35 +0000 (03:05 +0000)
committerJie Zhang <jiez@gcc.gnu.org>
Thu, 5 Aug 2010 03:05:35 +0000 (03:05 +0000)
PR tree-optimization/45144
* tree-sra.c (type_consists_of_records_p): Return false
if the record contains bit-field.

testsuite/
PR tree-optimization/45144
* gcc.dg/tree-ssa/pr45144.c: New test.

From-SVN: r162897

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

index a954245ccb7d1fff6133ed621f8667247a60ae5b..e014b3e43a7eda69eb154b5c1d7e6474ff0315e4 100644 (file)
@@ -1,3 +1,9 @@
+2010-08-05  Jie Zhang  <jie@codesourcery.com>
+
+       PR tree-optimization/45144
+       * tree-sra.c (type_consists_of_records_p): Return false
+       if the record contains bit-field.
+
 2010-08-04  Richard Henderson  <rth@redhat.com>
 
        * config/i386/i386.c (struct ix86_frame): Remove padding and
index 8f38f78d3c98c590eadc793b8f0ea456da88f8a5..6c37a88dd06476ec102e7a60d1ce061262644dba 100644 (file)
@@ -1,3 +1,8 @@
+2010-08-05  Jie Zhang  <jie@codesourcery.com>
+
+       PR tree-optimization/45144
+       * gcc.dg/tree-ssa/pr45144.c: New test.
+
 2010-08-04  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/42207
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr45144.c b/gcc/testsuite/gcc.dg/tree-ssa/pr45144.c
new file mode 100644 (file)
index 0000000..47530ce
--- /dev/null
@@ -0,0 +1,46 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+void baz (unsigned);
+
+extern unsigned buf[];
+
+struct A
+{
+  unsigned a1:10;
+  unsigned a2:3;
+  unsigned:19;
+};
+
+union TMP
+{
+  struct A a;
+  unsigned int b;
+};
+
+static unsigned
+foo (struct A *p)
+{
+  union TMP t;
+  struct A x;
+  
+  x = *p;
+  t.a = x;
+  return t.b;
+}
+
+void
+bar (unsigned orig, unsigned *new)
+{
+  struct A a;
+  union TMP s;
+
+  s.b = orig;
+  a = s.a;
+  if (a.a1)
+    baz (a.a2);
+  *new = foo (&a);
+}
+
+/* { dg-final { scan-tree-dump "x = a;" "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
index 372139f59494223b0cfd7f86b80aeba94cdafe8d..d32bbebc0f2d7503726183fd8cc1fbb0d0758e9f 100644 (file)
@@ -811,7 +811,7 @@ create_access (tree expr, gimple stmt, bool write)
 /* Return true iff TYPE is a RECORD_TYPE with fields that are either of gimple
    register types or (recursively) records with only these two kinds of fields.
    It also returns false if any of these records has a zero-size field as its
-   last field.  */
+   last field or has a bit-field.  */
 
 static bool
 type_consists_of_records_p (tree type)
@@ -827,6 +827,9 @@ type_consists_of_records_p (tree type)
       {
        tree ft = TREE_TYPE (fld);
 
+       if (DECL_BIT_FIELD (fld))
+         return false;
+
        if (!is_gimple_reg_type (ft)
            && !type_consists_of_records_p (ft))
          return false;