Commit 9390c347 by Richard Kenner Committed by Richard Kenner

tree-ssa-operands.c (build_ssa_operands, [...]): Ignore a VIEW_CONVERT_EXPR on…

tree-ssa-operands.c (build_ssa_operands, [...]): Ignore a VIEW_CONVERT_EXPR on LHS when deciding if must or may def.

	PR/18664
	* tree-ssa-operands.c (build_ssa_operands, case MODIFY_EXPR):
	Ignore a VIEW_CONVERT_EXPR on LHS when deciding if must or may def.
	* tree-ssa-ccp.c (visit_assignment): If LHS is a VIEW_CONVERT_EXPR,
	add an inverse VIEW_CONVERT_EXPR to const_val.

From-SVN: r91450
parent ab1a8620
2004-11-28 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> 2004-11-28 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
PR/18664
* tree-ssa-operands.c (build_ssa_operands, case MODIFY_EXPR):
Ignore a VIEW_CONVERT_EXPR on LHS when deciding if must or may def.
* tree-ssa-ccp.c (visit_assignment): If LHS is a VIEW_CONVERT_EXPR,
add an inverse VIEW_CONVERT_EXPR to const_val.
PR/18657
* tree-nested.c (check_for_nested_with_variably_modified): New. * tree-nested.c (check_for_nested_with_variably_modified): New.
(create_nesting_tree): Call it. (create_nesting_tree): Call it.
......
...@@ -1053,21 +1053,35 @@ visit_assignment (tree stmt, tree *output_p) ...@@ -1053,21 +1053,35 @@ visit_assignment (tree stmt, tree *output_p)
val = *nval; val = *nval;
} }
else else
{ /* Evaluate the statement. */
/* Evaluate the statement. */
val = evaluate_stmt (stmt); val = evaluate_stmt (stmt);
}
/* FIXME: Hack. If this was a definition of a bitfield, we need to widen /* If the original LHS was a VIEW_CONVERT_EXPR, modify the constant
value to be a VIEW_CONVERT_EXPR of the old constant value. This is
valid because a VIEW_CONVERT_EXPR is valid everywhere an operand of
aggregate type is valid.
??? Also, if this was a definition of a bitfield, we need to widen
the constant value into the type of the destination variable. This the constant value into the type of the destination variable. This
should not be necessary if GCC represented bitfields properly. */ should not be necessary if GCC represented bitfields properly. */
{ {
tree lhs = TREE_OPERAND (stmt, 0); tree orig_lhs = TREE_OPERAND (stmt, 0);
if (TREE_CODE (orig_lhs) == VIEW_CONVERT_EXPR
&& val.lattice_val == CONSTANT)
{
val.const_val = build1 (VIEW_CONVERT_EXPR,
TREE_TYPE (TREE_OPERAND (orig_lhs, 0)),
val.const_val);
orig_lhs = TREE_OPERAND (orig_lhs, 1);
}
if (val.lattice_val == CONSTANT if (val.lattice_val == CONSTANT
&& TREE_CODE (lhs) == COMPONENT_REF && TREE_CODE (orig_lhs) == COMPONENT_REF
&& DECL_BIT_FIELD (TREE_OPERAND (lhs, 1))) && DECL_BIT_FIELD (TREE_OPERAND (orig_lhs, 1)))
{ {
tree w = widen_bitfield (val.const_val, TREE_OPERAND (lhs, 1), lhs); tree w = widen_bitfield (val.const_val, TREE_OPERAND (orig_lhs, 1),
orig_lhs);
if (w && is_gimple_min_invariant (w)) if (w && is_gimple_min_invariant (w))
val.const_val = w; val.const_val = w;
......
...@@ -893,20 +893,33 @@ build_ssa_operands (tree stmt, stmt_ann_t ann, stmt_operands_p old_ops, ...@@ -893,20 +893,33 @@ build_ssa_operands (tree stmt, stmt_ann_t ann, stmt_operands_p old_ops,
switch (code) switch (code)
{ {
case MODIFY_EXPR: case MODIFY_EXPR:
get_expr_operands (stmt, &TREE_OPERAND (stmt, 1), opf_none); /* First get operands from the RHS. For the LHS, we use a V_MAY_DEF if
if (TREE_CODE (TREE_OPERAND (stmt, 0)) == ARRAY_REF either only part of LHS is modified or if the RHS might throw,
|| TREE_CODE (TREE_OPERAND (stmt, 0)) == ARRAY_RANGE_REF otherwise, use V_MUST_DEF.
|| TREE_CODE (TREE_OPERAND (stmt, 0)) == COMPONENT_REF
|| TREE_CODE (TREE_OPERAND (stmt, 0)) == REALPART_EXPR ??? If it might throw, we should represent somehow that it is killed
|| TREE_CODE (TREE_OPERAND (stmt, 0)) == IMAGPART_EXPR on the fallthrough path. */
/* Use a V_MAY_DEF if the RHS might throw, as the LHS won't be {
modified in that case. FIXME we should represent somehow tree lhs = TREE_OPERAND (stmt, 0);
that it is killed on the fallthrough path. */ int lhs_flags = opf_is_def;
|| tree_could_throw_p (TREE_OPERAND (stmt, 1)))
get_expr_operands (stmt, &TREE_OPERAND (stmt, 0), opf_is_def); get_expr_operands (stmt, &TREE_OPERAND (stmt, 1), opf_none);
else
get_expr_operands (stmt, &TREE_OPERAND (stmt, 0), /* If the LHS is a VIEW_CONVERT_EXPR, it isn't changing whether
opf_is_def | opf_kill_def); or not the entire LHS is modified; that depends on what's
inside the VIEW_CONVERT_EXPR. */
if (TREE_CODE (lhs) == VIEW_CONVERT_EXPR)
lhs = TREE_OPERAND (lhs, 0);
if (TREE_CODE (lhs) != ARRAY_REF && TREE_CODE (lhs) != ARRAY_RANGE_REF
&& TREE_CODE (lhs) != COMPONENT_REF
&& TREE_CODE (lhs) != BIT_FIELD_REF
&& TREE_CODE (lhs) != REALPART_EXPR
&& TREE_CODE (lhs) != IMAGPART_EXPR)
lhs_flags |= opf_kill_def;
get_expr_operands (stmt, &TREE_OPERAND (stmt, 0), lhs_flags);
}
break; break;
case COND_EXPR: case COND_EXPR:
......
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