fold-const.c (constant_boolean_node): Make extern.

* fold-const.c (constant_boolean_node): Make extern.
	(make_range): Wrap long lines.
	(fold_cond_expr_with_comparison): Remove unnecessary call to
	pedantic_non_lvalue.  Add missing calls to fold_convert.
	(fold_truthop): Add missing calls to fold_convert.
	(fold): Likewise.
	* tree.h (constant_boolean_node): Add prototype here.
	* builtins.c (expand_builtin_strncmp): Add missing calls to
	fold_convert.
	* tree-ssa-dom.c (record_equivalences_from_incoming_edge):
	Call fold_convert and constant_boolean_node to correct types.
	* tree-ssa-forwprop.c (substitute_single_use_vars): Add
	missing call to fold_convert to correct types.

From-SVN: r85169
This commit is contained in:
Roger Sayle 2004-07-25 23:26:59 +00:00 committed by Roger Sayle
parent 70502b2caf
commit e9ea8bd58e
6 changed files with 66 additions and 32 deletions

View file

@ -1,3 +1,19 @@
2004-07-25 Roger Sayle <roger@eyesopen.com>
* fold-const.c (constant_boolean_node): Make extern.
(make_range): Wrap long lines.
(fold_cond_expr_with_comparison): Remove unnecessary call to
pedantic_non_lvalue. Add missing calls to fold_convert.
(fold_truthop): Add missing calls to fold_convert.
(fold): Likewise.
* tree.h (constant_boolean_node): Add prototype here.
* builtins.c (expand_builtin_strncmp): Add missing calls to
fold_convert.
* tree-ssa-dom.c (record_equivalences_from_incoming_edge):
Call fold_convert and constant_boolean_node to correct types.
* tree-ssa-forwprop.c (substitute_single_use_vars): Add
missing call to fold_convert to correct types.
2004-07-26 Niall Douglas <s_fsfeurope2@nedprod.com>
Brian Ryner <bryner@brianryner.com>

View file

@ -3830,7 +3830,8 @@ expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode)
return 0;
/* The actual new length parameter is MIN(len,arg3). */
len = fold (build2 (MIN_EXPR, TREE_TYPE (len), len, arg3));
len = fold (build2 (MIN_EXPR, TREE_TYPE (len), len,
fold_convert (TREE_TYPE (len), arg3)));
/* If we don't have POINTER_TYPE, call the function. */
if (arg1_align == 0 || arg2_align == 0)

View file

