diff options
author | glisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-05-17 17:54:28 +0000 |
---|---|---|
committer | glisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-05-17 17:54:28 +0000 |
commit | a8719545560903e1dceeb2475088fe5e1301fd24 (patch) | |
tree | 1b1b1464fa56a7237a510a32cf422ab593a0209f /gcc/match.pd | |
parent | 34806102cb4b72ed7496dc8e4f72185abb4c4b25 (diff) | |
download | gcc-a8719545560903e1dceeb2475088fe5e1301fd24.tar.gz |
~X & Y to X ^ Y in some cases
2016-05-17 Marc Glisse <marc.glisse@inria.fr>
gcc/
* match.pd (~X & Y): New transformation.
gcc/testsuite/
* gcc.dg/tree-ssa/pr69270.c: Adjust.
* gcc.dg/tree-ssa/andnot-1.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@236337 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 5b3cb3bfd5e..acc41be5a8d 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -503,6 +503,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_ior:c (bit_and @0 INTEGER_CST@2) (bit_and (bit_not @0) INTEGER_CST@1)) (if (wi::bit_not (@2) == @1) (bit_xor @0 @1))) +/* Simplify (~X & Y) to X ^ Y if we know that (X & ~Y) is 0. */ +#if GIMPLE +(simplify + (bit_and (bit_not SSA_NAME@0) INTEGER_CST@1) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) + && (get_nonzero_bits (@0) & wi::bit_not (@1)) == 0) + (bit_xor @0 @1))) +#endif /* X % Y is smaller than Y. */ (for cmp (lt ge) |