GCC Middle and Back End API Reference
cfgcleanup.c File Reference

Functions

static bool try_crossjump_to_edge (int, edge, edge, enum replace_direction)
static bool try_crossjump_bb (int, basic_block)
static bool outgoing_edges_match (int, basic_block, basic_block)
static enum replace_direction old_insns_match_p (int, rtx, rtx)
static void merge_blocks_move_predecessor_nojumps (basic_block, basic_block)
static void merge_blocks_move_successor_nojumps (basic_block, basic_block)
static bool try_optimize_cfg (int)
static bool try_simplify_condjump (basic_block)
static bool try_forward_edges (int, basic_block)
static edge thread_jump (edge, basic_block)
static bool mark_effect (rtx, bitmap)
static void notice_new_block (basic_block)
static void update_forwarder_flag (basic_block)
static int mentions_nonequal_regs (rtx *, void *)
static void merge_memattrs (rtx, rtx)
static void notice_new_block ()
static void update_forwarder_flag ()
static bool try_simplify_condjump ()
static bool mark_effect ()
static int mentions_nonequal_regs ()
static edge thread_jump ()
static bool try_forward_edges ()
static void merge_blocks_move_predecessor_nojumps ()
static void merge_blocks_move_successor_nojumps ()
static basic_block merge_blocks_move ()
void merge_memattrs ()
static bool equal_different_set_p ()
static enum replace_direction can_replace_by ()
static enum replace_direction merge_dir ()
static enum replace_direction old_insns_match_p ()
static void merge_notes ()
static void walk_to_nondebug_insn (rtx *i1, basic_block *bb1, bool follow_fallthru, bool *did_fallthru)
int flow_find_cross_jump (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2, enum replace_direction *dir_p)
int flow_find_head_matching_sequence (basic_block bb1, basic_block bb2, rtx *f1, rtx *f2, int stop_after)
static bool outgoing_edges_match ()
static bool block_has_preserve_label ()
static bool try_crossjump_bb ()
static bool try_head_merge_bb ()
static bool trivially_empty_bb_p ()
static bool try_optimize_cfg ()
bool delete_unreachable_blocks ()
void delete_dead_jumptables ()
bool cleanup_cfg ()
static unsigned int execute_jump ()
rtl_opt_passmake_pass_jump ()
static unsigned int execute_jump2 ()
rtl_opt_passmake_pass_jump2 ()

Variables

static bool first_pass
static bool crossjumps_occured
static bool block_was_dirty

Function Documentation

static bool block_has_preserve_label ( )
static
Returns true if BB basic block has a preserve label.   

References block_label().

Referenced by try_crossjump_to_edge().

static enum replace_direction can_replace_by ( )
static
Examine register notes on I1 and I2 and return:
   - dir_forward if I1 can be replaced by I2, or
   - dir_backward if I2 can be replaced by I1, or
   - dir_both if both are the case.   

References d1, d2, dir_backward, dir_both, dir_forward, dir_none, equal_different_set_p(), find_reg_equal_equiv_note(), reload_completed, rtx_equal_p(), and rtx_renumbered_equal_p().

Referenced by old_insns_match_p().

void delete_dead_jumptables ( void  )
Delete any jump tables never referenced.  We can't delete them at the
   time of removing tablejump insn as they are referenced by the preceding
   insns computing the destination, so we delay deleting and garbagecollect
   them once life information is computed.   

References delete_insn(), and dump_file.

Referenced by cfg_layout_finalize(), and cleanup_cfg().

static bool equal_different_set_p ( )
static
static unsigned int execute_jump ( )
static
static unsigned int execute_jump2 ( )
static

References cleanup_cfg().

int flow_find_cross_jump ( basic_block  bb1,
basic_block  bb2,
rtx f1,
rtx f2,
enum replace_direction dir_p 
)
Look through the insns at the end of BB1 and BB2 and find the longest
   sequence that are either equivalent, or allow forward or backward
   replacement.  Store the first insns for that sequence in *F1 and *F2 and
   return the sequence length.

   DIR_P indicates the allowed replacement direction on function entry, and
   the actual replacement direction on function exit.  If NULL, only equivalent
   sequences are allowed.

   To simplify callers of this function, if the blocks match exactly,
   store the head of the blocks in *F1 and *F2.   