@ -123,7 +123,6 @@ static tree optimize_minmax_comparison (tree);
static tree extract_muldiv (tree, tree, enum tree_code, tree);
static tree extract_muldiv_1 (tree, tree, enum tree_code, tree);
static int multiple_of_p (tree, tree, tree);
static tree constant_boolean_node (int, tree);
static tree fold_binary_op_with_conditional_arg (enum tree_code, tree, tree,
tree, int);
static bool fold_real_zero_addition_p (tree, tree, int);
@ -3634,8 +3633,9 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh)
of, e.g. EQ_EXPR, is boolean. */
if (TYPE_UNSIGNED (arg0_type) && (low == 0 || high == 0))
{
if (! merge_ranges (&n_in_p, &n_low, &n_high, in_p, low, high,
1, fold_convert (arg0_type, integer_zero_node),
if (! merge_ranges (&n_in_p, &n_low, &n_high,
in_p, low, high, 1,
fold_convert (arg0_type, integer_zero_node),
NULL_TREE))
break;
@ -3769,7 +3769,8 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh)
{
if (! merge_ranges (&n_in_p, &n_low, &n_high,
1, n_low, n_high, 1,
fold_convert (arg0_type, integer_zero_node),
fold_convert (arg0_type,
integer_zero_node),
high_positive))
break;
@ -3781,7 +3782,8 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh)
that will be interpreted as negative. */
if (! merge_ranges (&n_in_p, &n_low, &n_high,
0, n_low, n_high, 1,
fold_convert (arg0_type, integer_zero_node),
fold_convert (arg0_type,
integer_zero_node),
high_positive))
break;
@ -4210,7 +4212,7 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
if (comp_code == NE_EXPR)
return pedantic_non_lvalue (fold_convert (type, arg1));
else if (comp_code == EQ_EXPR)
return pedantic_non_lvalue (fold_convert (type, integer_zero_node));
return fold_convert (type, integer_zero_node);
}
/* Try some transformations of A op B ? A : B.
@ -4266,22 +4268,31 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
so that we can convert this back to the
corresponding COND_EXPR. */
if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1))))
return pedantic_non_lvalue (
fold_convert (type, fold (build2 (MIN_EXPR, comp_type,
(comp_code == LE_EXPR
? comp_op0 : comp_op1),
(comp_code == LE_EXPR
? comp_op1 : comp_op0)))));
{
comp_op0 = fold_convert (comp_type, comp_op0);
comp_op1 = fold_convert (comp_type, comp_op1);
tem = fold (build2 (MIN_EXPR, comp_type,
(comp_code == LE_EXPR
? comp_op0 : comp_op1),
(comp_code == LE_EXPR
? comp_op1 : comp_op0)));
return pedantic_non_lvalue (fold_convert (type, tem));
}
break;
case GE_EXPR:
case GT_EXPR:
if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1))))
return pedantic_non_lvalue (
fold_convert (type, fold (build2 (MAX_EXPR, comp_type,
(comp_code == GE_EXPR
? comp_op0 : comp_op1),
(comp_code == GE_EXPR
? comp_op1 : comp_op0)))));
{
comp_op0 = fold_convert (comp_type, comp_op0);
comp_op1 = fold_convert (comp_type, comp_op1);
tem = fold (build2 (MAX_EXPR, comp_type,
(comp_code == GE_EXPR
? comp_op0 : comp_op1),
(comp_code == GE_EXPR
? comp_op1 : comp_op0)));
tem = fold (build2 (MAX_EXPR, comp_type, comp_op0, comp_op1));
return pedantic_non_lvalue (fold_convert (type, tem));
}
break;
default:
abort ();
@ -4544,13 +4555,15 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs)
if (lcode == BIT_AND_EXPR && integer_onep (TREE_OPERAND (lhs, 1)))
{
lhs = build2 (NE_EXPR, truth_type, lhs, integer_zero_node);
lhs = build2 (NE_EXPR, truth_type, lhs,
fold_convert (TREE_TYPE (lhs), integer_zero_node));
lcode = NE_EXPR;
}
if (rcode == BIT_AND_EXPR && integer_onep (TREE_OPERAND (rhs, 1)))
{
rhs = build2 (NE_EXPR, truth_type, rhs, integer_zero_node);
rhs = build2 (NE_EXPR, truth_type, rhs,
fold_convert (TREE_TYPE (rhs), integer_zero_node));
rcode = NE_EXPR;
}
@ -5312,7 +5325,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type)
/* Return a node which has the indicated constant VALUE (either 0 or
1), and is of the indicated TYPE. */
static tree
tree
constant_boolean_node (int value, tree type)
{
if (type == integer_type_node)
@ -8376,7 +8389,8 @@ fold (tree expr)
&& integer_pow2p (TREE_OPERAND (arg0, 1))
&& operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0))
return fold (build2 (code == EQ_EXPR ? NE_EXPR : EQ_EXPR, type,
arg0, integer_zero_node));
arg0, fold_convert (TREE_TYPE (arg0),
integer_zero_node)));
/* If we have (A & C) != 0 or (A & C) == 0 and C is a power of
2, then fold the expression into shifts and logical operations. */
@ -8644,8 +8658,9 @@ fold (tree expr)
&& ! TREE_CHAIN (arglist))
return fold (build2 (code, type,
build1 (INDIRECT_REF, char_type_node,
TREE_VALUE(arglist)),
integer_zero_node));
TREE_VALUE (arglist)),
fold_convert (char_type_node,
integer_zero_node)));
}
/* We can fold X/C1 op C2 where C1 and C2 are integer constants

View file

@ -1541,7 +1541,8 @@ record_equivalences_from_incoming_edge (struct dom_walk_data *walk_data,
&& !CASE_HIGH (match_case))
{
eq_expr_value.dst = switch_cond;
eq_expr_value.src = CASE_LOW (match_case);
eq_expr_value.src = fold_convert (TREE_TYPE (switch_cond),
CASE_LOW (match_case));
}
}
}
@ -3489,7 +3490,7 @@ get_eq_expr_value (tree if_stmt,
if (TREE_CODE (cond) == SSA_NAME)
{
retval.dst = cond;
retval.src = (true_arm ? integer_one_node : integer_zero_node);
retval.src = constant_boolean_node (true_arm, TREE_TYPE (cond));
return retval;
}

View file

@ -391,6 +391,7 @@ substitute_single_use_vars (varray_type *cond_worklist,
{
bool invert = false;
enum tree_code new_code;
tree new_arg;
/* TEST_VAR was set from a TRUTH_NOT_EXPR or a NOP_EXPR. */
if (def_rhs_code == TRUTH_NOT_EXPR)
@ -408,11 +409,10 @@ substitute_single_use_vars (varray_type *cond_worklist,
if (invert)
new_code = (new_code == EQ_EXPR ? NE_EXPR : EQ_EXPR);
new_cond = build (new_code,
boolean_type_node,
TREE_OPERAND (def_rhs, 0),
convert (TREE_TYPE (def_rhs),
integer_zero_node));
new_arg = TREE_OPERAND (def_rhs, 0);
new_cond = build2 (new_code, boolean_type_node, new_arg,
fold_convert (TREE_TYPE (new_arg),
integer_zero_node));
}
/* Dump details. */

View file

@ -3442,6 +3442,7 @@ extern tree int_const_binop (enum tree_code, tree, tree, int);
extern tree build_fold_addr_expr (tree);
extern tree build_fold_addr_expr_with_type (tree, tree);
extern tree build_fold_indirect_ref (tree);
extern tree constant_boolean_node (int, tree);
extern bool tree_swap_operands_p (tree, tree, bool);
extern enum tree_code swap_tree_comparison (enum tree_code);