re PR tree-optimization/31136 (FRE ignores bit-field truncation (C and C++ front...
authorRichard Guenther <rguenther@suse.de>
Sat, 21 Apr 2007 17:47:13 +0000 (17:47 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Sat, 21 Apr 2007 17:47:13 +0000 (17:47 +0000)
2007-04-21  Richard Guenther  <rguenther@suse.de>

PR middle-end/31136
* fold-const.c (fold_unary): Call fold_convert_const on the
original tree.

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

From-SVN: r124020

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

index cc3d7ab394367c5ee5fbec841f45ebe65967e5b6..034936d21056ff2dc3f7ced8575b0f322f11ef8e 100644 (file)
@@ -1,3 +1,9 @@
+2007-04-21  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/31136
+       * fold-const.c (fold_unary): Call fold_convert_const on the
+       original tree.
+
 2007-04-21  Alexandre Oliva  <aoliva@redhat.com>
 
        * gcse.c (store_killed_in_insn): Handle PARALLELs.
index 6d2db7b876e610ebb36032ecf82b1793ae55074b..4e8f34f06ec7bb2e9dfb36d5d991f0b66c7affe9 100644 (file)
@@ -7857,7 +7857,7 @@ fold_unary (enum tree_code code, tree type, tree op0)
            return fold_build1 (BIT_NOT_EXPR, type, fold_convert (type, tem));
        }
 
-      tem = fold_convert_const (code, type, arg0);
+      tem = fold_convert_const (code, type, op0);
       return tem ? tem : NULL_TREE;
 
     case VIEW_CONVERT_EXPR:
index 00af7d427657aec7699156b0afbb83c16d6f88a3..3157d85de1df11a787c577f83163804d4b5510f7 100644 (file)
@@ -1,3 +1,8 @@
+2007-04-21  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/31136
+       * gcc.c-torture/execute/pr31136.c: New testcase.
+
 2007-04-21  Alexandre Oliva  <aoliva@redhat.com>
 
        * gcc.target/i386/movsi-sm-1.c: New.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr31136.c b/gcc/testsuite/gcc.c-torture/execute/pr31136.c
new file mode 100644 (file)
index 0000000..66c202c
--- /dev/null
@@ -0,0 +1,17 @@
+extern void abort (void);
+
+struct S {
+  unsigned b4:4;
+  unsigned b6:6;
+} s;
+
+int main()
+{
+  s.b6 = 31;
+  s.b4 = s.b6;
+  s.b6 = s.b4;
+  if (s.b6 != 15)
+    abort ();
+  return 0;
+}
+