diff options
author | Roger Sayle <roger@eyesopen.com> | 2006-02-27 03:22:18 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2006-02-27 03:22:18 +0000 |
commit | 5881ad5d9dc40dbd97cb7dc4b9d4819c27bdd533 (patch) | |
tree | 751d572c91141ad30022081f8277b791e0019f07 /gcc/testsuite/gcc.dg | |
parent | 53f1b560dbbc8485efa92063ef1e953604b40469 (diff) | |
download | gcc-5881ad5d9dc40dbd97cb7dc4b9d4819c27bdd533.zip gcc-5881ad5d9dc40dbd97cb7dc4b9d4819c27bdd533.tar.gz gcc-5881ad5d9dc40dbd97cb7dc4b9d4819c27bdd533.tar.bz2 |
fold-const.c (fold_binary): Fold (~X & C) eq/ne 0 as (X & C) ne/eq 0, where C is a single bit, i.e.
* fold-const.c (fold_binary) <EQ_EXPR>: Fold (~X & C) eq/ne 0 as
(X & C) ne/eq 0, where C is a single bit, i.e. a power of two.
Fold both "((X & C) ^ C) eq/ne 0" and "((X ^ C) & C) eq/ne 0"
as (X & C) ne/eq 0.
* gcc.dg/fold-eqandnot-1.c: New test case.
From-SVN: r111471
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r-- | gcc/testsuite/gcc.dg/fold-eqandnot-1.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/fold-eqandnot-1.c b/gcc/testsuite/gcc.dg/fold-eqandnot-1.c new file mode 100644 index 0000000..5ed65e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-eqandnot-1.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ +int test1(int a) +{ + return !(a & 4); +} + +int test2(int b) +{ + return (b & 4) == 0; +} + +int test3(int c) +{ + return ((c & 4) ^ 4) != 0; +} + +int test4(int d) +{ + return ((d ^ 4) & 4) != 0; +} + +int test5(int e) +{ + return (~e & 4) != 0; +} + +/* { dg-final { scan-tree-dump-times "\\(a \& 4\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(b \& 4\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(c \& 4\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(d \& 4\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(e \& 4\\) == 0" 1 "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ |