aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-outof-ssa.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2018-10-31 11:57:33 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2018-10-31 11:57:33 +0000
commitef976be1a23a5171082cf1a569d00573013a175c (patch)
tree782afd083e18def3f782fe1b3164a3d22a3288ae /gcc/tree-outof-ssa.c
parent635aeaa20ffdf6e794f180cc8e053e8dc46db760 (diff)
downloadgcc-ef976be1a23a5171082cf1a569d00573013a175c.zip
gcc-ef976be1a23a5171082cf1a569d00573013a175c.tar.gz
gcc-ef976be1a23a5171082cf1a569d00573013a175c.tar.bz2
re PR middle-end/70359 (Code size increase for x86/ARM/others compared to gcc-5.3.0)
2018-10-31 Richard Biener <rguenther@suse.de> PR middle-end/70359 PR middle-end/86270 * tree-outof-ssa.c (insert_backedge_copies): Restrict copy generation to useful cases. Place the copy before the definition of the backedge value when possible. * gcc.target/i386/pr70359.c: New testcase. * gcc.target/i386/pr86270.c: Likewise. From-SVN: r265677
Diffstat (limited to 'gcc/tree-outof-ssa.c')
-rw-r--r--gcc/tree-outof-ssa.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index fca15e5..60f3c40 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -1171,15 +1171,19 @@ insert_backedge_copies (void)
{
tree arg = gimple_phi_arg_def (phi, i);
edge e = gimple_phi_arg_edge (phi, i);
+ /* We are only interested in copies emitted on critical
+ backedges. */
+ if (!(e->flags & EDGE_DFS_BACK)
+ || !EDGE_CRITICAL_P (e))
+ continue;
/* If the argument is not an SSA_NAME, then we will need a
- constant initialization. If the argument is an SSA_NAME with
- a different underlying variable then a copy statement will be
- needed. */
- if ((e->flags & EDGE_DFS_BACK)
- && (TREE_CODE (arg) != SSA_NAME
- || SSA_NAME_VAR (arg) != SSA_NAME_VAR (result)
- || trivially_conflicts_p (bb, result, arg)))
+ constant initialization. If the argument is an SSA_NAME then
+ a copy statement may be needed. First handle the case
+ where we cannot insert before the argument definition. */
+ if (TREE_CODE (arg) != SSA_NAME
+ || (gimple_code (SSA_NAME_DEF_STMT (arg)) == GIMPLE_PHI
+ && trivially_conflicts_p (bb, result, arg)))
{
tree name;
gassign *stmt;
@@ -1226,6 +1230,34 @@ insert_backedge_copies (void)
gsi_insert_after (&gsi2, stmt, GSI_NEW_STMT);
SET_PHI_ARG_DEF (phi, i, name);
}
+ /* Insert a copy before the definition of the backedge value
+ and adjust all conflicting uses. */
+ else if (trivially_conflicts_p (bb, result, arg))
+ {
+ gimple *def = SSA_NAME_DEF_STMT (arg);
+ if (gimple_nop_p (def)
+ || gimple_code (def) == GIMPLE_PHI)
+ continue;
+ tree name = copy_ssa_name (result);
+ gimple *stmt = gimple_build_assign (name, result);
+ imm_use_iterator imm_iter;
+ gimple *use_stmt;
+ /* The following matches trivially_conflicts_p. */
+ FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, result)
+ {
+ if (gimple_bb (use_stmt) != bb
+ || (gimple_code (use_stmt) != GIMPLE_PHI
+ && (maybe_renumber_stmts_bb (bb), true)
+ && gimple_uid (use_stmt) > gimple_uid (def)))
+ {
+ use_operand_p use;
+ FOR_EACH_IMM_USE_ON_STMT (use, imm_iter)
+ SET_USE (use, name);
+ }
+ }
+ gimple_stmt_iterator gsi = gsi_for_stmt (def);
+ gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+ }
}
}