diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-01-04 10:37:12 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-01-04 10:37:12 +0100 |
commit | ad64e807ffca93e927b68f1aa0cea54dacbe9afd (patch) | |
tree | df2024baac99aadb23527ff59bd90a761609faaa /gcc/match.pd | |
parent | 99dee82307f1e163e150c9c810452979994047ce (diff) | |
download | gcc-ad64e807ffca93e927b68f1aa0cea54dacbe9afd.zip gcc-ad64e807ffca93e927b68f1aa0cea54dacbe9afd.tar.gz gcc-ad64e807ffca93e927b68f1aa0cea54dacbe9afd.tar.bz2 |
match.pd: Fold x == ~x to false [PR96782]
x is never equal to ~x, so we can fold such comparisons to constants.
2021-01-04 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/96782
* match.pd (x == ~x -> false, x != ~x -> true): New simplifications.
* gcc.dg/tree-ssa/pr96782.c: New test.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index f5020d8..56fb583 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -4045,6 +4045,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (if (!flag_trapping_math) { constant_boolean_node (false, type); })) +/* x == ~x -> false */ +/* x != ~x -> true */ +(for cmp (eq ne) + (simplify + (cmp:c @0 (bit_not @0)) + { constant_boolean_node (cmp == NE_EXPR, type); })) + /* Fold ~X op ~Y as Y op X. */ (for cmp (simple_comparison) (simplify |