aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJames A. Morrison <phython@gcc.gnu.org>2005-04-20 04:32:41 +0000
committerJames A. Morrison <phython@gcc.gnu.org>2005-04-20 04:32:41 +0000
commitf242e7690e6e838ec12e2d09fe1b5fc7929e20da (patch)
treeb4037461c39b448b596c703851cd4c6686eae2b5 /gcc/fold-const.c
parent33ab6245545612b87af5868b4f6e6373cc733791 (diff)
downloadgcc-f242e7690e6e838ec12e2d09fe1b5fc7929e20da.zip
gcc-f242e7690e6e838ec12e2d09fe1b5fc7929e20da.tar.gz
gcc-f242e7690e6e838ec12e2d09fe1b5fc7929e20da.tar.bz2
fold-const.c (fold_binary): Fold ~(X ^ Y) to ~X ^ Y or X ^ ~Y if ~X or ~Y simplify.
2005-04-19 James A. Morrison <phython@gcc.gnu.org> * fold-const.c (fold_binary): Fold ~(X ^ Y) to ~X ^ Y or X ^ ~Y if ~X or ~Y simplify. From-SVN: r98435
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 2c90d0c..2ed556b 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7015,6 +7015,20 @@ fold_unary (enum tree_code code, tree type, tree op0)
|| (TREE_CODE (arg0) == PLUS_EXPR
&& integer_all_onesp (TREE_OPERAND (arg0, 1)))))
return fold_build1 (NEGATE_EXPR, type, TREE_OPERAND (arg0, 0));
+ /* Convert ~(X ^ Y) to ~X ^ Y or X ^ ~Y if ~X or ~Y simplify. */
+ else if (TREE_CODE (arg0) == BIT_XOR_EXPR
+ && (tem = fold_unary (BIT_NOT_EXPR, type,
+ fold_convert (type,
+ TREE_OPERAND (arg0, 0)))))
+ return fold_build2 (BIT_XOR_EXPR, type, tem,
+ fold_convert (type, TREE_OPERAND (arg0, 1)));
+ else if (TREE_CODE (arg0) == BIT_XOR_EXPR
+ && (tem = fold_unary (BIT_NOT_EXPR, type,
+ fold_convert (type,
+ TREE_OPERAND (arg0, 1)))))
+ return fold_build2 (BIT_XOR_EXPR, type,
+ fold_convert (type, TREE_OPERAND (arg0, 0)), tem);
+
return NULL_TREE;
case TRUTH_NOT_EXPR: