re PR middle-end/37931 (ice: verify_gimple failed)
authorJakub Jelinek <jakub@redhat.com>
Tue, 28 Oct 2008 10:34:51 +0000 (11:34 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 28 Oct 2008 10:34:51 +0000 (11:34 +0100)
PR middle-end/37931
* fold-const.c (distribute_bit_expr): Convert common, left and
right arguments to type.

* gcc.c-torture/execute/pr37931.c: New test.

From-SVN: r141406

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

index 44432df..d04aa06 100644 (file)
@@ -1,3 +1,9 @@
+2008-10-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/37931
+       * fold-const.c (distribute_bit_expr): Convert common, left and
+       right arguments to type.
+
 2008-10-28  Nick Clifton  <nickc@redhat.com>
 
        * config/mn10300/mn10300.h (CALL_REALLY_USED_REGISTERS): Define.
index 1eac946..7a215d2 100644 (file)
@@ -3806,6 +3806,9 @@ distribute_bit_expr (enum tree_code code, tree type, tree arg0, tree arg1)
   else
     return 0;
 
+  common = fold_convert (type, common);
+  left = fold_convert (type, left);
+  right = fold_convert (type, right);
   return fold_build2 (TREE_CODE (arg0), type, common,
                      fold_build2 (code, type, left, right));
 }
index 3aa9a1e..58e7819 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-28  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/37931
+       * gcc.c-torture/execute/pr37931.c: New test.
+
 2008-10-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/37879
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr37931.c b/gcc/testsuite/gcc.c-torture/execute/pr37931.c
new file mode 100644 (file)
index 0000000..0077a21
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR middle-end/37931 */
+
+extern void abort (void);
+
+int
+foo (int a, unsigned int b)
+{
+  return (a | 1) & (b | 1);
+}
+
+int
+main (void)
+{
+  if (foo (6, 0xc6) != 7)
+    abort ();
+  if (foo (0x80, 0xc1) != 0x81)
+    abort ();
+  if (foo (4, 4) != 5)
+    abort ();
+  if (foo (5, 4) != 5)
+    abort ();
+  return 0;
+}