diff options
author | Roger Sayle <roger@eyesopen.com> | 2006-02-26 16:10:30 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2006-02-26 16:10:30 +0000 |
commit | cef65eaa924c2c9eff16af8a19b051ad61d65ec2 (patch) | |
tree | 023ddcdab0e55bd4a22ee47cd852342b1535a05e /gcc/testsuite/gcc.dg | |
parent | a861485caf6698fe171b1d80a78f3f73091615eb (diff) | |
download | gcc-cef65eaa924c2c9eff16af8a19b051ad61d65ec2.zip gcc-cef65eaa924c2c9eff16af8a19b051ad61d65ec2.tar.gz gcc-cef65eaa924c2c9eff16af8a19b051ad61d65ec2.tar.bz2 |
fold-const.c (fold_binary): Fold (X & 1) ^ 1 as (X & 1) == 0.
* fold-const.c (fold_binary) <BIT_XOR_EXPR>: Fold (X & 1) ^ 1 as
(X & 1) == 0.
<BIT_AND_EXPR>: Fold (X ^ 1) & 1 and ~X & 1 as (X & 1) == 0.
* gcc.dg/fold-even-1.c: New test case.
From-SVN: r111454
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r-- | gcc/testsuite/gcc.dg/fold-even-1.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/fold-even-1.c b/gcc/testsuite/gcc.dg/fold-even-1.c new file mode 100644 index 0000000..8e6539c --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-even-1.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ +int test1(int a) +{ + return !(a & 1); +} + +int test2(int b) +{ + return (b & 1) == 0; +} + +int test3(int c) +{ + return (c & 1) ^ 1; +} + +int test4(int d) +{ + return (d ^ 1) & 1; +} + +int test5(int e) +{ + return ~e & 1; +} + +/* { dg-final { scan-tree-dump-times "\\(a \& 1\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(b \& 1\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(c \& 1\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(d \& 1\\) == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "\\(e \& 1\\) == 0" 1 "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ |