diff options
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index c7af5e7eccc..05166eb8c90 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -272,10 +272,6 @@ single_non_singleton_phi_for_edges (gimple_seq seq, edge e0, edge e1) return phi; } -/* For conditional store replacement we need a temporary to - put the old contents of the memory in. */ -static tree condstoretemp; - /* The core routine of conditional store replacement and normal phi optimizations. Both share much of the infrastructure in how to match applicable basic block patterns. DO_STORE_ELIM is true @@ -292,11 +288,8 @@ tree_ssa_phiopt_worker (bool do_store_elim, bool do_hoist_loads) struct pointer_set_t *nontrap = 0; if (do_store_elim) - { - condstoretemp = NULL_TREE; - /* Calculate the set of non-trapping memory accesses. */ - nontrap = get_non_trapping (); - } + /* Calculate the set of non-trapping memory accesses. */ + nontrap = get_non_trapping (); /* Search every basic block for COND_EXPR we may be able to optimize. @@ -690,11 +683,9 @@ conditional_replacement (basic_block cond_bb, basic_block middle_bb, { source_location locus_0, locus_1; - new_var2 = create_tmp_var (TREE_TYPE (result), NULL); + new_var2 = make_ssa_name (TREE_TYPE (result), NULL); new_stmt = gimple_build_assign_with_ops (CONVERT_EXPR, new_var2, new_var, NULL); - new_var2 = make_ssa_name (new_var2, new_stmt); - gimple_assign_set_lhs (new_stmt, new_var2); gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT); new_var = new_var2; @@ -1212,10 +1203,7 @@ abs_replacement (basic_block cond_bb, basic_block middle_bb, result = duplicate_ssa_name (result, NULL); if (negate) - { - tree tmp = create_tmp_var (TREE_TYPE (result), NULL); - lhs = make_ssa_name (tmp, NULL); - } + lhs = make_ssa_name (TREE_TYPE (result), NULL); else lhs = result; @@ -1445,7 +1433,7 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, edge e0, edge e1, struct pointer_set_t *nontrap) { gimple assign = last_and_only_stmt (middle_bb); - tree lhs, rhs, name; + tree lhs, rhs, name, name2; gimple newphi, new_stmt; gimple_stmt_iterator gsi; source_location locus; @@ -1476,31 +1464,26 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, gsi_remove (&gsi, true); release_defs (assign); - /* 2) Create a temporary where we can store the old content - of the memory touched by the store, if we need to. */ - if (!condstoretemp || TREE_TYPE (lhs) != TREE_TYPE (condstoretemp)) - condstoretemp = create_tmp_reg (TREE_TYPE (lhs), "cstore"); - - /* 3) Insert a load from the memory of the store to the temporary + /* 2) Insert a load from the memory of the store to the temporary on the edge which did not contain the store. */ lhs = unshare_expr (lhs); - new_stmt = gimple_build_assign (condstoretemp, lhs); - name = make_ssa_name (condstoretemp, new_stmt); - gimple_assign_set_lhs (new_stmt, name); + name = make_temp_ssa_name (TREE_TYPE (lhs), NULL, "cstore"); + new_stmt = gimple_build_assign (name, lhs); gimple_set_location (new_stmt, locus); gsi_insert_on_edge (e1, new_stmt); - /* 4) Create a PHI node at the join block, with one argument + /* 3) Create a PHI node at the join block, with one argument holding the old RHS, and the other holding the temporary where we stored the old memory contents. */ - newphi = create_phi_node (condstoretemp, join_bb); + name2 = make_temp_ssa_name (TREE_TYPE (lhs), NULL, "cstore"); + newphi = create_phi_node (name2, join_bb); add_phi_arg (newphi, rhs, e0, locus); add_phi_arg (newphi, name, e1, locus); lhs = unshare_expr (lhs); new_stmt = gimple_build_assign (lhs, PHI_RESULT (newphi)); - /* 5) Insert that PHI node. */ + /* 4) Insert that PHI node. */ gsi = gsi_after_labels (join_bb); if (gsi_end_p (gsi)) { @@ -1520,7 +1503,7 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb, basic_block join_bb, gimple then_assign, gimple else_assign) { - tree lhs_base, lhs, then_rhs, else_rhs; + tree lhs_base, lhs, then_rhs, else_rhs, name; source_location then_locus, else_locus; gimple_stmt_iterator gsi; gimple newphi, new_stmt; @@ -1560,21 +1543,17 @@ cond_if_else_store_replacement_1 (basic_block then_bb, basic_block else_bb, gsi_remove (&gsi, true); release_defs (else_assign); - /* 2) Create a temporary where we can store the old content - of the memory touched by the store, if we need to. */ - if (!condstoretemp || TREE_TYPE (lhs) != TREE_TYPE (condstoretemp)) - condstoretemp = create_tmp_reg (TREE_TYPE (lhs), "cstore"); - - /* 3) Create a PHI node at the join block, with one argument + /* 2) Create a PHI node at the join block, with one argument holding the old RHS, and the other holding the temporary where we stored the old memory contents. */ - newphi = create_phi_node (condstoretemp, join_bb); + name = make_temp_ssa_name (TREE_TYPE (lhs), NULL, "cstore"); + newphi = create_phi_node (name, join_bb); add_phi_arg (newphi, then_rhs, EDGE_SUCC (then_bb, 0), then_locus); add_phi_arg (newphi, else_rhs, EDGE_SUCC (else_bb, 0), else_locus); new_stmt = gimple_build_assign (lhs, PHI_RESULT (newphi)); - /* 4) Insert that PHI node. */ + /* 3) Insert that PHI node. */ gsi = gsi_after_labels (join_bb); if (gsi_end_p (gsi)) { |