]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/28045 (Bitfield, &&, and optimization => bad code generation)
authorRichard Guenther <rguenther@suse.de>
Fri, 23 Jun 2006 09:57:37 +0000 (09:57 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 23 Jun 2006 09:57:37 +0000 (09:57 +0000)
2006-06-23  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: r114930

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

index 214b661319717e8acc4b9c4941dba0e8efe6424e..28e9af85031d7646a2a2a766e9867250f344e72d 100644 (file)
@@ -1,3 +1,9 @@
+2006-06-23  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-22  Gerald Pfeifer  <gerald@pfeifer.com>
 
        * doc/install.texi (Configuration): Remove reference to CrossGCC
index 7a645c3569bd3dfb11973d38b9ece7ca2dd8574b..180fb35c66241279ffbb478e0880c71b2e197521 100644 (file)
@@ -2376,6 +2376,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 9ec0a99f0a536a6f10f45a12344043643ae61956..8407c2f6eb73f296fcf00c72a283946088023e80 100644 (file)
@@ -1,3 +1,8 @@
+2006-06-23  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/28045
+       * gcc.dg/torture/pr28045.c: New testcase.
+
 2006-06-22  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/28109
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;
+}
+