(fold, case PLUS_EXPR): Don't associate apart a constant operand.

From-SVN: r3807
This commit is contained in:
Richard Kenner 1993-03-20 20:49:22 -05:00
parent 404f986e04
commit ca86a57ae7

View File

@ -3424,6 +3424,12 @@ fold (expr)
if (code == PLUS_EXPR && operand_equal_p (var, arg1, 0))
return convert (TREE_TYPE (t), con);
/* If ARG0 is a constant, don't change things around;
instead keep all the constant computations together. */
if (TREE_CONSTANT (arg0))
return t;
/* Otherwise return (CON +- ARG1) - VAR. */
TREE_SET_CODE (t, MINUS_EXPR);
TREE_OPERAND (t, 1) = var;
@ -3437,6 +3443,12 @@ fold (expr)
if (code == MINUS_EXPR && operand_equal_p (var, arg1, 0))
return convert (TREE_TYPE (t), con);
/* If ARG0 is a constant, don't change things around;
instead keep all the constant computations together. */
if (TREE_CONSTANT (arg0))
return t;
/* Otherwise return VAR +- (ARG1 +- CON). */
TREE_OPERAND (t, 1) = tem
= fold (build (code, TREE_TYPE (t), arg1, con));
@ -3464,9 +3476,6 @@ fold (expr)
if (split_tree (arg1, code, &var, &con, &varsign))
{
/* EXPR is ARG0 +- (CON +- VAR). */
if (varsign == -1)
TREE_SET_CODE (t,
(code == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR));
if (TREE_CODE (t) == MINUS_EXPR
&& operand_equal_p (var, arg0, 0))
{
@ -3476,6 +3485,11 @@ fold (expr)
return fold (build1 (NEGATE_EXPR, TREE_TYPE (t),
convert (TREE_TYPE (t), con)));
}
if (TREE_CONSTANT (arg1))
return t;
if (varsign == -1)
TREE_SET_CODE (t,
(code == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR));
TREE_OPERAND (t, 0)
= fold (build (code, TREE_TYPE (t), arg0, con));
TREE_OPERAND (t, 1) = var;