summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-03 15:31:54 +0000
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-03 15:31:54 +0000
commitddc4113bc1de27e900b21f216df7e71febe0a51e (patch)
treeb878167fa61a2c5dbc8db3e8bac37811fef8aab1 /gcc/fold-const.c
parent1a6ba51b1362a0edba3e1798592d59c43bae8dd2 (diff)
downloadgcc-ddc4113bc1de27e900b21f216df7e71febe0a51e.tar.gz
* fold-const.c (fold) [EQ_EXPR]: When seeing if D & ~C != 0 to
fold (A & C) == D into 0, fold ~C. Similarly, for the case where | is used instead of &. * testsuite/gcc.dg/tree-ssa/20041002-1.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88449 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 595d8c1d83e..7de102f9870 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8400,11 +8400,11 @@ fold (tree expr)
&& TREE_CODE (arg1) == INTEGER_CST
&& TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST)
{
- tree dandnotc
- = fold (build2 (BIT_AND_EXPR, TREE_TYPE (arg0),
- arg1, build1 (BIT_NOT_EXPR,
- TREE_TYPE (TREE_OPERAND (arg0, 1)),
- TREE_OPERAND (arg0, 1))));
+ tree notc = fold (build1 (BIT_NOT_EXPR,
+ TREE_TYPE (TREE_OPERAND (arg0, 1)),
+ TREE_OPERAND (arg0, 1)));
+ tree dandnotc = fold (build2 (BIT_AND_EXPR, TREE_TYPE (arg0),
+ arg1, notc));
tree rslt = code == EQ_EXPR ? integer_zero_node : integer_one_node;
if (integer_nonzerop (dandnotc))
return omit_one_operand (type, rslt, arg0);
@@ -8417,10 +8417,9 @@ fold (tree expr)
&& TREE_CODE (arg1) == INTEGER_CST
&& TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST)
{
- tree candnotd
- = fold (build2 (BIT_AND_EXPR, TREE_TYPE (arg0),
- TREE_OPERAND (arg0, 1),
- build1 (BIT_NOT_EXPR, TREE_TYPE (arg1), arg1)));
+ tree notd = fold (build1 (BIT_NOT_EXPR, TREE_TYPE (arg1), arg1));
+ tree candnotd = fold (build2 (BIT_AND_EXPR, TREE_TYPE (arg0),
+ TREE_OPERAND (arg0, 1), notd));
tree rslt = code == EQ_EXPR ? integer_zero_node : integer_one_node;
if (integer_nonzerop (candnotd))
return omit_one_operand (type, rslt, arg0);