Commit 1796dff4 by Richard Henderson Committed by Richard Henderson

fold-const.c (split_tree): Don't assume a constant isn't splittable.

        * fold-const.c (split_tree): Don't assume a constant isn't splittable.
        (fold): Don't assume a constant isn't foldable.
        * tree.c (build): Set TREE_CONSTANT for an expression with no
        side-effects and constant operands.
        (build1): Likewise.

From-SVN: r39585
parent 11c7e5a2
2001-02-11 Richard Henderson <rth@redhat.com>
* fold-const.c (split_tree): Don't assume a constant isn't splittable.
(fold): Don't assume a constant isn't foldable.
* tree.c (build): Set TREE_CONSTANT for an expression with no
side-effects and constant operands.
(build1): Likewise.
2001-02-10 Richard Henderson <rth@redhat.com> 2001-02-10 Richard Henderson <rth@redhat.com>
* jump.c (squeeze_notes): Revert 2000-05-12 change. * jump.c (squeeze_notes): Revert 2000-05-12 change.
......
...@@ -1357,9 +1357,6 @@ split_tree (in, code, conp, litp, negate_p) ...@@ -1357,9 +1357,6 @@ split_tree (in, code, conp, litp, negate_p)
if (TREE_CODE (in) == INTEGER_CST || TREE_CODE (in) == REAL_CST) if (TREE_CODE (in) == INTEGER_CST || TREE_CODE (in) == REAL_CST)
*litp = in; *litp = in;
else if (TREE_CONSTANT (in))
*conp = in;
else if (TREE_CODE (in) == code else if (TREE_CODE (in) == code
|| (! FLOAT_TYPE_P (TREE_TYPE (in)) || (! FLOAT_TYPE_P (TREE_TYPE (in))
/* We can associate addition and subtraction together (even /* We can associate addition and subtraction together (even
...@@ -1399,6 +1396,8 @@ split_tree (in, code, conp, litp, negate_p) ...@@ -1399,6 +1396,8 @@ split_tree (in, code, conp, litp, negate_p)
if (neg_conp_p) *conp = negate_expr (*conp); if (neg_conp_p) *conp = negate_expr (*conp);
if (neg_var_p) var = negate_expr (var); if (neg_var_p) var = negate_expr (var);
} }
else if (TREE_CONSTANT (in))
*conp = in;
else else
var = in; var = in;
...@@ -4711,7 +4710,7 @@ fold (expr) ...@@ -4711,7 +4710,7 @@ fold (expr)
tree type = TREE_TYPE (expr); tree type = TREE_TYPE (expr);
register tree arg0 = NULL_TREE, arg1 = NULL_TREE; register tree arg0 = NULL_TREE, arg1 = NULL_TREE;
register enum tree_code code = TREE_CODE (t); register enum tree_code code = TREE_CODE (t);
register int kind; register int kind = TREE_CODE_CLASS (code);
int invert; int invert;
/* 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. */
...@@ -4722,19 +4721,14 @@ fold (expr) ...@@ -4722,19 +4721,14 @@ fold (expr)
if (code == RTL_EXPR || (code == SAVE_EXPR && SAVE_EXPR_RTL (t)) != 0) if (code == RTL_EXPR || (code == SAVE_EXPR && SAVE_EXPR_RTL (t)) != 0)
return t; return t;
/* Return right away if already constant. */ /* Return right away if a constant. */
if (TREE_CONSTANT (t)) if (kind == 'c')
{
if (code == CONST_DECL)
return DECL_INITIAL (t);
return t; return t;
}
#ifdef MAX_INTEGER_COMPUTATION_MODE #ifdef MAX_INTEGER_COMPUTATION_MODE
check_max_integer_computation_mode (expr); check_max_integer_computation_mode (expr);
#endif #endif
kind = TREE_CODE_CLASS (code);
if (code == NOP_EXPR || code == FLOAT_EXPR || code == CONVERT_EXPR) if (code == NOP_EXPR || code == FLOAT_EXPR || code == CONVERT_EXPR)
{ {
tree subop; tree subop;
......
...@@ -2323,6 +2323,7 @@ build VPARAMS ((enum tree_code code, tree tt, ...)) ...@@ -2323,6 +2323,7 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
register int length; register int length;
register int i; register int i;
int fro; int fro;
int constant;
VA_START (p, tt); VA_START (p, tt);
...@@ -2341,6 +2342,13 @@ build VPARAMS ((enum tree_code code, tree tt, ...)) ...@@ -2341,6 +2342,13 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
to do this. */ to do this. */
fro = first_rtl_op (code); fro = first_rtl_op (code);
/* Expressions without side effects may be constant if their
arguments are as well. */
constant = (TREE_CODE_CLASS (code) == '<'
|| TREE_CODE_CLASS (code) == '1'
|| TREE_CODE_CLASS (code) == '2'
|| TREE_CODE_CLASS (code) == 'c');
if (length == 2) if (length == 2)
{ {
/* This is equivalent to the loop below, but faster. */ /* This is equivalent to the loop below, but faster. */
...@@ -2356,6 +2364,8 @@ build VPARAMS ((enum tree_code code, tree tt, ...)) ...@@ -2356,6 +2364,8 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
TREE_SIDE_EFFECTS (t) = 1; TREE_SIDE_EFFECTS (t) = 1;
if (!TREE_READONLY (arg0)) if (!TREE_READONLY (arg0))
TREE_READONLY (t) = 0; TREE_READONLY (t) = 0;
if (!TREE_CONSTANT (arg0))
constant = 0;
} }
if (arg1 && fro > 1) if (arg1 && fro > 1)
...@@ -2364,6 +2374,8 @@ build VPARAMS ((enum tree_code code, tree tt, ...)) ...@@ -2364,6 +2374,8 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
TREE_SIDE_EFFECTS (t) = 1; TREE_SIDE_EFFECTS (t) = 1;
if (!TREE_READONLY (arg1)) if (!TREE_READONLY (arg1))
TREE_READONLY (t) = 0; TREE_READONLY (t) = 0;
if (!TREE_CONSTANT (arg1))
constant = 0;
} }
} }
else if (length == 1) else if (length == 1)
...@@ -2390,10 +2402,14 @@ build VPARAMS ((enum tree_code code, tree tt, ...)) ...@@ -2390,10 +2402,14 @@ build VPARAMS ((enum tree_code code, tree tt, ...))
{ {
if (TREE_SIDE_EFFECTS (operand)) if (TREE_SIDE_EFFECTS (operand))
TREE_SIDE_EFFECTS (t) = 1; TREE_SIDE_EFFECTS (t) = 1;
if (!TREE_CONSTANT (operand))
constant = 0;
} }
} }
} }
va_end (p); va_end (p);
TREE_CONSTANT (t) = constant;
return t; return t;
} }
...@@ -2466,6 +2482,8 @@ build1 (code, type, node) ...@@ -2466,6 +2482,8 @@ build1 (code, type, node)
break; break;
default: default:
if (TREE_CODE_CLASS (code) == '1' && TREE_CONSTANT (node))
TREE_CONSTANT (t) = 1;
break; break;
} }
......
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