X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Ftree-ssa-ccp.c;h=c530eded8c69680bd6b2e2022af4bdceb37d4057;hb=afdc9016cd75c0ac0c9f439dc7fd4d5a4a4392d7;hp=1815ebd4d736274c0cae259613c96390698cf005;hpb=cbcbd868bd5105a82cf3a9a679b073f785c170bb;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index 1815ebd4d73..c530eded8c6 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -579,16 +579,18 @@ substitute_and_fold (void) { bool changed = fold_stmt (bsi_stmt_ptr (i)); stmt = bsi_stmt(i); + /* If we folded a builtin function, we'll likely need to rename VDEFs. */ if (replaced_address || changed) - { - mark_new_vars_to_rename (stmt, vars_to_rename); - if (maybe_clean_eh_stmt (stmt)) - tree_purge_dead_eh_edges (bb); - } - else - modify_stmt (stmt); + mark_new_vars_to_rename (stmt, vars_to_rename); + + /* If we cleaned up EH information from the statement, + remove EH edges. */ + if (maybe_clean_eh_stmt (stmt)) + tree_purge_dead_eh_edges (bb); + + modify_stmt (stmt); } if (dump_file && (dump_flags & TDF_DETAILS)) @@ -847,9 +849,7 @@ ccp_fold (tree stmt) op0 = get_value (op0)->const_val; } - retval = nondestructive_fold_unary_to_constant (code, - TREE_TYPE (rhs), - op0); + retval = fold_unary_to_constant (code, TREE_TYPE (rhs), op0); /* If we folded, but did not create an invariant, then we can not use this expression. */ @@ -900,9 +900,7 @@ ccp_fold (tree stmt) op1 = val->const_val; } - retval = nondestructive_fold_binary_to_constant (code, - TREE_TYPE (rhs), - op0, op1); + retval = fold_binary_to_constant (code, TREE_TYPE (rhs), op0, op1); /* If we folded, but did not create an invariant, then we can not use this expression. */ @@ -1057,21 +1055,35 @@ visit_assignment (tree stmt, tree *output_p) val = *nval; } else - { - /* Evaluate the statement. */ + /* Evaluate the statement. */ 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 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 - && TREE_CODE (lhs) == COMPONENT_REF - && DECL_BIT_FIELD (TREE_OPERAND (lhs, 1))) + && TREE_CODE (orig_lhs) == COMPONENT_REF + && 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)) val.const_val = w;