summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/fold-eqxor-2.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-25 22:27:54 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-25 22:27:54 +0000
commit47da8b49c58ee20fa06791b9ca20965339301a87 (patch)
tree33a222942c6e3c0053613f0b378d977c6e36e141 /gcc/testsuite/gcc.dg/fold-eqxor-2.c
parent59da30e18db6518a527b4e6ad223deaab4bd71a9 (diff)
downloadgcc-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/gcc.dg/fold-eqxor-2.c')
-rw-r--r--gcc/testsuite/gcc.dg/fold-eqxor-2.c28
1 files changed, 28 insertions, 0 deletions
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" } } */