diff options
author | Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> | 2002-05-23 21:23:51 +0200 |
---|---|---|
committer | Zdenek Dvorak <rakdver@gcc.gnu.org> | 2002-05-23 19:23:51 +0000 |
commit | e0082a72651ae718c46e4f3510bba4a116148fc7 (patch) | |
tree | d9ef360c452a150ca3f25a23e593846ce26b64f0 /gcc/predict.c | |
parent | 17645b154d8a32a6fad15296e1030d06f5a0456b (diff) | |
download | gcc-e0082a72651ae718c46e4f3510bba4a116148fc7.zip gcc-e0082a72651ae718c46e4f3510bba4a116148fc7.tar.gz gcc-e0082a72651ae718c46e4f3510bba4a116148fc7.tar.bz2 |
bb-reorder.c (make_reorder_chain, [...]): Use FOR_EACH_BB macros to iterate over basic block chain.
* bb-reorder.c (make_reorder_chain, make_reorder_chain_1):
Use FOR_EACH_BB macros to iterate over basic block chain.
* cfg.c (clear_edges, clear_bb_flags, dump_flow_info,
alloc_aux_for_blocks, clear_aux_for_blocks, alloc_aux_for_edges):
Likewise.
* cfganal.c (set_edge_can_fallthru_flag, flow_call_edges_add,
find_unreachable_blocks, create_edge_list, verify_edge_list,
remove_fake_edges, add_noreturn_fake_exit_edges,
flow_preorder_transversal_compute, flow_dfs_compute_reverse_execute):
Likewise.
* cfgbuild.c (make_edges, find_basic_blocks, find_many_sub_basic_blocks,
find_sub_basic_blocks): Likewise.
* cfgcleanup.c (try_optimize_cfg, delete_unreachable_blocks):
Likewise.
* cfglayout.c (record_effective_endpoints, cleanup_unconditional_jumps):
Likewise.
* cfgloop.c (flow_loops_cfg_dump, flow_loops_find):
Likewise.
* cfgrtl.c (compute_bb_for_insn, tidy_fallthru_edges,
commit_edge_insertions, commit_edge_insertions_watch_calls,
print_rtl_with_bb, verify_flow_info, purge_all_dead_edges): Likewise.
* combine.c (combine_instructions, reg_dead_at_p): Likewise.
* conflict.c (conflict_graph_compute): Likewise.
* df.c (df_bitmaps_alloc, df_bitmaps_free, df_alloc, df_analyse_1,
df_modified_p, df_refs_unlink, df_dump): Likewise.
* dominance.c (calc_dfs_tree, calculate_dominance_info): Likewise.
* final.c (compute_alignments): Likewise.
* flow.c (update_life_info, update_life_info_in_dirty_blocks,
delete_noop_moves, calculate_global_regs_live, allocate_bb_life_data,
count_or_remove_death_notes): Likewise.
* gcse.c (oprs_unchanged_p, record_last_reg_set_info,
compute_hash_table, compute_kill_rd, compute_rd, compute_ae_kill,
classic_gcse, compute_transp, cprop, compute_pre_data,
compute_transpout, invalidate_nonnull_info,
delete_null_pointer_checks_1, delete_null_pointer_checks,
compute_code_hoist_vbeinout, hoist_code, compute_ld_motion_mems,
compute_store_table, build_store_vectors, store_motion): Likewise.
* global.c (global_conflicts, mark_elimination): Likewise.
* graph.c (print_rtl_graph_with_bb): Likewise.
* haifa-sched.c (sched_init): Likewise.
* ifcvt.c (if_convert): Likewise.
* lcm.c (compute_antinout_edge, compute_laterin, compute_insert_delete,
compute_available, compute_nearerout, compute_rev_insert_delete,
optimize_mode_switching): Likewise.
* local-alloc.c (local_alloc, update_equiv_regs): Likewise.
* predict.c (estimate_probability, note_prediction_to_br_prob,
propagate_freq, counts_to_freqs, expensive_function_p,
estimate_bb_frequencies): Likewise.
* profile.c (instrument_edges, get_exec_counts,
compute_branch_probabilities, compute_checksum, branch_prob,
find_spanning_tree): Likewise.
* recog.c (split_all_insns, peephole2_optimize): Likewise.
* reg-stack.c (reg_to_stack, convert_regs_entry, convert_regs):
Likewise.
* regclass.c (scan_one_insn, regclass): Likewise.
* regmove.c (mark_flags_life_zones, regmove_optimize,
record_stack_memrefs): Likewise.
* regrename.c (regrename_optimize, copyprop_hardreg_forward): Likewise.
* reload1.c (reload, reload_combine, fixup_abnormal_edges): Likewise.
* resource.c (find_basic_block): Likewise.
* sched-ebb.c (schedule_ebbs): Likewise.
* sched-rgn.c (is_cfg_nonregular, build_control_flow,
find_single_block_region, find_rgns, schedule_insns)
* sibcall.c (optimize_sibling_and_tail_recursive_call)
* ssa-ccp.c (optimize_unexecutable_edges,
ssa_ccp_df_delete_unreachable_insns): Likewise.
* ssa-dce.c (ssa_eliminate_dead_code): Likewise.
* ssa.c (find_evaluations, compute_dominance_frontiers_1,
rename_block, convert_to_ssa, compute_conservative_reg_partition,
compute_coalesced_reg_partition, rename_equivalent_regs,
convert_from_ssa): Likewise.
* config/ia64/ia64.c (emit_predicate_relation_info, process_epilogue,
process_for_unwind_directive): Likewise.
* df.c (FOR_ALL_BBS): Removed.
* gcse.c (struct null_pointer_info): Type of current_block field
changed.
(struct reg_avail_info): Type of last_bb field changed.
* config/ia64/ia64.c (block_num): Removed.
(need_copy_state): Type changed.
(last_block): New.
From-SVN: r53804
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 120 |
1 files changed, 43 insertions, 77 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index ce8ed2d..4f53a99 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -409,6 +409,7 @@ estimate_probability (loops_info) struct loops *loops_info; { sbitmap *dominators, *post_dominators; + basic_block bb; int i; dominators = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks); @@ -420,15 +421,14 @@ estimate_probability (loops_info) natural loop. */ for (i = 0; i < loops_info->num; i++) { - int j; int exits; struct loop *loop = &loops_info->array[i]; flow_loop_scan (loops_info, loop, LOOP_EXIT_EDGES); exits = loop->num_exits; - for (j = loop->first->index; j <= loop->last->index; ++j) - if (TEST_BIT (loop->nodes, j)) + FOR_BB_BETWEEN (bb, loop->first, loop->last->next_bb, next_bb) + if (TEST_BIT (loop->nodes, bb->index)) { int header_found = 0; edge e; @@ -437,12 +437,12 @@ estimate_probability (loops_info) statements construct loops via "non-loop" constructs in the source language and are better to be handled separately. */ - if (predicted_by_p (BASIC_BLOCK (j), PRED_CONTINUE)) + if (predicted_by_p (bb, PRED_CONTINUE)) continue; /* Loop branch heuristics - predict an edge back to a loop's head as taken. */ - for (e = BASIC_BLOCK(j)->succ; e; e = e->succ_next) + for (e = bb->succ; e; e = e->succ_next) if (e->dest == loop->header && e->src == loop->latch) { @@ -453,7 +453,7 @@ estimate_probability (loops_info) /* Loop exit heuristics - predict an edge exiting the loop if the conditinal has no loop header successors as not taken. */ if (!header_found) - for (e = BASIC_BLOCK(j)->succ; e; e = e->succ_next) + for (e = bb->succ; e; e = e->succ_next) if (e->dest->index < 0 || !TEST_BIT (loop->nodes, e->dest->index)) predict_edge @@ -465,9 +465,8 @@ estimate_probability (loops_info) } /* Attempt to predict conditional jumps using a number of heuristics. */ - for (i = 0; i < n_basic_blocks; i++) + FOR_EACH_BB (bb) { - basic_block bb = BASIC_BLOCK (i); rtx last_insn = bb->end; rtx cond, earliest; edge e; @@ -604,11 +603,11 @@ estimate_probability (loops_info) } /* Attach the combined probability to each conditional jump. */ - for (i = 0; i < n_basic_blocks; i++) - if (GET_CODE (BLOCK_END (i)) == JUMP_INSN - && any_condjump_p (BLOCK_END (i)) - && BASIC_BLOCK (i)->succ->succ_next != NULL) - combine_predictions_for_insn (BLOCK_END (i), BASIC_BLOCK (i)); + FOR_EACH_BB (bb) + if (GET_CODE (bb->end) == JUMP_INSN + && any_condjump_p (bb->end) + && bb->succ->succ_next != NULL) + combine_predictions_for_insn (bb->end, bb); sbitmap_vector_free (post_dominators); sbitmap_vector_free (dominators); @@ -834,7 +833,7 @@ process_note_predictions (bb, heads, dominators, post_dominators) void note_prediction_to_br_prob () { - int i; + basic_block bb; sbitmap *post_dominators; int *dominators, *heads; @@ -854,11 +853,8 @@ note_prediction_to_br_prob () /* Process all prediction notes. */ - for (i = 0; i < n_basic_blocks; ++i) - { - basic_block bb = BASIC_BLOCK (i); - process_note_predictions (bb, heads, dominators, post_dominators); - } + FOR_EACH_BB (bb) + process_note_predictions (bb, heads, dominators, post_dominators); sbitmap_vector_free (post_dominators); free (dominators); @@ -906,17 +902,15 @@ static void propagate_freq (head) basic_block head; { - basic_block bb = head; - basic_block last = bb; + basic_block bb; + basic_block last; edge e; basic_block nextbb; - int n; /* For each basic block we need to visit count number of his predecessors we need to visit first. */ - for (n = 0; n < n_basic_blocks; n++) + FOR_EACH_BB (bb) { - basic_block bb = BASIC_BLOCK (n); if (BLOCK_INFO (bb)->tovisit) { int count = 0; @@ -934,7 +928,8 @@ propagate_freq (head) } memcpy (&BLOCK_INFO (head)->frequency, &real_one, sizeof (real_one)); - for (; bb; bb = nextbb) + last = head; + for (bb = head; bb; bb = nextbb) { REAL_VALUE_TYPE cyclic_probability, frequency; @@ -1077,24 +1072,13 @@ static void counts_to_freqs () { HOST_WIDEST_INT count_max = 1; - int i; + basic_block bb; - for (i = 0; i < n_basic_blocks; i++) - count_max = MAX (BASIC_BLOCK (i)->count, count_max); + FOR_EACH_BB (bb) + count_max = MAX (bb->count, count_max); - for (i = -2; i < n_basic_blocks; i++) - { - basic_block bb; - - if (i == -2) - bb = ENTRY_BLOCK_PTR; - else if (i == -1) - bb = EXIT_BLOCK_PTR; - else - bb = BASIC_BLOCK (i); - - bb->frequency = (bb->count * BB_FREQ_MAX + count_max / 2) / count_max; - } + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) + bb->frequency = (bb->count * BB_FREQ_MAX + count_max / 2) / count_max; } /* Return true if function is likely to be expensive, so there is no point to @@ -1107,7 +1091,7 @@ expensive_function_p (threshold) int threshold; { unsigned int sum = 0; - int i; + basic_block bb; unsigned int limit; /* We can not compute accurately for large thresholds due to scaled @@ -1123,9 +1107,8 @@ expensive_function_p (threshold) /* Maximally BB_FREQ_MAX^2 so overflow won't happen. */ limit = ENTRY_BLOCK_PTR->frequency * threshold; - for (i = 0; i < n_basic_blocks; i++) + FOR_EACH_BB (bb) { - basic_block bb = BASIC_BLOCK (i); rtx insn; for (insn = bb->head; insn != NEXT_INSN (bb->end); @@ -1147,7 +1130,7 @@ static void estimate_bb_frequencies (loops) struct loops *loops; { - int i; + basic_block bb; REAL_VALUE_TYPE freq_max; enum machine_mode double_mode = TYPE_MODE (double_type_node); @@ -1169,13 +1152,13 @@ estimate_bb_frequencies (loops) mark_dfs_back_edges (); /* Fill in the probability values in flowgraph based on the REG_BR_PROB notes. */ - for (i = 0; i < n_basic_blocks; i++) + FOR_EACH_BB (bb) { - rtx last_insn = BLOCK_END (i); + rtx last_insn = bb->end; if (GET_CODE (last_insn) != JUMP_INSN || !any_condjump_p (last_insn) /* Avoid handling of conditional jumps jumping to fallthru edge. */ - || BASIC_BLOCK (i)->succ->succ_next == NULL) + || bb->succ->succ_next == NULL) { /* We can predict only conditional jumps at the moment. Expect each edge to be equally probable. @@ -1183,14 +1166,14 @@ estimate_bb_frequencies (loops) int nedges = 0; edge e; - for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next) + for (e = bb->succ; e; e = e->succ_next) { nedges++; if (e->probability != 0) break; } if (!e) - for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next) + for (e = bb->succ; e; e = e->succ_next) e->probability = (REG_BR_PROB_BASE + nedges / 2) / nedges; } } @@ -1200,22 +1183,13 @@ estimate_bb_frequencies (loops) /* Set up block info for each basic block. */ alloc_aux_for_blocks (sizeof (struct block_info_def)); alloc_aux_for_edges (sizeof (struct edge_info_def)); - for (i = -2; i < n_basic_blocks; i++) + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) { edge e; - basic_block bb; - - if (i == -2) - bb = ENTRY_BLOCK_PTR; - else if (i == -1) - bb = EXIT_BLOCK_PTR; - else - bb = BASIC_BLOCK (i); BLOCK_INFO (bb)->tovisit = 0; for (e = bb->succ; e; e = e->succ_next) { - REAL_VALUE_FROM_INT (EDGE_INFO (e)->back_edge_prob, e->probability, 0, double_mode); REAL_ARITHMETIC (EDGE_INFO (e)->back_edge_prob, @@ -1229,32 +1203,24 @@ estimate_bb_frequencies (loops) estimate_loops_at_level (loops->tree_root); /* Now fake loop around whole function to finalize probabilities. */ - for (i = 0; i < n_basic_blocks; i++) - BLOCK_INFO (BASIC_BLOCK (i))->tovisit = 1; + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) + BLOCK_INFO (bb)->tovisit = 1; BLOCK_INFO (ENTRY_BLOCK_PTR)->tovisit = 1; BLOCK_INFO (EXIT_BLOCK_PTR)->tovisit = 1; propagate_freq (ENTRY_BLOCK_PTR); memcpy (&freq_max, &real_zero, sizeof (real_zero)); - for (i = 0; i < n_basic_blocks; i++) + FOR_EACH_BB (bb) if (REAL_VALUES_LESS - (freq_max, BLOCK_INFO (BASIC_BLOCK (i))->frequency)) - memcpy (&freq_max, &BLOCK_INFO (BASIC_BLOCK (i))->frequency, + (freq_max, BLOCK_INFO (bb)->frequency)) + memcpy (&freq_max, &BLOCK_INFO (bb)->frequency, sizeof (freq_max)); - for (i = -2; i < n_basic_blocks; i++) + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) { - basic_block bb; REAL_VALUE_TYPE tmp; - if (i == -2) - bb = ENTRY_BLOCK_PTR; - else if (i == -1) - bb = EXIT_BLOCK_PTR; - else - bb = BASIC_BLOCK (i); - REAL_ARITHMETIC (tmp, MULT_EXPR, BLOCK_INFO (bb)->frequency, real_bb_freq_max); REAL_ARITHMETIC (tmp, RDIV_EXPR, tmp, freq_max); @@ -1274,14 +1240,14 @@ estimate_bb_frequencies (loops) static void compute_function_frequency () { - int i; + basic_block bb; + if (!profile_info.count_profiles_merged || !flag_branch_probabilities) return; cfun->function_frequency = FUNCTION_FREQUENCY_UNLIKELY_EXECUTED; - for (i = 0; i < n_basic_blocks; i++) + FOR_EACH_BB (bb) { - basic_block bb = BASIC_BLOCK (i); if (maybe_hot_bb_p (bb)) { cfun->function_frequency = FUNCTION_FREQUENCY_HOT; |