diff options
| author | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-20 02:31:26 +0000 |
|---|---|---|
| committer | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-20 02:31:26 +0000 |
| commit | 8cadcd8f65bc9687741b66aec776086ef375e3a3 (patch) | |
| tree | 16946e0d737d4e878583432cead2d91d65f93a7a | |
| parent | 86281e87f9ac84b5ef9f631f76bb61e39c196dfa (diff) | |
| download | ppe42-gcc-8cadcd8f65bc9687741b66aec776086ef375e3a3.tar.gz ppe42-gcc-8cadcd8f65bc9687741b66aec776086ef375e3a3.zip | |
2005-04-19 James A. Morrison <phython@gcc.gnu.org>
* fold-const (fold_binary): Fold ~X ^ ~ Y to X ^ Y.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98434 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/ChangeLog | 4 | ||||
| -rw-r--r-- | gcc/fold-const.c | 7 | ||||
| -rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
| -rw-r--r-- | gcc/testsuite/gcc.dg/fold-xor-1.c | 12 |
4 files changed, 27 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6b1c0404a13..237ebcd4e88 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2005-04-19 James A. Morrison <phython@gcc.gnu.org> + + * fold-const (fold_binary): Fold ~X ^ ~ Y to X ^ Y. + 2005-04-20 Michael Pogue <michael.pogue@sun.com> Joseph S. Myers <joseph@codesourcery.com> diff --git a/gcc/fold-const.c b/gcc/fold-const.c index bbd14c0177e..2c90d0c80de 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8174,6 +8174,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) goto bit_ior; } + /* Convert ~X ^ ~Y to X ^ Y. */ + if (TREE_CODE (arg0) == BIT_NOT_EXPR + && TREE_CODE (arg1) == BIT_NOT_EXPR) + return fold_build2 (code, type, + fold_convert (type, TREE_OPERAND (arg0, 0)), + fold_convert (type, TREE_OPERAND (arg1, 0))); + /* See if this can be simplified into a rotate first. If that is unsuccessful continue in the association code. */ goto bit_rotate; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b281f7d3f9e..1782fed8405 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-04-19 James A. Morrison <phython@gcc.gnu.org> + + * gcc.dg/fold-xor-1.c: New test. + 2005-04-19 James E. Wilson <wilson@specifixinc.com> PR target/20670 diff --git a/gcc/testsuite/gcc.dg/fold-xor-1.c b/gcc/testsuite/gcc.dg/fold-xor-1.c new file mode 100644 index 00000000000..c8334e1875a --- /dev/null +++ b/gcc/testsuite/gcc.dg/fold-xor-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-generic" } */ + +int f (int a, int b) { + return ~a ^ ~b; +} + +unsigned int g (unsigned int a, unsigned int b) { + return ~a ^ ~b; +} +/* { dg-final { scan-tree-dump-times "a \\^ b" 2 "generic" } } */ +/* { dg-final { cleanup-tree-dump "generic" } } */ |

