summaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-16 18:29:01 +0000
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>2014-12-16 18:29:01 +0000
commit2e4fb82e490be4ee012898a67d796cd167a093ea (patch)
tree934c45cf87fd29677d4acbc201a26aaddb8742ee /gcc/match.pd
parent852fa94e29ebd44814054f4657b7385788b0321b (diff)
downloadgcc-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.pd7
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. */