References cc0_rtx, dir_backward, dir_both, dir_forward, dir_none, i1, i2, merge_dir(), merge_memattrs(), merge_notes(), old_insns_match_p(), onlyjump_p(), reg_mentioned_p(), returnjump_p(), sets_cc0_p(), side_effects_p(), simplejump_p(), and walk_to_nondebug_insn().

Referenced by cond_exec_process_if_block(), and try_crossjump_to_edge().

int flow_find_head_matching_sequence ( basic_block  bb1,
basic_block  bb2,
rtx f1,
rtx f2,
int  stop_after 
)
Like flow_find_cross_jump, except start looking for a matching sequence from
   the head of the two blocks.  Do not include jumps at the end.
   If STOP_AFTER is nonzero, stop after finding that many matching
   instructions.   

References cc0_rtx, dir_both, edge_def::flags, i1, i2, merge_memattrs(), merge_notes(), old_insns_match_p(), reg_mentioned_p(), sets_cc0_p(), and basic_block_def::succs.

Referenced by cond_exec_process_if_block(), and try_head_merge_bb().

rtl_opt_pass* make_pass_jump ( )
rtl_opt_pass* make_pass_jump2 ( )
static bool mark_effect ( rtx  ,
bitmap   
)
static

Referenced by thread_jump().

static bool mark_effect ( )
static
Attempt to prove that operation is NOOP using CSElib or mark the effect
   on register.  Used by jump threading.   

References bitmap_clear_bit(), bitmap_clear_range(), bitmap_set_bit(), bitmap_set_range(), pc_rtx, rtx_equal_for_cselib_p(), and SET.

static int mentions_nonequal_regs ( rtx ,
void *   
)
static

Referenced by thread_jump().

static int mentions_nonequal_regs ( )
static
Return nonzero if X is a register set in regset DATA.
   Called via for_each_rtx.   
static basic_block merge_blocks_move ( )
static
Attempt to merge basic blocks that are potentially non-adjacent.
   Return NULL iff the attempt failed, otherwise return basic block
   where cleanup_cfg should continue.  Because the merging commonly
   moves basic block away or introduces another optimization
   possibility, return basic block just before B so cleanup_cfg don't
   need to iterate.

   It may be good idea to return basic block before C in the case
   C has been moved after B and originally appeared earlier in the
   insn sequence, but we have no information available about the
   relative ordering of these two.  Hopefully it is not too common.   

References dump_file, find_fallthru_edge(), edge_def::flags, force_nonfallthru(), basic_block_def::index, loop::latch, basic_block_def::loop_father, merge_blocks(), merge_blocks_move_predecessor_nojumps(), merge_blocks_move_successor_nojumps(), basic_block_def::next_bb, notice_new_block(), basic_block_def::preds, basic_block_def::prev_bb, edge_def::src, basic_block_def::succs, and update_forwarder_flag().

Referenced by try_optimize_cfg().

static void merge_blocks_move_predecessor_nojumps ( basic_block  ,
basic_block   
)
static

Referenced by merge_blocks_move().

static void merge_blocks_move_predecessor_nojumps ( )
static
Blocks A and B are to be merged into a single block.  A has no incoming
   fallthru edge, so it can be moved before B without adding or modifying
   any jumps (aside from the jump from A to B).   

References delete_insn(), df_set_bb_dirty(), dump_file, basic_block_def::index, link_block(), merge_blocks(), next_nonnote_insn(), basic_block_def::prev_bb, reorder_insns_nobb(), and unlink_block().

static void merge_blocks_move_successor_nojumps ( basic_block  ,
basic_block   
)
static

Referenced by merge_blocks_move().

static void merge_blocks_move_successor_nojumps ( )
static
Blocks A and B are to be merged into a single block.  B has no outgoing
   fallthru edge, so it can be moved after A without adding or modifying
   any jumps (aside from the jump from A to B).   

References delete_insn(), dump_file, basic_block_def::index, merge_blocks(), prev_active_insn(), reorder_insns_nobb(), table, and tablejump_p().

static enum replace_direction merge_dir ( )
static
Merges directions A and B.   

References dir_both, and dir_none.

Referenced by flow_find_cross_jump().

static void merge_memattrs ( rtx  ,
rtx   
)
static
void merge_memattrs ( )
Removes the memory attributes of MEM expression
   if they are not equal.   

