This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] fold-const.c: Reorganize fold - Part 12/n
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 06 Mar 2005 10:46:45 -0500 (EST)
- Subject: [patch] fold-const.c: Reorganize fold - Part 12/n
Hi,
Attached is part 12 of my patch to reorganize fold.
Eventually, we want fold_binary to look like
fold_binary (code, type, op0, op1)
instead of
fold_binary (binary_expr)
So we should use code, type, op0, and op1 instead of t.
Currently, fold_binary calls fold_binary_op_with_conditional_arg,
which takes t. The patch changes its arguments so that it will take
code, type, op0, and op1.
Tested on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2005-03-06 Kazu Hirata <kazu@cs.umass.edu>
* fold-const.c (fold_binary_op_with_conditional_arg): Take
decomposed arguments code, type, op0, and op1 instead of t.
(fold_binary): Update a call to fold_range_test.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.527
diff -u -d -p -r1.527 fold-const.c
--- fold-const.c 6 Mar 2005 02:25:03 -0000 1.527
+++ fold-const.c 6 Mar 2005 02:38:23 -0000
@@ -121,7 +121,8 @@ static tree optimize_minmax_comparison (
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 fold_binary_op_with_conditional_arg (tree, enum tree_code,
+static tree fold_binary_op_with_conditional_arg (enum tree_code, tree,
+ tree, tree,
tree, tree, int);
static bool fold_real_zero_addition_p (tree, tree, int);
static tree fold_mathfn_compare (enum built_in_function, enum tree_code,
@@ -5446,14 +5447,12 @@ extract_array_ref (tree expr, tree *base
possible. */
static tree
-fold_binary_op_with_conditional_arg (tree t, enum tree_code code, tree cond,
- tree arg, int cond_first_p)
+fold_binary_op_with_conditional_arg (enum tree_code code,
+ tree type, tree op0, tree op1,
+ tree cond, tree arg, int cond_first_p)
{
- const tree type = TREE_TYPE (t);
- tree cond_type = cond_first_p ? TREE_TYPE (TREE_OPERAND (t, 0))
- : TREE_TYPE (TREE_OPERAND (t, 1));
- tree arg_type = cond_first_p ? TREE_TYPE (TREE_OPERAND (t, 1))
- : TREE_TYPE (TREE_OPERAND (t, 0));
+ tree cond_type = cond_first_p ? TREE_TYPE (op0) : TREE_TYPE (op1);
+ tree arg_type = cond_first_p ? TREE_TYPE (op0) : TREE_TYPE (op1);
tree test, true_value, false_value;
tree lhs = NULL_TREE;
tree rhs = NULL_TREE;
@@ -7152,7 +7151,8 @@ fold_binary (tree expr)
if (TREE_CODE (arg0) == COND_EXPR || COMPARISON_CLASS_P (arg0))
{
- tem = fold_binary_op_with_conditional_arg (t, code, arg0, arg1,
+ tem = fold_binary_op_with_conditional_arg (code, type, op0, op1,
+ arg0, arg1,
/*cond_first_p=*/1);
if (tem != NULL_TREE)
return tem;
@@ -7160,7 +7160,8 @@ fold_binary (tree expr)
if (TREE_CODE (arg1) == COND_EXPR || COMPARISON_CLASS_P (arg1))
{
- tem = fold_binary_op_with_conditional_arg (t, code, arg1, arg0,
+ tem = fold_binary_op_with_conditional_arg (code, type, op0, op1,
+ arg1, arg0,
/*cond_first_p=*/0);
if (tem != NULL_TREE)
return tem;