diff options
author | Jakub Jelinek <jakub@redhat.com> | 2011-05-23 11:36:05 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2011-05-23 11:36:05 +0200 |
commit | 7bba408b970437ce2ec52b61e38d7636d1bfaa21 (patch) | |
tree | ca69f48c8a8153515aeec23bcd9eb79666cf46ae | |
parent | c11e39b0bdfc580582012fe56f0cce1b84f064f4 (diff) | |
download | gcc-7bba408b970437ce2ec52b61e38d7636d1bfaa21.zip gcc-7bba408b970437ce2ec52b61e38d7636d1bfaa21.tar.gz gcc-7bba408b970437ce2ec52b61e38d7636d1bfaa21.tar.bz2 |
re PR middle-end/48973 (Inliner bug with one-bit (1-bit) bitfield)
PR middle-end/48973
* expr.c (expand_expr_real_2) <case LT_EXPR>: If do_store_flag
failed and the comparison has a single bit signed type, use
constm1_rtx instead of const1_rtx for true value.
(do_store_flag): If ops->type is single bit signed type, disable
signel bit test optimization and pass -1 instead of 1 as last
parameter to emit_store_flag_force.
* gcc.c-torture/execute/pr48973-1.c: New test.
* gcc.c-torture/execute/pr48973-2.c: New test.
From-SVN: r174060
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/expr.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr48973-1.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr48973-2.c | 14 |
5 files changed, 59 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7070973..0421811 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2011-05-23 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/48973 + * expr.c (expand_expr_real_2) <case LT_EXPR>: If do_store_flag + failed and the comparison has a single bit signed type, use + constm1_rtx instead of const1_rtx for true value. + (do_store_flag): If ops->type is single bit signed type, disable + signel bit test optimization and pass -1 instead of 1 as last + parameter to emit_store_flag_force. + 2011-05-23 Tom de Vries <tom@codesourcery.com> PR target/45098 @@ -8105,7 +8105,10 @@ expand_expr_real_2 (sepops ops, rtx target, enum machine_mode tmode, op1 = gen_label_rtx (); jumpifnot_1 (code, treeop0, treeop1, op1, -1); - emit_move_insn (target, const1_rtx); + if (TYPE_PRECISION (type) == 1 && !TYPE_UNSIGNED (type)) + emit_move_insn (target, constm1_rtx); + else + emit_move_insn (target, const1_rtx); emit_label (op1); return target; @@ -10050,7 +10053,8 @@ do_store_flag (sepops ops, rtx target, enum machine_mode mode) if ((code == NE || code == EQ) && TREE_CODE (arg0) == BIT_AND_EXPR && integer_zerop (arg1) - && integer_pow2p (TREE_OPERAND (arg0, 1))) + && integer_pow2p (TREE_OPERAND (arg0, 1)) + && (TYPE_PRECISION (ops->type) != 1 || TYPE_UNSIGNED (ops->type))) { tree type = lang_hooks.types.type_for_mode (mode, unsignedp); return expand_expr (fold_single_bit_test (loc, @@ -10070,7 +10074,9 @@ do_store_flag (sepops ops, rtx target, enum machine_mode mode) /* Try a cstore if possible. */ return emit_store_flag_force (target, code, op0, op1, - operand_mode, unsignedp, 1); + operand_mode, unsignedp, + (TYPE_PRECISION (ops->type) == 1 + && !TYPE_UNSIGNED (ops->type)) ? -1 : 1); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b87cb2a..2429b60 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-05-23 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/48973 + * gcc.c-torture/execute/pr48973-1.c: New test. + * gcc.c-torture/execute/pr48973-2.c: New test. + 2011-05-23 Jonathan Wakely <jwakely.gcc@gmail.com> PR c++/18016 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr48973-1.c b/gcc/testsuite/gcc.c-torture/execute/pr48973-1.c new file mode 100644 index 0000000..02688a0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr48973-1.c @@ -0,0 +1,20 @@ +/* PR middle-end/48973 */ + +extern void abort (void); +struct S { int f : 1; } s; +int v = -1; + +void +foo (unsigned int x) +{ + if (x != -1U) + abort (); +} + +int +main () +{ + s.f = (v & 1) > 0; + foo (s.f); + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr48973-2.c b/gcc/testsuite/gcc.c-torture/execute/pr48973-2.c new file mode 100644 index 0000000..a64d491 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr48973-2.c @@ -0,0 +1,14 @@ +/* PR middle-end/48973 */ + +extern void abort (void); +struct S { int f : 1; } s; +int v = -1; + +int +main () +{ + s.f = v < 0; + if ((unsigned int) s.f != -1U) + abort (); + return 0; +} |