]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/32244 (bit-field: optimization BUG)
authorRichard Guenther <rguenther@suse.de>
Fri, 25 Jan 2008 15:33:09 +0000 (15:33 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 25 Jan 2008 15:33:09 +0000 (15:33 +0000)
2008-01-25  Richard Guenther  <rguenther@suse.de>

PR middle-end/32244
* expr.c (expand_expr_real_1): Reduce result of LSHIFT_EXPR
to its bitfield precision if required.

* gcc.c-torture/execute/pr32244-1.c: New testcase.

From-SVN: r131828

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr32244-1.c [new file with mode: 0644]

index f16c87ac3fa821a1f02b6a473930a92cee6f6f7c..824f85aa2be5a4de8691ddd94f9fd616bb493391 100644 (file)
@@ -1,3 +1,9 @@
+2008-01-25  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/32244
+       * expr.c (expand_expr_real_1): Reduce result of LSHIFT_EXPR
+       to its bitfield precision if required.
+
 2008-01-25  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/33880
index 84dab2f4871cb2c325a3f24d5c8bef7e5704e900..53cb3eb9d2cb9ddfe19b4bf8e670a5780ba8f6a8 100644 (file)
@@ -8920,8 +8920,11 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
        target = 0;
       op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget,
                         VOIDmode, EXPAND_NORMAL);
-      return expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
+      temp = expand_shift (code, mode, op0, TREE_OPERAND (exp, 1), target,
                           unsignedp);
+      if (code == LSHIFT_EXPR)
+       temp = REDUCE_BIT_FIELD (temp);
+      return temp;
 
       /* Could determine the answer when only additive constants differ.  Also,
         the addition of one can be handled by changing the condition.  */
index 407d42db211f55d7e5f5330df82a55318d7d1721..9fbd03a432e193b491f049e9cfcd7b79b7ef5343 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-25  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/32244
+       * gcc.c-torture/execute/pr32244-1.c: New testcase.
+
 2008-01-25  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/34966
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr32244-1.c b/gcc/testsuite/gcc.c-torture/execute/pr32244-1.c
new file mode 100644 (file)
index 0000000..afad256
--- /dev/null
@@ -0,0 +1,20 @@
+struct foo
+{
+  unsigned long long b:40;
+} x;
+
+extern void abort (void);
+
+void test1(unsigned long long res)
+{
+  /* The shift is carried out in 40 bit precision.  */
+  if (x.b<<32 != res)
+    abort ();
+}
+
+int main()
+{
+  x.b = 0x0100;
+  test1(0);
+  return 0;
+}