]> gcc.gnu.org Git - gcc.git/commitdiff
re PR middle-end/28045 (Bitfield, &&, and optimization => bad code generation)
authorRichard Guenther <rguenther@suse.de>
Mon, 19 Jun 2006 14:48:47 +0000 (14:48 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 19 Jun 2006 14:48:47 +0000 (14:48 +0000)
2006-06-19  Richard Guenther  <rguenther@suse.de>

PR middle-end/28045
* fold-const.c (operand_equal_p): Check if the argument types
have the same precision before stripping NOPs.

* gcc.dg/torture/pr28045.c: New testcase.

From-SVN: r114772

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr28045.c [new file with mode: 0644]

index 34b7da6cbbe30162739c3ea8683453098a599440..be202bf61d0806474c556b621ddbd5ec2efd922b 100644 (file)
@@ -1,3 +1,9 @@
+2006-06-19  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/28045
+       * fold-const.c (operand_equal_p): Check if the argument types
+       have the same precision before stripping NOPs.
+
 2006-06-19  Daniel Berlin  <dberlin@dberlin.org>
 
        Fix PR tree-optimization/27341
index 57a72489121af0c6d509c231ad3a720c0e337f6f..5a65586794e0c130dc6278649f2a874e5e1a2026 100644 (file)
@@ -2497,6 +2497,11 @@ operand_equal_p (tree arg0, tree arg1, unsigned int flags)
   if (TYPE_UNSIGNED (TREE_TYPE (arg0)) != TYPE_UNSIGNED (TREE_TYPE (arg1)))
     return 0;
 
+  /* If both types don't have the same precision, then it is not safe
+     to strip NOPs.  */
+  if (TYPE_PRECISION (TREE_TYPE (arg0)) != TYPE_PRECISION (TREE_TYPE (arg1)))
+    return 0;
+
   STRIP_NOPS (arg0);
   STRIP_NOPS (arg1);
 
index 985d645556736feab87fd78955fa9f2f316c29e5..ba44e8fb2ac8a6d89b9f82294b03832794392bca 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-19  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/28045
+       * gcc.dg/torture/pr28045.c: New testcase.
+
 2006-06-18  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
        PR fortran/26801
diff --git a/gcc/testsuite/gcc.dg/torture/pr28045.c b/gcc/testsuite/gcc.dg/torture/pr28045.c
new file mode 100644 (file)
index 0000000..f2d1664
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+
+extern void abort(void);
+struct a
+{
+   unsigned int bits : 1;
+   signed long val : ((sizeof(long) * 8) - 1);
+};
+int Fnegate (struct a b)
+{
+  if ((-((long)b.val)) <= ((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))
+      && (-((long)b.val)) >= (-(((long) ((1UL << ((sizeof(long) * 8) - 2)) -1UL))) - 1))
+     return 0 ;
+  abort ();
+}
+int main ()
+{
+  struct a b = {1, 1};
+  Fnegate (b);
+  return 0;
+}
+
This page took 0.132715 seconds and 5 git commands to generate.