* fold-const.c (fold): Fold A - (A & B) into ~B & A.

From-SVN: r64615
This commit is contained in:
Kazu Hirata 2003-03-20 16:10:36 +00:00 committed by Kazu Hirata
parent 101cb92aa6
commit 015c318662
2 changed files with 20 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2003-03-20 Kazu Hirata <kazu at cs dot umass dot edu>
* fold-const.c (fold): Fold A - (A & B) into ~B & A.
2003-03-20 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.md (a peephole2): New.

View File

@ -5560,6 +5560,22 @@ fold (expr)
TREE_OPERAND (arg0, 0),
TREE_OPERAND (arg1, 0))),
TREE_OPERAND (arg0, 1)));
/* Fold A - (A & B) into ~B & A. */
if (!TREE_SIDE_EFFECTS (arg0)
&& TREE_CODE (arg1) == BIT_AND_EXPR)
{
if (operand_equal_p (arg0, TREE_OPERAND (arg1, 1), 0))
return fold (build (BIT_AND_EXPR, type,
fold (build1 (BIT_NOT_EXPR, type,
TREE_OPERAND (arg1, 0))),
arg0));
if (operand_equal_p (arg0, TREE_OPERAND (arg1, 0), 0))
return fold (build (BIT_AND_EXPR, type,
fold (build1 (BIT_NOT_EXPR, type,
TREE_OPERAND (arg1, 1))),
arg0));
}
}
/* See if ARG1 is zero and X - ARG1 reduces to X. */