From 0f3f94375a989a45df3c315789f0fc62bbf39989 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 7 Jun 2016 07:30:47 +0000 Subject: [PATCH] re PR tree-optimization/71423 (wrong code at -Os and above on x86_64-linux-gnu) 2016-06-07 Richard Biener PR middle-end/71423 * match.pd ((X | ~Y) -> Y <= X): Properly invert the comparison for signed ops. * gcc.dg/torture/pr71423.c: New testcase. From-SVN: r237166 --- gcc/ChangeLog | 6 ++++++ gcc/match.pd | 8 ++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr71423.c | 20 ++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr71423.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index edc45f5f8e9..878ee3a5f2e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-06-07 Richard Biener + + PR middle-end/71423 + * match.pd ((X | ~Y) -> Y <= X): Properly invert the comparison + for signed ops. + 2016-06-06 John David Anglin * config/pa/pa.md (call): Generate indirect long calls to non-local diff --git a/gcc/match.pd b/gcc/match.pd index 4d66243d78e..fe711159df9 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -900,12 +900,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (ne (bit_and:c (bit_not @0) @1) integer_zerop) (if (INTEGRAL_TYPE_P (TREE_TYPE (@1)) && TYPE_PRECISION (TREE_TYPE (@1)) == 1) - (lt @0 @1))) + (if (TYPE_UNSIGNED (TREE_TYPE (@1))) + (lt @0 @1) + (gt @0 @1)))) (simplify (ne (bit_ior:c (bit_not @0) @1) integer_zerop) (if (INTEGRAL_TYPE_P (TREE_TYPE (@1)) && TYPE_PRECISION (TREE_TYPE (@1)) == 1) - (le @0 @1))) + (if (TYPE_UNSIGNED (TREE_TYPE (@1))) + (le @0 @1) + (ge @0 @1)))) /* ~~x -> x */ (simplify diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a1a7f1994ff..52bb629e4e7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-07 Richard Biener + + PR middle-end/71423 + * gcc.dg/torture/pr71423.c: New testcase. + 2016-06-07 Kugan Vivekanandarajah PR middle-end/71408 diff --git a/gcc/testsuite/gcc.dg/torture/pr71423.c b/gcc/testsuite/gcc.dg/torture/pr71423.c new file mode 100644 index 00000000000..06a613f11fe --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr71423.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ + +struct S1 +{ + int f1:1; +}; + +volatile struct S1 b = { 0 }; + +int +main () +{ + char c = b.f1; + b.f1 = 1; + + if (b.f1 > -1 || c) + __builtin_abort (); + + return 0; +} -- 2.30.2