diff options
author | Roger Sayle <roger@eyesopen.com> | 2006-10-29 17:51:07 +0000 |
---|---|---|
committer | Roger Sayle <sayle@gcc.gnu.org> | 2006-10-29 17:51:07 +0000 |
commit | f8ed9a1c654104efd3cc124f52a4e14f396b43ad (patch) | |
tree | b49a8dec3cf8d233b45cd54501b107cf1aa58844 /gcc/fold-const.c | |
parent | 0f8bc3e1736a1b5b8195f0cb968511ca36a17c19 (diff) | |
download | gcc-f8ed9a1c654104efd3cc124f52a4e14f396b43ad.zip gcc-f8ed9a1c654104efd3cc124f52a4e14f396b43ad.tar.gz gcc-f8ed9a1c654104efd3cc124f52a4e14f396b43ad.tar.bz2 |
re PR tree-optimization/15458 (Combine ~ and ^.)
PR tree-optimization/15458
* fold-const.c (fold_binary): Optimize ~X ^ C as X ^ ~C, where C
is a constant.
* gcc.dg/fold-xornot-1.c: New test case.
From-SVN: r118152
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8e3c97a..1c3c752 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9506,6 +9506,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) fold_convert (type, TREE_OPERAND (arg0, 0)), fold_convert (type, TREE_OPERAND (arg1, 0))); + /* Convert ~X ^ C to X ^ ~C. */ + if (TREE_CODE (arg0) == BIT_NOT_EXPR + && TREE_CODE (arg1) == INTEGER_CST) + return fold_build2 (code, type, + fold_convert (type, TREE_OPERAND (arg0, 0)), + fold_build1 (BIT_NOT_EXPR, type, arg1)); + /* Fold (X & 1) ^ 1 as (X & 1) == 0. */ if (TREE_CODE (arg0) == BIT_AND_EXPR && integer_onep (TREE_OPERAND (arg0, 1)) |