References clear_mem_offset(), clear_mem_size(), HOST_WIDE_INT, mem_expr_equal_p(), merge_memattrs(), set_mem_alias_set(), set_mem_align(), set_mem_expr(), and set_mem_size().

static void merge_notes ( )
static
When comparing insns I1 and I2 in flow_find_cross_jump or
   flow_find_head_matching_sequence, ensure the notes match.   

References find_reg_equal_equiv_note(), remove_note(), and rtx_equal_p().

Referenced by flow_find_cross_jump(), and flow_find_head_matching_sequence().

static void notice_new_block ( basic_block  )
static
static void notice_new_block ( )
static
Set flags for newly created block.   

References basic_block_def::flags, and forwarder_block_p().

static enum replace_direction old_insns_match_p ( int  ,
rtx  ,
rtx   
)
static
static enum replace_direction old_insns_match_p ( )
static
Examine I1 and I2 and return:
   - dir_forward if I1 can be replaced by I2, or
   - dir_backward if I2 can be replaced by I1, or
   - dir_both if both are the case.   

References BUILT_IN_NORMAL, can_replace_by(), dir_both, dir_none, find_args_size_adjust(), find_reg_note(), get_call_rtx_from(), hard_reg_set_equal_p(), HOST_WIDE_INT_MIN, reload_completed, rtx_equal_p(), rtx_renumbered_equal_p(), and stack_regs_mentioned().

static bool outgoing_edges_match ( int  ,
basic_block  ,
basic_block   
)
static

Referenced by try_crossjump_to_edge().

static bool outgoing_edges_match ( )
static
static edge thread_jump ( edge  ,
basic_block   
)
static

Referenced by try_forward_edges().

static edge thread_jump ( )
static
Attempt to prove that the basic block B will have no side effects and
   always continues in the same edge if reached via E.  Return the edge
   if exist, NULL otherwise.   

References any_condjump_p(), comparison_dominates_p(), cselib_finish(), cselib_init(), cselib_process_insn(), edge_def::flags, basic_block_def::flags, for_each_rtx(), mark_effect(), mentions_nonequal_regs(), onlyjump_p(), pc_rtx, pc_set(), reversed_comparison_code(), rtx_equal_p(), side_effects_p(), edge_def::src, and basic_block_def::succs.

static bool trivially_empty_bb_p ( )
static
Return true if BB contains just bb note, or bb note followed
   by only DEBUG_INSNs.   

Referenced by try_optimize_cfg().

static bool try_crossjump_bb ( int  ,
basic_block   
)
static

Referenced by try_optimize_cfg().

static bool try_crossjump_bb ( )
static
Search the predecessors of BB for common insn sequences.  When found,
   share code between them by redirecting control flow.  Return true if
   any changes made.   

References changed, computed_jump_p(), crossjumps_occured, dir_both, dir_forward, find_fallthru_edge(), first_pass, basic_block_def::flags, basic_block_def::index, optimize_bb_for_size_p(), basic_block_def::preds, edge_def::src, and try_crossjump_to_edge().

static bool try_crossjump_to_edge ( int  mode,
edge  e1,
edge  e2,
enum replace_direction  dir 
)
static
static bool try_forward_edges ( int  ,
basic_block   
)
static

Referenced by try_optimize_cfg().

static bool try_optimize_cfg ( int  )
static

Referenced by cleanup_cfg().

static bool try_simplify_condjump ( basic_block  )
static

Referenced by try_optimize_cfg().

static void update_forwarder_flag ( basic_block  )
static
static void update_forwarder_flag ( )
static
Recompute forwarder flag after block has been modified.   

References basic_block_def::flags, and forwarder_block_p().

static void walk_to_nondebug_insn ( rtx i1,
basic_block bb1,
bool  follow_fallthru,
bool *  did_fallthru 
)
static

Variable Documentation

bool block_was_dirty
static
Set to true if we couldn't run an optimization due to stale liveness
   information; we should run df_analyze to enable more opportunities.   

Referenced by try_head_merge_bb(), and try_optimize_cfg().

bool crossjumps_occured
static
Set to true if crossjumps occurred in the latest run of try_optimize_cfg.   

Referenced by cleanup_cfg(), try_crossjump_bb(), try_head_merge_bb(), and try_optimize_cfg().

bool first_pass
static
Set to true when we are running first pass of try_optimize_cfg loop.   

Referenced by try_crossjump_bb(), try_forward_edges(), and try_optimize_cfg().