Commit b52d5eaa by Roger Sayle Committed by Roger Sayle

fold-const.c (nondestructive_fold_binary_to_constant): Rename to fold_binary_to_constant.


	* fold-const.c (nondestructive_fold_binary_to_constant): Rename
	to fold_binary_to_constant.
	(nondestructive_fold_unary_to_constant): Likewise, rename to
	fold_unary_to_constant.
	(fold_relational_hi_lo): Update call to fold_binary_to_constant.
	* tree.h (nondestructive_fold_binary_to_constant): Update prototype.
	(nondestructive_fold_unary_to_constant): Likewise.
	* tree-ssa-ccp.c (ccp_fold): Update calls to fold_unary_to_constant
	and fold_binary_to_constant.
	* tree-ssa-loop-niter.c (EXEC_BINARY, EXEC_UNARY): Delete macros.
	(inverse, number_of_iterations_cond): Replace uses of EXEC_BINARY
	and EXEC_UNARY with calls to fold_*nary_to_constant.
	* tree-ssa-loop-ivopts.c (EXEC_BINARY, EXEC_UNARY): Delete macros.
	(idx_find_step): Replace uses of EXEC_BINARY with calls to
	fold_binary_to_constant.

From-SVN: r91063
parent ba2baa55
2004-11-22 Roger Sayle <roger@eyesopen.com> 2004-11-22 Roger Sayle <roger@eyesopen.com>
* fold-const.c (nondestructive_fold_binary_to_constant): Rename
to fold_binary_to_constant.
(nondestructive_fold_unary_to_constant): Likewise, rename to
fold_unary_to_constant.
(fold_relational_hi_lo): Update call to fold_binary_to_constant.
* tree.h (nondestructive_fold_binary_to_constant): Update prototype.
(nondestructive_fold_unary_to_constant): Likewise.
* tree-ssa-ccp.c (ccp_fold): Update calls to fold_unary_to_constant
and fold_binary_to_constant.
* tree-ssa-loop-niter.c (EXEC_BINARY, EXEC_UNARY): Delete macros.
(inverse, number_of_iterations_cond): Replace uses of EXEC_BINARY
and EXEC_UNARY with calls to fold_*nary_to_constant.
* tree-ssa-loop-ivopts.c (EXEC_BINARY, EXEC_UNARY): Delete macros.
(idx_find_step): Replace uses of EXEC_BINARY with calls to
fold_binary_to_constant.
2004-11-22 Roger Sayle <roger@eyesopen.com>
* config/i386/i386.h (TARGET_USE_FANCY_MATH_387): New macro. * config/i386/i386.h (TARGET_USE_FANCY_MATH_387): New macro.
* config/i386/i386.c (override_options): Set MASK_NO_FANCY_MATH_387 * config/i386/i386.c (override_options): Set MASK_NO_FANCY_MATH_387
automatically for targets without TARGET_80387. automatically for targets without TARGET_80387.
......
...@@ -10110,11 +10110,10 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p, ...@@ -10110,11 +10110,10 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p,
fold_convert (st0, op0), fold_convert (st0, op0),
fold_convert (st1, integer_zero_node)); fold_convert (st1, integer_zero_node));
retval retval = fold_binary_to_constant (TREE_CODE (exp),
= nondestructive_fold_binary_to_constant (TREE_CODE (exp), TREE_TYPE (exp),
TREE_TYPE (exp), TREE_OPERAND (exp, 0),
TREE_OPERAND (exp, 0), TREE_OPERAND (exp, 1));
TREE_OPERAND (exp, 1));
/* If we are in gimple form, then returning EXP would create /* If we are in gimple form, then returning EXP would create
non-gimple expressions. Clearing it is safe and insures non-gimple expressions. Clearing it is safe and insures
...@@ -10145,8 +10144,7 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p, ...@@ -10145,8 +10144,7 @@ fold_relational_hi_lo (enum tree_code *code_p, const tree type, tree *op0_p,
simpler than the generic fold routine. */ simpler than the generic fold routine. */
tree tree
nondestructive_fold_binary_to_constant (enum tree_code code, tree type, fold_binary_to_constant (enum tree_code code, tree type, tree op0, tree op1)
tree op0, tree op1)
{ {
int wins = 1; int wins = 1;
tree subop0; tree subop0;
...@@ -10440,8 +10438,7 @@ nondestructive_fold_binary_to_constant (enum tree_code code, tree type, ...@@ -10440,8 +10438,7 @@ nondestructive_fold_binary_to_constant (enum tree_code code, tree type,
the generic fold routine. */ the generic fold routine. */
tree tree
nondestructive_fold_unary_to_constant (enum tree_code code, tree type, fold_unary_to_constant (enum tree_code code, tree type, tree op0)
tree op0)
{ {
/* Make sure we have a suitable constant argument. */ /* Make sure we have a suitable constant argument. */
if (code == NOP_EXPR || code == FLOAT_EXPR || code == CONVERT_EXPR) if (code == NOP_EXPR || code == FLOAT_EXPR || code == CONVERT_EXPR)
......
...@@ -847,9 +847,7 @@ ccp_fold (tree stmt) ...@@ -847,9 +847,7 @@ ccp_fold (tree stmt)
op0 = get_value (op0)->const_val; op0 = get_value (op0)->const_val;
} }
retval = nondestructive_fold_unary_to_constant (code, retval = fold_unary_to_constant (code, TREE_TYPE (rhs), op0);
TREE_TYPE (rhs),
op0);
/* If we folded, but did not create an invariant, then we can not /* If we folded, but did not create an invariant, then we can not
use this expression. */ use this expression. */
...@@ -900,9 +898,7 @@ ccp_fold (tree stmt) ...@@ -900,9 +898,7 @@ ccp_fold (tree stmt)
op1 = val->const_val; op1 = val->const_val;
} }
retval = nondestructive_fold_binary_to_constant (code, retval = fold_binary_to_constant (code, TREE_TYPE (rhs), op0, op1);
TREE_TYPE (rhs),
op0, op1);
/* If we folded, but did not create an invariant, then we can not /* If we folded, but did not create an invariant, then we can not
use this expression. */ use this expression. */
......
...@@ -96,9 +96,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -96,9 +96,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
this. */ this. */
#define AVG_LOOP_NITER(LOOP) 5 #define AVG_LOOP_NITER(LOOP) 5
/* Just to shorten the ugly names. */
#define EXEC_BINARY nondestructive_fold_binary_to_constant
#define EXEC_UNARY nondestructive_fold_unary_to_constant
/* Representation of the induction variable. */ /* Representation of the induction variable. */
struct iv struct iv
...@@ -1364,12 +1361,13 @@ idx_find_step (tree base, tree *idx, void *data) ...@@ -1364,12 +1361,13 @@ idx_find_step (tree base, tree *idx, void *data)
return false; return false;
} }
step = EXEC_BINARY (MULT_EXPR, type, step, iv_step); step = fold_binary_to_constant (MULT_EXPR, type, step, iv_step);
if (!*dta->step_p) if (!*dta->step_p)
*dta->step_p = step; *dta->step_p = step;
else else
*dta->step_p = EXEC_BINARY (PLUS_EXPR, type, *dta->step_p, step); *dta->step_p = fold_binary_to_constant (PLUS_EXPR, type,
*dta->step_p, step);
return true; return true;
} }
......
...@@ -43,9 +43,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -43,9 +43,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#define SWAP(X, Y) do { void *tmp = (X); (X) = (Y); (Y) = tmp; } while (0) #define SWAP(X, Y) do { void *tmp = (X); (X) = (Y); (Y) = tmp; } while (0)
/* Just to shorten the ugly names. */
#define EXEC_BINARY nondestructive_fold_binary_to_constant
#define EXEC_UNARY nondestructive_fold_unary_to_constant
/* /*
...@@ -156,10 +153,10 @@ inverse (tree x, tree mask) ...@@ -156,10 +153,10 @@ inverse (tree x, tree mask)
rslt = build_int_cst_type (type, 1); rslt = build_int_cst_type (type, 1);
for (; ctr; ctr--) for (; ctr; ctr--)
{ {
rslt = EXEC_BINARY (MULT_EXPR, type, rslt, x); rslt = fold_binary_to_constant (MULT_EXPR, type, rslt, x);
x = EXEC_BINARY (MULT_EXPR, type, x, x); x = fold_binary_to_constant (MULT_EXPR, type, x, x);
} }
rslt = EXEC_BINARY (BIT_AND_EXPR, type, rslt, mask); rslt = fold_binary_to_constant (BIT_AND_EXPR, type, rslt, mask);
} }
return rslt; return rslt;
...@@ -217,7 +214,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0, ...@@ -217,7 +214,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
if (code != NE_EXPR) if (code != NE_EXPR)
return; return;
step0 = EXEC_BINARY (MINUS_EXPR, type, step0, step1); step0 = fold_binary_to_constant (MINUS_EXPR, type, step0, step1);
step1 = NULL_TREE; step1 = NULL_TREE;
} }
...@@ -311,7 +308,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0, ...@@ -311,7 +308,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
if (code != NE_EXPR) if (code != NE_EXPR)
{ {
if (zero_p (step0)) if (zero_p (step0))
step = EXEC_UNARY (NEGATE_EXPR, type, step1); step = fold_unary_to_constant (NEGATE_EXPR, type, step1);
else else
step = step0; step = step0;
delta = build2 (MINUS_EXPR, type, base1, base0); delta = build2 (MINUS_EXPR, type, base1, base0);
...@@ -320,8 +317,8 @@ number_of_iterations_cond (tree type, tree base0, tree step0, ...@@ -320,8 +317,8 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
if (TREE_CODE (delta) == INTEGER_CST) if (TREE_CODE (delta) == INTEGER_CST)
{ {
tmp = EXEC_BINARY (MINUS_EXPR, type, step, tmp = fold_binary_to_constant (MINUS_EXPR, type, step,
build_int_cst_type (type, 1)); build_int_cst_type (type, 1));
if (was_sharp if (was_sharp
&& operand_equal_p (delta, tmp, 0)) && operand_equal_p (delta, tmp, 0))
{ {
...@@ -342,8 +339,10 @@ number_of_iterations_cond (tree type, tree base0, tree step0, ...@@ -342,8 +339,10 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
may_xform = boolean_true_node; may_xform = boolean_true_node;
else else
{ {
bound = EXEC_BINARY (PLUS_EXPR, type, mmin, step); bound = fold_binary_to_constant (PLUS_EXPR, type,
bound = EXEC_BINARY (MINUS_EXPR, type, bound, delta); mmin, step);
bound = fold_binary_to_constant (MINUS_EXPR, type,
bound, delta);
may_xform = fold (build2 (LE_EXPR, boolean_type_node, may_xform = fold (build2 (LE_EXPR, boolean_type_node,
bound, base0)); bound, base0));
} }
...@@ -354,8 +353,10 @@ number_of_iterations_cond (tree type, tree base0, tree step0, ...@@ -354,8 +353,10 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
may_xform = boolean_true_node; may_xform = boolean_true_node;
else else
{ {
bound = EXEC_BINARY (MINUS_EXPR, type, mmax, step); bound = fold_binary_to_constant (MINUS_EXPR, type,
bound = EXEC_BINARY (PLUS_EXPR, type, bound, delta); mmax, step);
bound = fold_binary_to_constant (PLUS_EXPR, type,
bound, delta);
may_xform = fold (build2 (LE_EXPR, boolean_type_node, may_xform = fold (build2 (LE_EXPR, boolean_type_node,
base1, bound)); base1, bound));
} }
...@@ -401,11 +402,11 @@ number_of_iterations_cond (tree type, tree base0, tree step0, ...@@ -401,11 +402,11 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
base1 = fold (build2 (MINUS_EXPR, type, base1, base0)); base1 = fold (build2 (MINUS_EXPR, type, base1, base0));
base0 = NULL_TREE; base0 = NULL_TREE;
if (!zero_p (step1)) if (!zero_p (step1))
step0 = EXEC_UNARY (NEGATE_EXPR, type, step1); step0 = fold_unary_to_constant (NEGATE_EXPR, type, step1);
step1 = NULL_TREE; step1 = NULL_TREE;
if (!tree_expr_nonnegative_p (fold_convert (signed_niter_type, step0))) if (!tree_expr_nonnegative_p (fold_convert (signed_niter_type, step0)))
{ {
step0 = EXEC_UNARY (NEGATE_EXPR, type, step0); step0 = fold_unary_to_constant (NEGATE_EXPR, type, step0);
base1 = fold (build1 (NEGATE_EXPR, type, base1)); base1 = fold (build1 (NEGATE_EXPR, type, base1));
} }
...@@ -416,9 +417,9 @@ number_of_iterations_cond (tree type, tree base0, tree step0, ...@@ -416,9 +417,9 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
is infinite. Otherwise, the number of iterations is is infinite. Otherwise, the number of iterations is
(inverse(s/d) * (c/d)) mod (size of mode/d). */ (inverse(s/d) * (c/d)) mod (size of mode/d). */
bits = num_ending_zeros (step0); bits = num_ending_zeros (step0);
d = EXEC_BINARY (LSHIFT_EXPR, niter_type, d = fold_binary_to_constant (LSHIFT_EXPR, niter_type,
build_int_cst_type (niter_type, 1), bits); build_int_cst_type (niter_type, 1), bits);
s = EXEC_BINARY (RSHIFT_EXPR, niter_type, step0, bits); s = fold_binary_to_constant (RSHIFT_EXPR, niter_type, step0, bits);
bound = build_low_bits_mask (niter_type, bound = build_low_bits_mask (niter_type,
(TYPE_PRECISION (niter_type) (TYPE_PRECISION (niter_type)
...@@ -447,7 +448,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0, ...@@ -447,7 +448,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
{ {
if (mmax) if (mmax)
{ {
bound = EXEC_BINARY (MINUS_EXPR, type, mmax, step0); bound = fold_binary_to_constant (MINUS_EXPR, type, mmax, step0);
assumption = fold (build2 (LE_EXPR, boolean_type_node, assumption = fold (build2 (LE_EXPR, boolean_type_node,
base1, bound)); base1, bound));
assumptions = fold (build2 (TRUTH_AND_EXPR, boolean_type_node, assumptions = fold (build2 (TRUTH_AND_EXPR, boolean_type_node,
...@@ -468,7 +469,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0, ...@@ -468,7 +469,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
we can again compute number of iterations as (b - (a - s)) / s. */ we can again compute number of iterations as (b - (a - s)) / s. */
if (mmin) if (mmin)
{ {
bound = EXEC_BINARY (MINUS_EXPR, type, mmin, step1); bound = fold_binary_to_constant (MINUS_EXPR, type, mmin, step1);
assumption = fold (build2 (LE_EXPR, boolean_type_node, assumption = fold (build2 (LE_EXPR, boolean_type_node,
bound, base0)); bound, base0));
assumptions = fold (build2 (TRUTH_AND_EXPR, boolean_type_node, assumptions = fold (build2 (TRUTH_AND_EXPR, boolean_type_node,
......
...@@ -3525,8 +3525,8 @@ extern int operand_equal_p (tree, tree, unsigned int); ...@@ -3525,8 +3525,8 @@ extern int operand_equal_p (tree, tree, unsigned int);
extern tree omit_one_operand (tree, tree, tree); extern tree omit_one_operand (tree, tree, tree);
extern tree omit_two_operands (tree, tree, tree, tree); extern tree omit_two_operands (tree, tree, tree, tree);
extern tree invert_truthvalue (tree); extern tree invert_truthvalue (tree);
extern tree nondestructive_fold_unary_to_constant (enum tree_code, tree, tree); extern tree fold_unary_to_constant (enum tree_code, tree, tree);
extern tree nondestructive_fold_binary_to_constant (enum tree_code, tree, tree, tree); extern tree fold_binary_to_constant (enum tree_code, tree, tree, tree);
extern tree fold_read_from_constant_string (tree); extern tree fold_read_from_constant_string (tree);
extern tree int_const_binop (enum tree_code, tree, tree, int); 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);
......
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