]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/45017 (miscompile with bitfield and optimization)
authorRichard Guenther <rguenther@suse.de>
Thu, 22 Jul 2010 12:14:27 +0000 (12:14 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 22 Jul 2010 12:14:27 +0000 (12:14 +0000)
2010-07-22  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/45017
* tree-ssa-sccvn.c (vn_reference_eq): Make sure we honor
TYPE_PRECISION of integral types in addition to size.

* gcc.c-torture/execute/pr45017.c: New testcase.

From-SVN: r162411

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

index a8b3af38cd5ca1e4bd33d73af3e79f55629b5023..b9725dce3073783e23d4663a5ca06e350e22e3bd 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-22  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/45017
+       * tree-ssa-sccvn.c (vn_reference_eq): Make sure we honor
+       TYPE_PRECISION of integral types in addition to size.
+
 2010-07-22  Maxim Kuvyrkov  <maxim@codesourcery.com>
 
        * config/rs6000/sysv4.h (CHOOSE_DYNAMIC_LINKER): Default to GLIBC
index 7a454a94706499929f86ae8b6eb61647f1ce7d45..35ae9948cfb1a7efe75e67e9d1f75d91a3bec3e9 100644 (file)
@@ -1,3 +1,8 @@
+2010-07-22  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/45017
+       * gcc.c-torture/execute/pr45017.c: New testcase.
+
 2010-07-22  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/45019
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr45017.c b/gcc/testsuite/gcc.c-torture/execute/pr45017.c
new file mode 100644 (file)
index 0000000..37ff286
--- /dev/null
@@ -0,0 +1,22 @@
+int tester(char *bytes)
+{
+  union {
+      struct {
+         unsigned int r1:4;
+         unsigned int r2:4;
+      } fmt;
+      char value[1];
+  } ovl;
+
+  ovl.value[0] = bytes[0];
+  return ovl.fmt.r1;
+}
+extern void abort (void);
+int main()
+{
+  char buff = 0x2f;
+  if (tester(&buff) != 0x0f)
+    abort ();
+  return 0;
+}
+
index 8eafd9b9821829a35640f4b25fa6dd538392bd3f..c99c8a8f3719bc945e3ea8bc62f53c66207f0dae 100644 (file)
@@ -498,6 +498,21 @@ vn_reference_eq (const void *p1, const void *p2)
   if (!expressions_equal_p (TYPE_SIZE (vr1->type), TYPE_SIZE (vr2->type)))
     return false;
 
+  if (INTEGRAL_TYPE_P (vr1->type)
+      && INTEGRAL_TYPE_P (vr2->type))
+    {
+      if (TYPE_PRECISION (vr1->type) != TYPE_PRECISION (vr2->type))
+       return false;
+    }
+  else if (INTEGRAL_TYPE_P (vr1->type)
+          && (TYPE_PRECISION (vr1->type)
+              != TREE_INT_CST_LOW (TYPE_SIZE (vr1->type))))
+    return false;
+  else if (INTEGRAL_TYPE_P (vr2->type)
+          && (TYPE_PRECISION (vr2->type)
+              != TREE_INT_CST_LOW (TYPE_SIZE (vr2->type))))
+    return false;
+
   i = 0;
   j = 0;
   do