Commit 96da8066 by Eric Botcazou Committed by Eric Botcazou

tree.c (process_call_operands): Propagate TREE_READONLY from the operands.

	* tree.c (process_call_operands): Propagate TREE_READONLY from the
	operands.
	(PROCESS_ARG): Do not clear TREE_READONLY if CONSTANT_CLASS_P.
	(build3_stat): Propagate TREE_READONLY for COND_EXPR.

From-SVN: r149060
parent 3ad1aba1
2009-06-29 Eric Botcazou <ebotcazou@adacore.com>
* tree.c (process_call_operands): Propagate TREE_READONLY from the
operands.
(PROCESS_ARG): Do not clear TREE_READONLY if CONSTANT_CLASS_P.
(build3_stat): Propagate TREE_READONLY for COND_EXPR.
2009-06-29 Daniel Jacobowitz <dan@codesourcery.com> 2009-06-29 Daniel Jacobowitz <dan@codesourcery.com>
* config/arm/arm.h (REGISTER_MOVE_COST): Increase VFP register * config/arm/arm.h (REGISTER_MOVE_COST): Increase VFP register
......
...@@ -2479,28 +2479,28 @@ static void ...@@ -2479,28 +2479,28 @@ static void
process_call_operands (tree t) process_call_operands (tree t)
{ {
bool side_effects = TREE_SIDE_EFFECTS (t); bool side_effects = TREE_SIDE_EFFECTS (t);
int i; bool read_only = false;
int i = call_expr_flags (t);
/* Calls have side-effects, except those to const or pure functions. */
if ((i & ECF_LOOPING_CONST_OR_PURE) || !(i & (ECF_CONST | ECF_PURE)))
side_effects = true;
/* Propagate TREE_READONLY of arguments for const functions. */
if (i & ECF_CONST)
read_only = true;
if (!side_effects) if (!side_effects || read_only)
for (i = 1; i < TREE_OPERAND_LENGTH (t); i++) for (i = 1; i < TREE_OPERAND_LENGTH (t); i++)
{ {
tree op = TREE_OPERAND (t, i); tree op = TREE_OPERAND (t, i);
if (op && TREE_SIDE_EFFECTS (op)) if (op && TREE_SIDE_EFFECTS (op))
{ side_effects = true;
side_effects = true; if (op && !TREE_READONLY (op) && !CONSTANT_CLASS_P (op))
break; read_only = false;
}
} }
if (!side_effects)
{
/* Calls have side-effects, except those to const or pure functions. */
i = call_expr_flags (t);
if ((i & ECF_LOOPING_CONST_OR_PURE) || !(i & (ECF_CONST | ECF_PURE)))
side_effects = true;
}
TREE_SIDE_EFFECTS (t) = side_effects; TREE_SIDE_EFFECTS (t) = side_effects;
TREE_READONLY (t) = read_only;
} }
/* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size /* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size
...@@ -3346,18 +3346,19 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL) ...@@ -3346,18 +3346,19 @@ build1_stat (enum tree_code code, tree type, tree node MEM_STAT_DECL)
return t; return t;
} }
#define PROCESS_ARG(N) \ #define PROCESS_ARG(N) \
do { \ do { \
TREE_OPERAND (t, N) = arg##N; \ TREE_OPERAND (t, N) = arg##N; \
if (arg##N &&!TYPE_P (arg##N)) \ if (arg##N &&!TYPE_P (arg##N)) \
{ \ { \
if (TREE_SIDE_EFFECTS (arg##N)) \ if (TREE_SIDE_EFFECTS (arg##N)) \
side_effects = 1; \ side_effects = 1; \
if (!TREE_READONLY (arg##N)) \ if (!TREE_READONLY (arg##N) \
read_only = 0; \ && !CONSTANT_CLASS_P (arg##N)) \
if (!TREE_CONSTANT (arg##N)) \ read_only = 0; \
constant = 0; \ if (!TREE_CONSTANT (arg##N)) \
} \ constant = 0; \
} \
} while (0) } while (0)
tree tree
...@@ -3424,6 +3425,8 @@ build3_stat (enum tree_code code, tree tt, tree arg0, tree arg1, ...@@ -3424,6 +3425,8 @@ build3_stat (enum tree_code code, tree tt, tree arg0, tree arg1,
t = make_node_stat (code PASS_MEM_STAT); t = make_node_stat (code PASS_MEM_STAT);
TREE_TYPE (t) = tt; TREE_TYPE (t) = tt;
read_only = 1;
/* As a special exception, if COND_EXPR has NULL branches, we /* As a special exception, if COND_EXPR has NULL branches, we
assume that it is a gimple statement and always consider assume that it is a gimple statement and always consider
it to have side effects. */ it to have side effects. */
...@@ -3439,6 +3442,9 @@ build3_stat (enum tree_code code, tree tt, tree arg0, tree arg1, ...@@ -3439,6 +3442,9 @@ build3_stat (enum tree_code code, tree tt, tree arg0, tree arg1,
PROCESS_ARG(1); PROCESS_ARG(1);
PROCESS_ARG(2); PROCESS_ARG(2);
if (code == COND_EXPR)
TREE_READONLY (t) = read_only;
TREE_SIDE_EFFECTS (t) = side_effects; TREE_SIDE_EFFECTS (t) = side_effects;
TREE_THIS_VOLATILE (t) TREE_THIS_VOLATILE (t)
= (TREE_CODE_CLASS (code) == tcc_reference = (TREE_CODE_CLASS (code) == tcc_reference
......
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