diff options
author | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-16 18:29:01 +0000 |
---|---|---|
committer | mpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-12-16 18:29:01 +0000 |
commit | 2e4fb82e490be4ee012898a67d796cd167a093ea (patch) | |
tree | 934c45cf87fd29677d4acbc201a26aaddb8742ee /gcc/match.pd | |
parent | 852fa94e29ebd44814054f4657b7385788b0321b (diff) | |
download | gcc-2e4fb82e490be4ee012898a67d796cd167a093ea.tar.gz |
PR middle-end/64309
* match.pd: Add ((1 << A) & 1) != 0 -> A == 0 and
((1 << A) & 1) == 0 -> A != 0.
* gcc.dg/pr64309.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@218787 138bc75d-0d04-0410-961f-82ee72b054a4
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 083d65f9ee1..dbca99efb01 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -599,6 +599,13 @@ along with GCC; see the file COPYING3. If not see build_int_cst (TREE_TYPE (@1), element_precision (type)), @1); })) +/* ((1 << A) & 1) != 0 -> A == 0 + ((1 << A) & 1) == 0 -> A != 0 */ +(for cmp (ne eq) + icmp (eq ne) + (simplify + (cmp (bit_and (lshift integer_onep @0) integer_onep) integer_zerop) + (icmp @0 { build_zero_cst (TREE_TYPE (@0)); }))) /* Simplifications of conversions. */ |