diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-11 11:13:27 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-11 11:13:27 +0000 |
commit | c41143fb1d63596ff2a0f6da741b4bae73b8be16 (patch) | |
tree | d70c0763693cfef7bc877f21e079986944261a5f /gcc/sel-sched.c | |
parent | eb0badc13724022c8828a55e516d0eecdc487cc3 (diff) | |
download | gcc-c41143fb1d63596ff2a0f6da741b4bae73b8be16.tar.gz |
2011-05-11 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 173647 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@173652 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/sel-sched.c')
-rw-r--r-- | gcc/sel-sched.c | 89 |
1 files changed, 51 insertions, 38 deletions
diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c index e26ddac8fab..b176deaaef3 100644 --- a/gcc/sel-sched.c +++ b/gcc/sel-sched.c @@ -1263,17 +1263,12 @@ mark_unavailable_hard_regs (def_t def, struct reg_rename *reg_rename_p, FIXME: it is enough to do this once per all original defs. */ if (frame_pointer_needed) { - int i; - - for (i = hard_regno_nregs[FRAME_POINTER_REGNUM][Pmode]; i--;) - SET_HARD_REG_BIT (reg_rename_p->unavailable_hard_regs, - FRAME_POINTER_REGNUM + i); + add_to_hard_reg_set (®_rename_p->unavailable_hard_regs, + Pmode, FRAME_POINTER_REGNUM); -#if !HARD_FRAME_POINTER_IS_FRAME_POINTER - for (i = hard_regno_nregs[HARD_FRAME_POINTER_REGNUM][Pmode]; i--;) - SET_HARD_REG_BIT (reg_rename_p->unavailable_hard_regs, - HARD_FRAME_POINTER_REGNUM + i); -#endif + if (!HARD_FRAME_POINTER_IS_FRAME_POINTER) + add_to_hard_reg_set (®_rename_p->unavailable_hard_regs, + Pmode, HARD_FRAME_POINTER_IS_FRAME_POINTER); } #ifdef STACK_REGS @@ -2746,7 +2741,7 @@ compute_av_set_at_bb_end (insn_t insn, ilist_t p, int ws) sel_print ("real successors num: %d\n", sinfo->all_succs_n); } - /* Add insn to to the tail of current path. */ + /* Add insn to the tail of current path. */ ilist_add (&p, insn); FOR_EACH_VEC_ELT (rtx, sinfo->succs_ok, is, succ) @@ -5522,7 +5517,7 @@ fill_insns (fence_t fence, int seqno, ilist_t **scheduled_insns_tailpp) { blist_t *bnds_tailp1, *bndsp; expr_t expr_vliw; - int need_stall; + int need_stall = false; int was_stall = 0, scheduled_insns = 0; int max_insns = pipelining_p ? issue_rate : 2 * issue_rate; int max_stall = pipelining_p ? 1 : 3; @@ -6369,7 +6364,10 @@ code_motion_process_successors (insn_t insn, av_set_t orig_ops, the iterator becomes invalid. We need to try again. */ if (BLOCK_FOR_INSN (insn)->index != old_index || EDGE_COUNT (bb->succs) != old_succs) - goto rescan; + { + insn = sel_bb_end (BLOCK_FOR_INSN (insn)); + goto rescan; + } } #ifdef ENABLE_CHECKING @@ -6481,7 +6479,7 @@ code_motion_path_driver (insn_t insn, av_set_t orig_ops, ilist_t path, /* Filter the orig_ops set. */ if (AV_SET_VALID_P (insn)) - av_set_intersect (&orig_ops, AV_SET (insn)); + av_set_code_motion_filter (&orig_ops, AV_SET (insn)); /* If no more original ops, return immediately. */ if (!orig_ops) @@ -6587,21 +6585,37 @@ code_motion_path_driver (insn_t insn, av_set_t orig_ops, ilist_t path, if (!expr) { int res; + rtx last_insn = PREV_INSN (insn); + bool added_to_path; gcc_assert (insn == sel_bb_end (bb)); /* Add bb tail to PATH (but it doesn't make any sense if it's a bb_head - it's already in PATH then). */ if (insn != first_insn) - ilist_add (&path, insn); + { + ilist_add (&path, insn); + added_to_path = true; + } + else + added_to_path = false; /* Process_successors should be able to find at least one successor for which code_motion_path_driver returns TRUE. */ res = code_motion_process_successors (insn, orig_ops, path, static_params); + /* Jump in the end of basic block could have been removed or replaced + during code_motion_process_successors, so recompute insn as the + last insn in bb. */ + if (NEXT_INSN (last_insn) != insn) + { + insn = sel_bb_end (bb); + first_insn = sel_bb_head (bb); + } + /* Remove bb tail from path. */ - if (insn != first_insn) + if (added_to_path) ilist_remove (&path); if (res != 1) @@ -6731,15 +6745,14 @@ init_seqno_1 (basic_block bb, sbitmap visited_bbs, bitmap blocks_to_reschedule) INSN_SEQNO (insn) = cur_seqno--; } -/* Initialize seqnos for the current region. NUMBER_OF_INSNS is the number - of instructions in the region, BLOCKS_TO_RESCHEDULE contains blocks on - which we're rescheduling when pipelining, FROM is the block where +/* Initialize seqnos for the current region. BLOCKS_TO_RESCHEDULE contains + blocks on which we're rescheduling when pipelining, FROM is the block where traversing region begins (it may not be the head of the region when pipelining, but the head of the loop instead). Returns the maximal seqno found. */ static int -init_seqno (int number_of_insns, bitmap blocks_to_reschedule, basic_block from) +init_seqno (bitmap blocks_to_reschedule, basic_block from) { sbitmap visited_bbs; bitmap_iterator bi; @@ -6762,9 +6775,13 @@ init_seqno (int number_of_insns, bitmap blocks_to_reschedule, basic_block from) from = EBB_FIRST_BB (0); } - cur_seqno = number_of_insns > 0 ? number_of_insns : sched_max_luid - 1; + cur_seqno = sched_max_luid - 1; init_seqno_1 (from, visited_bbs, blocks_to_reschedule); - gcc_assert (cur_seqno == 0 || number_of_insns == 0); + + /* cur_seqno may be positive if the number of instructions is less than + sched_max_luid - 1 (when rescheduling or if some instructions have been + removed by the call to purge_empty_blocks in sel_sched_region_1). */ + gcc_assert (cur_seqno >= 0); sbitmap_free (visited_bbs); return sched_max_luid - 1; @@ -6778,7 +6795,8 @@ sel_setup_region_sched_flags (void) bookkeeping_p = 1; pipelining_p = (bookkeeping_p && (flag_sel_sched_pipelining != 0) - && current_loop_nest != NULL); + && current_loop_nest != NULL + && loop_has_exit_edges (current_loop_nest)); max_insns_to_rename = PARAM_VALUE (PARAM_SELSCHED_INSNS_TO_RENAME); max_ws = MAX_WS; } @@ -6797,7 +6815,7 @@ current_region_empty_p (void) /* Prepare and verify loop nest for pipelining. */ static void -setup_current_loop_nest (int rgn) +setup_current_loop_nest (int rgn, bb_vec_t *bbs) { current_loop_nest = get_loop_nest_for_rgn (rgn); @@ -6806,7 +6824,7 @@ setup_current_loop_nest (int rgn) /* If this loop has any saved loop preheaders from nested loops, add these basic blocks to the current region. */ - sel_add_loop_preheaders (); + sel_add_loop_preheaders (bbs); /* Check that we're starting with a valid information. */ gcc_assert (loop_latch_edge (current_loop_nest)); @@ -6845,11 +6863,6 @@ sel_region_init (int rgn) if (current_region_empty_p ()) return true; - if (flag_sel_sched_pipelining) - setup_current_loop_nest (rgn); - - sel_setup_region_sched_flags (); - bbs = VEC_alloc (basic_block, heap, current_nr_blocks); for (i = 0; i < current_nr_blocks; i++) @@ -6857,6 +6870,11 @@ sel_region_init (int rgn) sel_init_bbs (bbs, NULL); + if (flag_sel_sched_pipelining) + setup_current_loop_nest (rgn, &bbs); + + sel_setup_region_sched_flags (); + /* Initialize luids and dependence analysis which both sel-sched and haifa need. */ sched_init_luids (bbs, NULL, NULL, NULL); @@ -7473,17 +7491,12 @@ sel_sched_region_2 (int orig_max_seqno) static void sel_sched_region_1 (void) { - int number_of_insns; int orig_max_seqno; - /* Remove empty blocks that might be in the region from the beginning. - We need to do save sched_max_luid before that, as it actually shows - the number of insns in the region, and purge_empty_blocks can - alter it. */ - number_of_insns = sched_max_luid - 1; + /* Remove empty blocks that might be in the region from the beginning. */ purge_empty_blocks (); - orig_max_seqno = init_seqno (number_of_insns, NULL, NULL); + orig_max_seqno = init_seqno (NULL, NULL); gcc_assert (orig_max_seqno >= 1); /* When pipelining outer loops, create fences on the loop header, @@ -7560,7 +7573,7 @@ sel_sched_region_1 (void) { flist_tail_init (new_fences); - orig_max_seqno = init_seqno (0, blocks_to_reschedule, bb); + orig_max_seqno = init_seqno (blocks_to_reschedule, bb); /* Mark BB as head of the new ebb. */ bitmap_set_bit (forced_ebb_heads, bb->index); |