diff options
Diffstat (limited to 'gcc/tree-ssa-coalesce.c')
-rw-r--r-- | gcc/tree-ssa-coalesce.c | 102 |
1 files changed, 58 insertions, 44 deletions
diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index a96029aa7c5..d5e5f8702ff 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -841,16 +841,15 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo) FOR_EACH_BB (bb) { - block_stmt_iterator bsi; - tree phi; + gimple_stmt_iterator gsi; /* Start with live on exit temporaries. */ live_track_init (live, live_on_exit (liveinfo, bb)); - for (bsi = bsi_last (bb); !bsi_end_p (bsi); bsi_prev (&bsi)) + for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi)) { tree var; - tree stmt = bsi_stmt (bsi); + gimple stmt = gsi_stmt (gsi); /* A copy between 2 partitions does not introduce an interference by itself. If they did, you would never be able to coalesce @@ -859,12 +858,14 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo) This is handled by simply removing the SRC of the copy from the live list, and processing the stmt normally. */ - if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT) + if (is_gimple_assign (stmt)) { - tree lhs = GIMPLE_STMT_OPERAND (stmt, 0); - tree rhs = GIMPLE_STMT_OPERAND (stmt, 1); - if (TREE_CODE (lhs) == SSA_NAME && TREE_CODE (rhs) == SSA_NAME) - live_track_clear_var (live, rhs); + tree lhs = gimple_assign_lhs (stmt); + tree rhs1 = gimple_assign_rhs1 (stmt); + if (gimple_assign_copy_p (stmt) + && TREE_CODE (lhs) == SSA_NAME + && TREE_CODE (rhs1) == SSA_NAME) + live_track_clear_var (live, rhs1); } FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_DEF) @@ -880,8 +881,9 @@ build_ssa_conflict_graph (tree_live_info_p liveinfo) There must be a conflict recorded between the result of the PHI and any variables that are live. Otherwise the out-of-ssa translation may create incorrect code. */ - for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi)) + for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { + gimple phi = gsi_stmt (gsi); tree result = PHI_RESULT (phi); if (live_track_live_p (live, result)) live_track_process_def (live, result, graph); @@ -915,11 +917,11 @@ print_exprs (FILE *f, const char *str1, tree expr1, const char *str2, printed and compilation is then terminated. */ static inline void -abnormal_corrupt (tree phi, int i) +abnormal_corrupt (gimple phi, int i) { - edge e = PHI_ARG_EDGE (phi, i); - tree res = PHI_RESULT (phi); - tree arg = PHI_ARG_DEF (phi, i); + edge e = gimple_phi_arg_edge (phi, i); + tree res = gimple_phi_result (phi); + tree arg = gimple_phi_arg_def (phi, i); fprintf (stderr, " Corrupt SSA across abnormal edge BB%d->BB%d\n", e->src->index, e->dest->index); @@ -959,10 +961,10 @@ fail_abnormal_edge_coalesce (int x, int y) static var_map create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) { - block_stmt_iterator bsi; + gimple_stmt_iterator gsi; basic_block bb; tree var; - tree stmt; + gimple stmt; tree first; var_map map; ssa_op_iter iter; @@ -981,24 +983,25 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) FOR_EACH_BB (bb) { - tree phi, arg; + tree arg; - for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi)) + for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - int i; + gimple phi = gsi_stmt (gsi); + size_t i; int ver; tree res; bool saw_copy = false; - res = PHI_RESULT (phi); + res = gimple_phi_result (phi); ver = SSA_NAME_VERSION (res); register_ssa_partition (map, res); /* Register ssa_names and coalesces between the args and the result of all PHI. */ - for (i = 0; i < PHI_NUM_ARGS (phi); i++) + for (i = 0; i < gimple_phi_num_args (phi); i++) { - edge e = PHI_ARG_EDGE (phi, i); + edge e = gimple_phi_arg_edge (phi, i); arg = PHI_ARG_DEF (phi, i); if (TREE_CODE (arg) == SSA_NAME) register_ssa_partition (map, arg); @@ -1024,27 +1027,29 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) bitmap_set_bit (used_in_copy, ver); } - for (bsi = bsi_start (bb); !bsi_end_p (bsi); bsi_next (&bsi)) + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { - stmt = bsi_stmt (bsi); + stmt = gsi_stmt (gsi); /* Register USE and DEF operands in each statement. */ FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, (SSA_OP_DEF|SSA_OP_USE)) register_ssa_partition (map, var); /* Check for copy coalesces. */ - switch (TREE_CODE (stmt)) + switch (gimple_code (stmt)) { - case GIMPLE_MODIFY_STMT: + case GIMPLE_ASSIGN: { - tree op1 = GIMPLE_STMT_OPERAND (stmt, 0); - tree op2 = GIMPLE_STMT_OPERAND (stmt, 1); - if (TREE_CODE (op1) == SSA_NAME - && TREE_CODE (op2) == SSA_NAME - && SSA_NAME_VAR (op1) == SSA_NAME_VAR (op2)) + tree lhs = gimple_assign_lhs (stmt); + tree rhs1 = gimple_assign_rhs1 (stmt); + + if (gimple_assign_copy_p (stmt) + && TREE_CODE (lhs) == SSA_NAME + && TREE_CODE (rhs1) == SSA_NAME + && SSA_NAME_VAR (lhs) == SSA_NAME_VAR (rhs1)) { - v1 = SSA_NAME_VERSION (op1); - v2 = SSA_NAME_VERSION (op2); + v1 = SSA_NAME_VERSION (lhs); + v2 = SSA_NAME_VERSION (rhs1); cost = coalesce_cost_bb (bb); add_coalesce (cl, v1, v2, cost); bitmap_set_bit (used_in_copy, v1); @@ -1053,24 +1058,31 @@ create_outofssa_var_map (coalesce_list_p cl, bitmap used_in_copy) } break; - case ASM_EXPR: + case GIMPLE_ASM: { unsigned long noutputs, i; + unsigned long ninputs; tree *outputs, link; - noutputs = list_length (ASM_OUTPUTS (stmt)); + noutputs = gimple_asm_noutputs (stmt); + ninputs = gimple_asm_ninputs (stmt); outputs = (tree *) alloca (noutputs * sizeof (tree)); - for (i = 0, link = ASM_OUTPUTS (stmt); link; - ++i, link = TREE_CHAIN (link)) + for (i = 0; i < noutputs; ++i) { + link = gimple_asm_output_op (stmt, i); outputs[i] = TREE_VALUE (link); + } - for (link = ASM_INPUTS (stmt); link; link = TREE_CHAIN (link)) + for (i = 0; i < ninputs; ++i) { - const char *constraint - = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link))); - tree input = TREE_VALUE (link); + const char *constraint; + tree input; char *end; unsigned long match; + link = gimple_asm_input_op (stmt, i); + constraint + = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (link))); + input = TREE_VALUE (link); + if (TREE_CODE (input) != SSA_NAME) continue; @@ -1247,7 +1259,7 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl, FILE *debug) { int x = 0, y = 0; - tree var1, var2, phi; + tree var1, var2; int cost; basic_block bb; edge e; @@ -1262,8 +1274,11 @@ coalesce_partitions (var_map map, ssa_conflicts_p graph, coalesce_list_p cl, FOR_EACH_EDGE (e, ei, bb->preds) if (e->flags & EDGE_ABNORMAL) { - for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi)) + gimple_stmt_iterator gsi; + for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); + gsi_next (&gsi)) { + gimple phi = gsi_stmt (gsi); tree res = PHI_RESULT (phi); tree arg = PHI_ARG_DEF (phi, e->dest_idx); int v1 = SSA_NAME_VERSION (res); @@ -1437,4 +1452,3 @@ coalesce_ssa_name (void) return map; } - |