Commit e9ea8bd5 by Roger Sayle Committed by Roger Sayle

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
parent 70502b2c
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> 2004-07-26 Niall Douglas <s_fsfeurope2@nedprod.com>
Brian Ryner <bryner@brianryner.com> Brian Ryner <bryner@brianryner.com>
......
...@@ -3830,7 +3830,8 @@ expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode) ...@@ -3830,7 +3830,8 @@ expand_builtin_strncmp (tree exp, rtx target, enum machine_mode mode)
return 0; return 0;
/* The actual new length parameter is MIN(len,arg3). */ /* 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 we don't have POINTER_TYPE, call the function. */
if (arg1_align == 0 || arg2_align == 0) if (arg1_align == 0 || arg2_align == 0)
......
...@@ -123,7 +123,6 @@ static tree optimize_minmax_comparison (tree); ...@@ -123,7 +123,6 @@ static tree optimize_minmax_comparison (tree);
static tree extract_muldiv (tree, tree, enum tree_code, tree); static tree extract_muldiv (tree, tree, enum tree_code, tree);
static tree extract_muldiv_1 (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 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, static tree fold_binary_op_with_conditional_arg (enum tree_code, tree, tree,
tree, int); tree, int);
static bool fold_real_zero_addition_p (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) ...@@ -3634,8 +3633,9 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh)
of, e.g. EQ_EXPR, is boolean. */ of, e.g. EQ_EXPR, is boolean. */
if (TYPE_UNSIGNED (arg0_type) && (low == 0 || high == 0)) if (TYPE_UNSIGNED (arg0_type) && (low == 0 || high == 0))
{ {
if (! merge_ranges (&n_in_p, &n_low, &n_high, in_p, low, high, if (! merge_ranges (&n_in_p, &n_low, &n_high,
1, fold_convert (arg0_type, integer_zero_node), in_p, low, high, 1,
fold_convert (arg0_type, integer_zero_node),
NULL_TREE)) NULL_TREE))
break; break;
...@@ -3769,7 +3769,8 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh) ...@@ -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, if (! merge_ranges (&n_in_p, &n_low, &n_high,
1, n_low, n_high, 1, 1, n_low, n_high, 1,
fold_convert (arg0_type, integer_zero_node), fold_convert (arg0_type,
integer_zero_node),
high_positive)) high_positive))
break; break;
...@@ -3781,7 +3782,8 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh) ...@@ -3781,7 +3782,8 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh)
that will be interpreted as negative. */ that will be interpreted as negative. */
if (! merge_ranges (&n_in_p, &n_low, &n_high, if (! merge_ranges (&n_in_p, &n_low, &n_high,
0, n_low, n_high, 1, 0, n_low, n_high, 1,
fold_convert (arg0_type, integer_zero_node), fold_convert (arg0_type,
integer_zero_node),
high_positive)) high_positive))
break; break;
...@@ -4210,7 +4212,7 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) ...@@ -4210,7 +4212,7 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2)
if (comp_code == NE_EXPR) if (comp_code == NE_EXPR)
return pedantic_non_lvalue (fold_convert (type, arg1)); return pedantic_non_lvalue (fold_convert (type, arg1));
else if (comp_code == EQ_EXPR) 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. /* 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) ...@@ -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 so that we can convert this back to the
corresponding COND_EXPR. */ corresponding COND_EXPR. */
if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1)))) if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1))))
return pedantic_non_lvalue ( {
fold_convert (type, fold (build2 (MIN_EXPR, comp_type, comp_op0 = fold_convert (comp_type, comp_op0);
(comp_code == LE_EXPR comp_op1 = fold_convert (comp_type, comp_op1);
? comp_op0 : comp_op1), tem = fold (build2 (MIN_EXPR, comp_type,
(comp_code == LE_EXPR (comp_code == LE_EXPR
? comp_op1 : comp_op0))))); ? comp_op0 : comp_op1),
(comp_code == LE_EXPR
? comp_op1 : comp_op0)));
return pedantic_non_lvalue (fold_convert (type, tem));
}
break; break;
case GE_EXPR: case GE_EXPR:
case GT_EXPR: case GT_EXPR:
if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1)))) if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg1))))
return pedantic_non_lvalue ( {
fold_convert (type, fold (build2 (MAX_EXPR, comp_type, comp_op0 = fold_convert (comp_type, comp_op0);
(comp_code == GE_EXPR comp_op1 = fold_convert (comp_type, comp_op1);
? comp_op0 : comp_op1), tem = fold (build2 (MAX_EXPR, comp_type,
(comp_code == GE_EXPR (comp_code == GE_EXPR
? comp_op1 : comp_op0))))); ? 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; break;
default: default:
abort (); abort ();
...@@ -4544,13 +4555,15 @@ fold_truthop (enum tree_code code, tree truth_type, tree lhs, tree rhs) ...@@ -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))) 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; lcode = NE_EXPR;
} }
if (rcode == BIT_AND_EXPR && integer_onep (TREE_OPERAND (rhs, 1))) 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; rcode = NE_EXPR;
} }
...@@ -5312,7 +5325,7 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type) ...@@ -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 /* Return a node which has the indicated constant VALUE (either 0 or
1), and is of the indicated TYPE. */ 1), and is of the indicated TYPE. */
static tree tree
constant_boolean_node (int value, tree type) constant_boolean_node (int value, tree type)
{ {
if (type == integer_type_node) if (type == integer_type_node)
...@@ -8376,7 +8389,8 @@ fold (tree expr) ...@@ -8376,7 +8389,8 @@ fold (tree expr)
&& integer_pow2p (TREE_OPERAND (arg0, 1)) && integer_pow2p (TREE_OPERAND (arg0, 1))
&& operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0)) && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0))
return fold (build2 (code == EQ_EXPR ? NE_EXPR : EQ_EXPR, type, 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 /* 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. */ 2, then fold the expression into shifts and logical operations. */
...@@ -8644,8 +8658,9 @@ fold (tree expr) ...@@ -8644,8 +8658,9 @@ fold (tree expr)
&& ! TREE_CHAIN (arglist)) && ! TREE_CHAIN (arglist))
return fold (build2 (code, type, return fold (build2 (code, type,
build1 (INDIRECT_REF, char_type_node, build1 (INDIRECT_REF, char_type_node,
TREE_VALUE(arglist)), TREE_VALUE (arglist)),
integer_zero_node)); fold_convert (char_type_node,
integer_zero_node)));
} }
/* We can fold X/C1 op C2 where C1 and C2 are integer constants /* We can fold X/C1 op C2 where C1 and C2 are integer constants
......
...@@ -1541,7 +1541,8 @@ record_equivalences_from_incoming_edge (struct dom_walk_data *walk_data, ...@@ -1541,7 +1541,8 @@ record_equivalences_from_incoming_edge (struct dom_walk_data *walk_data,
&& !CASE_HIGH (match_case)) && !CASE_HIGH (match_case))
{ {
eq_expr_value.dst = switch_cond; 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, ...@@ -3489,7 +3490,7 @@ get_eq_expr_value (tree if_stmt,
if (TREE_CODE (cond) == SSA_NAME) if (TREE_CODE (cond) == SSA_NAME)
{ {
retval.dst = cond; 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; return retval;
} }
......
...@@ -391,6 +391,7 @@ substitute_single_use_vars (varray_type *cond_worklist, ...@@ -391,6 +391,7 @@ substitute_single_use_vars (varray_type *cond_worklist,
{ {
bool invert = false; bool invert = false;
enum tree_code new_code; enum tree_code new_code;
tree new_arg;
/* TEST_VAR was set from a TRUTH_NOT_EXPR or a NOP_EXPR. */ /* TEST_VAR was set from a TRUTH_NOT_EXPR or a NOP_EXPR. */
if (def_rhs_code == TRUTH_NOT_EXPR) if (def_rhs_code == TRUTH_NOT_EXPR)
...@@ -408,11 +409,10 @@ substitute_single_use_vars (varray_type *cond_worklist, ...@@ -408,11 +409,10 @@ substitute_single_use_vars (varray_type *cond_worklist,
if (invert) if (invert)
new_code = (new_code == EQ_EXPR ? NE_EXPR : EQ_EXPR); new_code = (new_code == EQ_EXPR ? NE_EXPR : EQ_EXPR);
new_cond = build (new_code, new_arg = TREE_OPERAND (def_rhs, 0);
boolean_type_node, new_cond = build2 (new_code, boolean_type_node, new_arg,
TREE_OPERAND (def_rhs, 0), fold_convert (TREE_TYPE (new_arg),
convert (TREE_TYPE (def_rhs), integer_zero_node));
integer_zero_node));
} }
/* Dump details. */ /* Dump details. */
......
...@@ -3442,6 +3442,7 @@ extern tree int_const_binop (enum tree_code, tree, tree, int); ...@@ -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 (tree);
extern tree build_fold_addr_expr_with_type (tree, tree); extern tree build_fold_addr_expr_with_type (tree, tree);
extern tree build_fold_indirect_ref (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 bool tree_swap_operands_p (tree, tree, bool);
extern enum tree_code swap_tree_comparison (enum tree_code); extern enum tree_code swap_tree_comparison (enum tree_code);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment