aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2006-02-25 22:27:54 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2006-02-25 22:27:54 +0000
commiteb8dffe0fbff242efc573fba9eff7a1da7eb893f (patch)
tree33a222942c6e3c0053613f0b378d977c6e36e141 /gcc/testsuite/gcc.dg
parentd349482e965a1f68edcc6cbac12aa52c5cc95196 (diff)
downloadgcc-eb8dffe0fbff242efc573fba9eff7a1da7eb893f.zip
gcc-eb8dffe0fbff242efc573fba9eff7a1da7eb893f.tar.gz
gcc-eb8dffe0fbff242efc573fba9eff7a1da7eb893f.tar.bz2
re PR middle-end/23673 (fold does not fold (a^b) != 0 to a != b)
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. From-SVN: r111442
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/fold-eqxor-1.c28
-rw-r--r--gcc/testsuite/gcc.dg/fold-eqxor-2.c28
-rw-r--r--gcc/testsuite/gcc.dg/fold-eqxor-3.c28
3 files changed, 84 insertions, 0 deletions
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 0000000..d220e42
--- /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 0000000..ee5ec9fa
--- /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 0000000..a087375
--- /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" } } */