diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-25 22:27:54 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-25 22:27:54 +0000 |
commit | 47da8b49c58ee20fa06791b9ca20965339301a87 (patch) | |
tree | 33a222942c6e3c0053613f0b378d977c6e36e141 /gcc/testsuite | |
parent | 59da30e18db6518a527b4e6ad223deaab4bd71a9 (diff) | |
download | gcc-47da8b49c58ee20fa06791b9ca20965339301a87.tar.gz |
PR middle-end/23673
* fold-const.c (fold_binary) <EQ_EXPR>: Fold (X^Y) == 0 as X == Y
and (X^Y) != 0 as X != Y. Fold (X^Y) == Y as X == 0, and some
symmetry related transformations. Fold (X^C1) == C2 as
X == (C1^C2).
* gcc.dg/fold-eqxor-1.c: New test case.
* gcc.dg/fold-eqxor-2.c: Likewise.
* gcc.dg/fold-eqxor-3.c: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111442 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/fold-eqxor-1.c | 28 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/fold-eqxor-2.c | 28 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/fold-eqxor-3.c | 28 |
4 files changed, 91 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 387e690134b..9656f4ee3ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2006-02-25 Roger Sayle <roger@eyesopen.com> + + PR middle-end/23673 + * gcc.dg/fold-eqxor-1.c: New test case. + * gcc.dg/fold-eqxor-2.c: Likewise. + * gcc.dg/fold-eqxor-3.c: Likewise. + 2006-02-25 Thomas Koenig <Thomas.Koenig@online.de> PR fortran/23092 diff --git a/gcc/testsuite/gcc.dg/fold-eqxor-1.c b/gcc/testsuite/gcc.dg/fold-eqxor-1.c new file mode 100644 index 00000000000..d220e42bbfa --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-eqxor-1.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a, int b) +{ + return (a ^ b) == 0; +} + +int test2(int c, int d) +{ + return (c ^ d) != 0; +} + +unsigned int test3(unsigned int e, unsigned int f) +{ + return (e ^ f) == 0; +} + +unsigned int test4(unsigned int g, unsigned int h) +{ + return (g ^ h) != 0; +} + +/* { dg-final { scan-tree-dump-times "a == b" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "c != d" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e == f" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "g != h" 1 "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc/testsuite/gcc.dg/fold-eqxor-2.c b/gcc/testsuite/gcc.dg/fold-eqxor-2.c new file mode 100644 index 00000000000..ee5ec9fa5ae --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-eqxor-2.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a, int b) +{ + return (a ^ b) == a; +} + +int test2(int c, int d) +{ + return (c ^ d) != c; +} + +int test3(int e, int f) +{ + return (e ^ f) == f; +} + +int test4(int g, int h) +{ + return (g ^ h) != h; +} + +/* { dg-final { scan-tree-dump-times "b == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "d != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "g != 0" 1 "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ diff --git a/gcc/testsuite/gcc.dg/fold-eqxor-3.c b/gcc/testsuite/gcc.dg/fold-eqxor-3.c new file mode 100644 index 00000000000..a087375aee9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-eqxor-3.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-original" } */ + +int test1(int a, int b) +{ + return (a ^ 2) == 2; +} + +int test2(int c, int d) +{ + return (c ^ 4) != 4; +} + +int test3(int e, int f) +{ + return (e ^ 2) == 6; +} + +int test4(int g, int h) +{ + return (g ^ 6) != 4; +} + +/* { dg-final { scan-tree-dump-times "a == 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "c != 0" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "e == 4" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "g != 2" 1 "original" } } */ +/* { dg-final { cleanup-tree-dump "original" } } */ |