]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/58570 (wrong code for bitfields at -O2 and above)
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 9 Oct 2013 12:59:02 +0000 (12:59 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 9 Oct 2013 12:59:02 +0000 (12:59 +0000)
PR middle-end/58570
* tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): Return
false if both components are bitfields.

From-SVN: r203315

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr58570.c [new file with mode: 0644]
gcc/tree-ssa-alias.c

index d04904c440825c0219458be31e77e4f63b9fbbd1..f78642ae0adb2dc8eb7ba3fd07b6e895cb1969a3 100644 (file)
@@ -1,3 +1,9 @@
+2013-10-09  Eric Botcazou  <ebotcazou@adacore.com>
+
+       PR middle-end/58570
+       * tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p): Return
+       false if both components are bitfields.
+
 2013-10-09  Alex Velenko  <Alex.Velenko@arm.com>
 
        * config/aarch64/arm_neon.h (vclz_s8, vclz_s16, vclz_s32)
index 0ece8c0651077204084ff7513d5236d45fd03564..4de71eb0f71701e20192ae7059e4fcbe1c247c2a 100644 (file)
@@ -1,3 +1,7 @@
+2013-10-09  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.c-torture/execute/pr58570.c: New test.
+
 2013-10-09  Alex Velenko  <Alex.Velenko@arm.com>
 
        * gcc.target/aarch64/vclz.c: New testcase.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58570.c b/gcc/testsuite/gcc.c-torture/execute/pr58570.c
new file mode 100644 (file)
index 0000000..6d5116d
--- /dev/null
@@ -0,0 +1,22 @@
+#pragma pack(1)
+struct S
+{
+  int f0:15;
+  int f1:29;
+};
+
+int e = 1, i;
+static struct S d[6];
+
+int
+main (void)
+{
+  if (e)
+    {
+      d[i].f0 = 1;
+      d[i].f1 = 1;
+    }
+  if (d[0].f1 != 1)
+    __builtin_abort ();
+  return 0;
+}
index 0d3c15c447d3a040751a080c3f23f9af42a6cd13..4aaa98b11ae97faf29723dc2ad2d452aa2104f68 100644 (file)
@@ -803,12 +803,13 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2)
       if (type1 != type2 || TREE_CODE (type1) != RECORD_TYPE)
         goto may_overlap;
 
-      /* Different fields of the same record type cannot overlap.  */
+      /* Different fields of the same record type cannot overlap.
+        ??? Bitfields can overlap at RTL level so punt on them.  */
       if (field1 != field2)
        {
          component_refs1.release ();
          component_refs2.release ();
-         return true;
+         return !(DECL_BIT_FIELD (field1) && DECL_BIT_FIELD (field2));
        }
     }