&& integer_onep (TREE_OPERAND (arg0, 1))
&& integer_onep (arg1))
return fold_build2_loc (loc, EQ_EXPR, type, arg0,
- build_int_cst (TREE_TYPE (arg0), 0));
+ build_zero_cst (TREE_TYPE (arg0)));
/* Fold (X & Y) ^ Y as ~X & Y. */
if (TREE_CODE (arg0) == BIT_AND_EXPR
&& integer_onep (TREE_OPERAND (arg0, 1))
&& integer_onep (arg1))
{
+ tree tem2;
tem = TREE_OPERAND (arg0, 0);
- return fold_build2_loc (loc, EQ_EXPR, type,
- fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (tem), tem,
- build_int_cst (TREE_TYPE (tem), 1)),
- build_int_cst (TREE_TYPE (tem), 0));
+ tem2 = fold_convert_loc (loc, TREE_TYPE (tem), arg1);
+ tem2 = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (tem),
+ tem, tem2);
+ return fold_build2_loc (loc, EQ_EXPR, type, tem2,
+ build_zero_cst (TREE_TYPE (tem)));
}
/* Fold ~X & 1 as (X & 1) == 0. */
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& integer_onep (arg1))
{
+ tree tem2;
tem = TREE_OPERAND (arg0, 0);
- return fold_build2_loc (loc, EQ_EXPR, type,
- fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (tem), tem,
- build_int_cst (TREE_TYPE (tem), 1)),
- build_int_cst (TREE_TYPE (tem), 0));
+ tem2 = fold_convert_loc (loc, TREE_TYPE (tem), arg1);
+ tem2 = fold_build2_loc (loc, BIT_AND_EXPR, TREE_TYPE (tem),
+ tem, tem2);
+ return fold_build2_loc (loc, EQ_EXPR, type, tem2,
+ build_zero_cst (TREE_TYPE (tem)));
}
/* Fold !X & 1 as X == 0. */
if (TREE_CODE (arg0) == TRUTH_NOT_EXPR
{
tem = TREE_OPERAND (arg0, 0);
return fold_build2_loc (loc, EQ_EXPR, type, tem,
- build_int_cst (TREE_TYPE (tem), 0));
+ build_zero_cst (TREE_TYPE (tem)));
}
/* Fold (X ^ Y) & Y as ~X & Y. */
if (TREE_CODE (arg0) == BIT_XOR_EXPR
&& operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0))
return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0),
- build_int_cst (TREE_TYPE (arg0), 0));
+ build_zero_cst (TREE_TYPE (arg0)));
/* Likewise (X ^ Y) == X becomes Y == 0. X has no side-effects. */
if (TREE_CODE (arg0) == BIT_XOR_EXPR
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)
&& reorder_operands_p (TREE_OPERAND (arg0, 1), arg1))
return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 1),
- build_int_cst (TREE_TYPE (arg0), 0));
+ build_zero_cst (TREE_TYPE (arg0)));
/* (X ^ C1) op C2 can be rewritten as X op (C1 ^ C2). */
if (TREE_CODE (arg0) == BIT_XOR_EXPR
BIT_XOR_EXPR, itype,
arg00, arg10),
arg01),
- build_int_cst (itype, 0));
+ build_zero_cst (itype));
if (operand_equal_p (arg01, arg10, 0))
return fold_build2_loc (loc, code, type,
BIT_XOR_EXPR, itype,
arg00, arg11),
arg01),
- build_int_cst (itype, 0));
+ build_zero_cst (itype));
if (operand_equal_p (arg00, arg11, 0))
return fold_build2_loc (loc, code, type,
BIT_XOR_EXPR, itype,
arg01, arg10),
arg00),
- build_int_cst (itype, 0));
+ build_zero_cst (itype));
if (operand_equal_p (arg00, arg10, 0))
return fold_build2_loc (loc, code, type,
BIT_XOR_EXPR, itype,
arg01, arg11),
arg00),
- build_int_cst (itype, 0));
+ build_zero_cst (itype));
}
if (TREE_CODE (arg0) == BIT_XOR_EXPR
return build2_loc (loc, code == LT_EXPR ? EQ_EXPR : NE_EXPR, type,
build2 (RSHIFT_EXPR, TREE_TYPE (arg0), arg0,
TREE_OPERAND (arg1, 1)),
- build_int_cst (TREE_TYPE (arg0), 0));
+ build_zero_cst (TREE_TYPE (arg0)));
if ((code == LT_EXPR || code == GE_EXPR)
&& TYPE_UNSIGNED (TREE_TYPE (arg0))
TREE_OPERAND (TREE_OPERAND (arg1, 0), 1));
return build2_loc (loc, code == LT_EXPR ? EQ_EXPR : NE_EXPR, type,
fold_convert_loc (loc, TREE_TYPE (arg0), tem),
- build_int_cst (TREE_TYPE (arg0), 0));
+ build_zero_cst (TREE_TYPE (arg0)));
}
return NULL_TREE;