diff options
Diffstat (limited to 'gcc/tree-ssa-sink.c')
-rw-r--r-- | gcc/tree-ssa-sink.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/tree-ssa-sink.c b/gcc/tree-ssa-sink.c index bb8d2ca..eb8b360 100644 --- a/gcc/tree-ssa-sink.c +++ b/gcc/tree-ssa-sink.c @@ -256,8 +256,12 @@ statement_sink_location (gimple *stmt, basic_block frombb, *zero_uses_p = false; - /* We only can sink assignments. */ - if (!is_gimple_assign (stmt)) + /* We only can sink assignments and non-looping const/pure calls. */ + int cf; + if (!is_gimple_assign (stmt) + && (!is_gimple_call (stmt) + || !((cf = gimple_call_flags (stmt)) & (ECF_CONST|ECF_PURE)) + || (cf & ECF_LOOPING_CONST_OR_PURE))) return false; /* We only can sink stmts with a single definition. */ @@ -291,7 +295,7 @@ statement_sink_location (gimple *stmt, basic_block frombb, if (stmt_ends_bb_p (stmt) || gimple_has_side_effects (stmt) || (cfun->has_local_explicit_reg_vars - && TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt))) == BLKmode)) + && TYPE_MODE (TREE_TYPE (gimple_get_lhs (stmt))) == BLKmode)) return false; /* Return if there are no immediate uses of this stmt. */ @@ -323,15 +327,15 @@ statement_sink_location (gimple *stmt, basic_block frombb, /* A killing definition is not a use. */ if ((gimple_has_lhs (use_stmt) - && operand_equal_p (gimple_assign_lhs (stmt), + && operand_equal_p (gimple_get_lhs (stmt), gimple_get_lhs (use_stmt), 0)) - || stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt))) + || stmt_kills_ref_p (use_stmt, gimple_get_lhs (stmt))) { /* If use_stmt is or might be a nop assignment then USE_STMT acts as a use as well as definition. */ if (stmt != use_stmt && ref_maybe_used_by_stmt_p (use_stmt, - gimple_assign_lhs (stmt))) + gimple_get_lhs (stmt))) return false; continue; } |