Commit 1eaea409 by Kazu Hirata Committed by Kazu Hirata

fold-const.c (fold_binary): Unroll the very first "for" loop.

	* fold-const.c (fold_binary): Unroll the very first "for"
	loop.

From-SVN: r96003
parent 209eaaff
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
* fold-const.c (fold_binary): Remove handling of RANGE_EXPR. * fold-const.c (fold_binary): Remove handling of RANGE_EXPR.
* fold-const.c (fold_binary): Unroll the very first "for"
loop.
2005-03-06 David Edelsohn <edelsohn@gnu.org> 2005-03-06 David Edelsohn <edelsohn@gnu.org>
* config/rs6000/predicates.md (branch_comparison_operator): Remove * config/rs6000/predicates.md (branch_comparison_operator): Remove
......
...@@ -7038,21 +7038,17 @@ fold_binary (tree expr) ...@@ -7038,21 +7038,17 @@ fold_binary (tree expr)
/* WINS will be nonzero when the switch is done /* WINS will be nonzero when the switch is done
if all operands are constant. */ if all operands are constant. */
int wins = 1; int wins = 1;
int i;
gcc_assert (IS_EXPR_CODE_CLASS (kind) gcc_assert (IS_EXPR_CODE_CLASS (kind)
&& TREE_CODE_LENGTH (code) == 2); && TREE_CODE_LENGTH (code) == 2);
op0 = TREE_OPERAND (t, 0); arg0 = op0 = TREE_OPERAND (t, 0);
op1 = TREE_OPERAND (t, 1); arg1 = op1 = TREE_OPERAND (t, 1);
for (i = 0; i < 2; i++)
if (arg0)
{ {
tree op = TREE_OPERAND (t, i);
tree subop; tree subop;
if (op == 0)
continue; /* Valid for CALL_EXPR, at least. */
/* Strip any conversions that don't change the mode. This is /* Strip any conversions that don't change the mode. This is
safe for every expression, except for a comparison expression safe for every expression, except for a comparison expression
because its signedness is derived from its operands. So, in because its signedness is derived from its operands. So, in
...@@ -7065,14 +7061,14 @@ fold_binary (tree expr) ...@@ -7065,14 +7061,14 @@ fold_binary (tree expr)
cases, the appropriate type conversions should be put back in cases, the appropriate type conversions should be put back in
the tree that will get out of the constant folder. */ the tree that will get out of the constant folder. */
if (kind == tcc_comparison) if (kind == tcc_comparison)
STRIP_SIGN_NOPS (op); STRIP_SIGN_NOPS (arg0);
else else
STRIP_NOPS (op); STRIP_NOPS (arg0);
if (TREE_CODE (op) == COMPLEX_CST) if (TREE_CODE (arg0) == COMPLEX_CST)
subop = TREE_REALPART (op); subop = TREE_REALPART (arg0);
else else
subop = op; subop = arg0;
if (TREE_CODE (subop) != INTEGER_CST if (TREE_CODE (subop) != INTEGER_CST
&& TREE_CODE (subop) != REAL_CST) && TREE_CODE (subop) != REAL_CST)
...@@ -7080,11 +7076,39 @@ fold_binary (tree expr) ...@@ -7080,11 +7076,39 @@ fold_binary (tree expr)
static var addresses are constant but we can't static var addresses are constant but we can't
do arithmetic on them. */ do arithmetic on them. */
wins = 0; wins = 0;
}
if (arg1)
{
tree subop;
/* Strip any conversions that don't change the mode. This is
safe for every expression, except for a comparison expression
because its signedness is derived from its operands. So, in
the latter case, only strip conversions that don't change the
signedness.
if (i == 0) Note that this is done as an internal manipulation within the
arg0 = op; constant folder, in order to find the simplest representation
else if (i == 1) of the arguments so that their form can be studied. In any
arg1 = op; cases, the appropriate type conversions should be put back in
the tree that will get out of the constant folder. */
if (kind == tcc_comparison)
STRIP_SIGN_NOPS (arg1);
else
STRIP_NOPS (arg1);
if (TREE_CODE (arg1) == COMPLEX_CST)
subop = TREE_REALPART (arg1);
else
subop = arg1;
if (TREE_CODE (subop) != INTEGER_CST
&& TREE_CODE (subop) != REAL_CST)
/* Note that TREE_CONSTANT isn't enough:
static var addresses are constant but we can't
do arithmetic on them. */
wins = 0;
} }
/* If this is a commutative operation, and ARG0 is a constant, move it /* If this is a commutative operation, and ARG0 is a constant, move it
......
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