From 7e5608caaa3e0cddc100ecf8f7e29379b490cd24 Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 13 Feb 2012 10:37:35 +0000 Subject: [PATCH] PR middle-end/52209 * expr.c (expand_expr_real_2) : Only expand using XOR for reduce_bit_field if type is unsigned. * gcc.c-torture/execute/pr52209.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184151 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/expr.c | 5 +++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/execute/pr52209.c | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr52209.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1a97108..549af73 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-02-13 Jakub Jelinek + + PR middle-end/52209 + * expr.c (expand_expr_real_2) : Only expand using + XOR for reduce_bit_field if type is unsigned. + 2012-02-12 Eric Botcazou * config/sparc/sparc.h (CANNOT_CHANGE_MODE_CLASS): In 64-bit mode, diff --git a/gcc/expr.c b/gcc/expr.c index e63ed3b..2e716cc 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -8600,8 +8600,9 @@ expand_expr_real_2 (sepops ops, rtx target, enum machine_mode tmode, if (modifier == EXPAND_STACK_PARM) target = 0; /* In case we have to reduce the result to bitfield precision - expand this as XOR with a proper constant instead. */ - if (reduce_bit_field) + for unsigned bitfield expand this as XOR with a proper constant + instead. */ + if (reduce_bit_field && TYPE_UNSIGNED (type)) temp = expand_binop (mode, xor_optab, op0, immed_double_int_const (double_int_mask (TYPE_PRECISION (type)), mode), diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 66abdd0..e75cc5e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-02-13 Jakub Jelinek + + PR middle-end/52209 + * gcc.c-torture/execute/pr52209.c: New test. + 2012-02-12 Mikael Morin PR fortran/50981 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr52209.c b/gcc/testsuite/gcc.c-torture/execute/pr52209.c new file mode 100644 index 0000000..f1d5b1f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr52209.c @@ -0,0 +1,14 @@ +/* PR middle-end/52209 */ + +extern void abort (void); +struct S0 { int f2 : 1; } c; +int b; + +int +main () +{ + b = -1 ^ c.f2; + if (b != -1) + abort (); + return 0; +} -- 2.7.4