From c8ba649886633947106b28f1ebf43b3b0d86be6c Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 6 Jul 2015 08:43:58 +0000 Subject: [PATCH] re PR tree-optimization/66757 (wrong code at -O1 and above on x86_64-linux-gnu) PR tree-optimization/66757 * match.pd: Add missing condition to ~X ^ C -> X ^ ~C. From-SVN: r225446 --- gcc/ChangeLog | 5 +++++ gcc/match.pd | 3 ++- gcc/testsuite/ChangeLog | 7 +++++-- gcc/testsuite/gcc.c-torture/execute/pr66757.c | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr66757.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d6337c2a23..234468c71a1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-07-06 Eric Botcazou + + PR tree-optimization/66757 + * match.pd: Add missing condition to ~X ^ C -> X ^ ~C. + 2015-07-05 Chung-Lin Tang Sandra Loosemore diff --git a/gcc/match.pd b/gcc/match.pd index 7d1d4dfbcb1..ae0d9f11134 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -444,7 +444,8 @@ along with GCC; see the file COPYING3. If not see /* Convert ~X ^ C to X ^ ~C. */ (simplify (bit_xor (convert? (bit_not @0)) INTEGER_CST@1) - (bit_xor (convert @0) (bit_not @1))) + (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) + (bit_xor (convert @0) (bit_not @1)))) /* Fold (X & Y) ^ Y as ~X & Y. */ (simplify diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e1f30e4d693..da05a9468c2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,8 +1,11 @@ +2015-07-06 Eric Botcazou + + * gcc.c-torture/execute/pr66757.c: New test. + 2015-07-06 Bin Cheng PR tree-optimization/66720 - * gcc.dg/vect/pr48052.c: Use dg-require-effective-target - vect_int_mult. + * gcc.dg/vect/pr48052.c: Use dg-require-effective-target vect_int_mult. 2015-07-05 Chung-Lin Tang Sandra Loosemore diff --git a/gcc/testsuite/gcc.c-torture/execute/pr66757.c b/gcc/testsuite/gcc.c-torture/execute/pr66757.c new file mode 100644 index 00000000000..acd4d20ff6f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr66757.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/66757 */ +/* Testcase by Zhendong Su */ + +int a, b; + +int +main (void) +{ + unsigned int t = (unsigned char) (~b); + + if ((t ^ 1) / 255) + __builtin_abort (); + + return 0; +} -- 2.30.2