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

Functions

static void init_label_info (rtx)
static void mark_all_labels (rtx)
static void mark_jump_label_1 (rtx, rtx, bool, bool)
static void mark_jump_label_asm (rtx, rtx)
static void redirect_exp_1 (rtx *, rtx, rtx, rtx)
static int invert_exp_1 (rtx, rtx)
static int returnjump_p_1 (rtx *, void *)
static void rebuild_jump_labels_1 ()
void rebuild_jump_labels ()
void rebuild_jump_labels_chain ()
static unsigned int cleanup_barriers ()
rtl_opt_passmake_pass_cleanup_barriers ()
static void init_label_info ()
static void maybe_propagate_label_ref ()
static void mark_all_labels ()
enum rtx_code reversed_comparison_code_parts (enum rtx_code code, const_rtx arg0, const_rtx arg1, const_rtx insn)
enum rtx_code reversed_comparison_code ()
rtx reversed_comparison ()
enum rtx_code reverse_condition ()
enum rtx_code reverse_condition_maybe_unordered ()
enum rtx_code swap_condition ()
enum rtx_code unsigned_condition ()
enum rtx_code signed_condition ()
int comparison_dominates_p ()
int simplejump_p ()
int condjump_p ()
int condjump_in_parallel_p ()
rtx pc_set ()
int any_uncondjump_p ()
int any_condjump_p ()
rtx condjump_label ()
static int returnjump_p_1 ()
int returnjump_p ()
static int eh_returnjump_p_1 ()
int eh_returnjump_p ()
int onlyjump_p ()
bool jump_to_label_p ()
int only_sets_cc0_p ()
int sets_cc0_p ()
void mark_jump_label ()
static void mark_jump_label_1 ()
static void mark_jump_label_asm ()
rtx delete_related_insns ()
void delete_for_peephole ()
static rtx redirect_target ()
static void redirect_exp_1 ()
int redirect_jump_1 ()
int redirect_jump ()
void redirect_jump_2 (rtx jump, rtx olabel, rtx nlabel, int delete_unused, int invert)
static int invert_exp_1 ()
int invert_jump_1 ()
int invert_jump ()
int rtx_renumbered_equal_p ()
int true_regnum ()
unsigned int reg_or_subregno ()

Function Documentation

int any_uncondjump_p ( )
Return true when insn is an unconditional direct jump,
   possibly bundled inside a PARALLEL.   

References find_reg_note(), and pc_set().

Referenced by add_test(), emit(), find_dead_or_set_registers(), follow_jumps(), rtl_block_empty_p(), rtl_tidy_fallthru_edge(), rtl_verify_edges(), and try_combine().

static unsigned int cleanup_barriers ( )
static
Some old code expects exactly one BARRIER as the NEXT_INSN of a
   non-fallthru insn.  This is not generally true, as multiple barriers
   may have crept in, or the BARRIER may be separated from the last
   real insn by one or more NOTEs.

   This simple pass moves barriers and removes duplicates so that the
   old code is happy.

References delete_insn(), get_insns(), prev_nonnote_insn(), and reorder_insns_nobb().

int comparison_dominates_p ( )
Return nonzero if CODE1 is more strict than CODE2, i.e., if the
   truth of CODE1 implies the truth of CODE2.   

Referenced by condition_dominates_p(), fold_rtx(), known_cond(), and thread_jump().

int condjump_in_parallel_p ( )
Return nonzero if INSN is a (possibly) conditional jump inside a
   PARALLEL.

   Use this function is deprecated, since we need to support combined
   branch and compare insns.  Use any_condjump_p instead whenever possible.   

References pc_rtx, and SET.

Referenced by dbr_schedule(), fill_eager_delay_slots(), fill_simple_delay_slots(), get_branch_condition(), get_jump_flags(), relax_delay_slots(), and reload_combine().

rtx condjump_label ( )
Return the label of a conditional jump.   

References pc_rtx, and pc_set().

int condjump_p ( )
Return nonzero if INSN is a (possibly) conditional jump
   and nothing more.

   Use of this function is deprecated, since we need to support combined
   branch and compare insns.  Use any_condjump_p instead whenever possible.   

References SET.

Referenced by convert_jumps_to_returns(), cse_insn(), dbr_schedule(), fill_eager_delay_slots(), fill_simple_delay_slots(), get_jump_flags(), relax_delay_slots(), reload_combine(), and rtl_verify_bb_layout().

void delete_for_peephole ( )
Delete a range of insns from FROM to TO, inclusive.
   This is for the sake of peephole optimization, so assume
   that whatever these insns do will still be done by a new
   peephole insn that will replace them.   
rtx delete_related_insns ( )
Delete insn INSN from the chain of insns and update label ref counts
   and delete insns now unreachable.

   Returns the first insn after INSN that was not deleted.

   Usage of this instruction is deprecated.  Use delete_insn instead and
   subsequent cfg_cleanup pass to delete unreachable code if needed.   

References delete_insn(), jump_to_label_p(), len, remove_insn(), and tablejump_p().

Referenced by dbr_schedule(), delete_address_reloads(), delete_computation(), delete_from_delay_slot(), delete_scheduled_jump(), fill_simple_delay_slots(), fill_slots_from_thread(), make_return_insns(), optimize_skip(), redirect_jump_2(), relax_delay_slots(), and try_merge_delay_insns().

int eh_returnjump_p ( )
static int eh_returnjump_p_1 ( )
static
Return true if INSN is a (possibly conditional) return insn.   

Referenced by eh_returnjump_p().

static void init_label_info ( rtx  )
static
@verbatim Optimize jump instructions, for GNU compiler.

Copyright (C) 1987-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.

This is the pathetic reminder of old fame of the jump-optimization pass
   of the compiler.  Now it contains basically a set of utility functions to
   operate with jumps.

   Each CODE_LABEL has a count of the times it is used
   stored in the LABEL_NUSES internal field, and each JUMP_INSN
   has one label that it refers to stored in the
   JUMP_LABEL internal field.  With this we can detect labels that
   become unused because of the deletion of all the jumps that
   formerly used them.  The JUMP_LABEL info is sometimes looked
   at by later passes.  For return insns, it contains either a
   RETURN or a SIMPLE_RETURN rtx.

   The subroutines redirect_jump and invert_jump are used
   from other passes as well.   
Optimize jump y; x: ... y: jumpif... x?
   Don't know if it is worth bothering with.   
Optimize two cases of conditional jump to conditional jump?
   This can never delete any instruction or make anything dead,
   or even change what is live at any point.
   So perhaps let combiner do it.   

Referenced by rebuild_jump_labels_1().

static void init_label_info ( )
static
Initialize LABEL_NUSES and JUMP_LABEL fields, add REG_LABEL_TARGET
   for remaining targets for JUMP_P.  Delete any REG_LABEL_OPERAND
   notes whose labels don't occur in the insn any more.   

References reg_mentioned_p(), and remove_note().

static int invert_exp_1 ( rtx  ,
rtx   
)
static

Referenced by invert_jump_1(), and redirect_jump_2().

static int invert_exp_1 ( )
static
Invert the jump condition X contained in jump insn INSN.  Accrue the
   modifications into the change group.  Return nonzero for success.   

References comp, reversed_comparison_code(), and validate_change().

int invert_jump ( )
Invert the condition of the jump JUMP, and make it jump to label
   NLABEL instead of where it jumps now.  Return true if successful.   

References apply_change_group(), cancel_changes(), invert_jump_1(), and redirect_jump_2().

Referenced by fix_up_fall_thru_edges(), fixup_reorder_chain(), optimize_skip(), relax_delay_slots(), set_edge_can_fallthru_flag(), and try_simplify_condjump().

int invert_jump_1 ( )
Invert the condition of the jump JUMP, and make it jump to label
   NLABEL instead of where it jumps now.  Accrue changes into the
   change group.  Return false if we didn't see how to perform the
   inversion and redirection.   

References invert_exp_1(), num_validated_changes(), pc_set(), and redirect_jump_1().

Referenced by dead_or_predicable(), and invert_jump().

bool jump_to_label_p ( )
Return true iff INSN is a jump and its JUMP_LABEL is a label, not
   NULL or a return.   

Referenced by delete_related_insns(), fill_simple_delay_slots(), fill_slots_from_thread(), and make_return_insns().

rtl_opt_pass* make_pass_cleanup_barriers ( )
static void mark_all_labels ( rtx  )
static

Referenced by rebuild_jump_labels_1().

static void mark_all_labels ( )
static
Mark the label each jump jumps to.
   Combine consecutive labels, and count uses of labels.   

References current_ir_type(), IR_RTL_CFGLAYOUT, mark_jump_label(), and maybe_propagate_label_ref().

void mark_jump_label ( )
Find all CODE_LABELs referred to in X, and increment their use
   counts.  If INSN is a JUMP_INSN and there is at least one
   CODE_LABEL referenced in INSN as a jump target, then store the last
   one in JUMP_LABEL (INSN).  For a tablejump, this must be the label
   for the ADDR_VEC.  Store any other jump targets as REG_LABEL_TARGET
   notes.  If INSN is an INSN or a CALL_INSN or non-target operands of
   a JUMP_INSN, and there is at least one CODE_LABEL referenced in
   INSN, add a REG_LABEL_OPERAND note containing that label to INSN.
   For returnjumps, the JUMP_LABEL will also be set as appropriate.

   Note that two labels separated by a loop-beginning note
   must be kept distinct if we have not yet done loop-optimization,
   because the gap between them is where loop-optimize
   will want to move invariant code to.  CROSS_JUMP tells us
   that loop-optimization is done with.   

References extract_asm_operands(), mark_jump_label_1(), and mark_jump_label_asm().

Referenced by emit_copy_of_insn_after(), gen_reload(), mark_all_labels(), mark_jump_label_1(), try_combine(), and try_split().

static void mark_jump_label_1 ( rtx  ,
rtx  ,
bool  ,
bool   
)
static
static void mark_jump_label_1 ( )
static
Worker function for mark_jump_label.  IN_MEM is TRUE when X occurs
   within a (MEM ...).  IS_TARGET is TRUE when X is to be treated as a
   jump-target; when the JUMP_LABEL field of INSN should be set or a
   REG_LABEL_TARGET note should be added, not a REG_LABEL_OPERAND
   note.   

References add_reg_note(), find_reg_note(), get_pool_constant(), mark_jump_label(), and mark_jump_label_1().

static void mark_jump_label_asm ( rtx  ,
rtx   
)
static

Referenced by mark_jump_label().

static void mark_jump_label_asm ( )
static
Worker function for mark_jump_label.  Handle asm insns specially.
   In particular, output operands need not be considered so we can
   avoid re-scanning the replicated asm_operand.  Also, the asm_labels
   need to be considered targets.   

References mark_jump_label_1().

static void maybe_propagate_label_ref ( )
static
A subroutine of mark_all_labels.  Trivially propagate a simple label
   load into a jump_insn that uses it.   

References find_reg_note(), mark_jump_label_1(), pc_set(), and rtx_equal_p().

Referenced by mark_all_labels().

int only_sets_cc0_p ( )
Return nonzero if X is an RTX that only sets the condition codes
   and has no side effects.   

References sets_cc0_p(), and side_effects_p().

Referenced by rtl_merge_blocks(), rtl_tidy_fallthru_edge(), and try_redirect_by_replacing_jump().

void rebuild_jump_labels ( )
This function rebuilds the JUMP_LABEL field and REG_LABEL_TARGET
   notes in jumping insns and REG_LABEL_OPERAND notes in non-jumping
   instructions and jumping insns that have labels as operands
   (e.g. cbranchsi4).   

References rebuild_jump_labels_1().

Referenced by break_superblocks(), cfg_layout_finalize(), gimple_expand_cfg(), ira(), peephole2_optimize(), rest_of_handle_combine(), rest_of_handle_cse(), rest_of_handle_cse2(), rest_of_handle_cse_after_global_opts(), and rest_of_handle_gcse2().

static void rebuild_jump_labels_1 ( )
static
Worker for rebuild_jump_labels and rebuild_jump_labels_chain.   

References init_label_info(), mark_all_labels(), timevar_pop(), and timevar_push().

Referenced by rebuild_jump_labels(), and rebuild_jump_labels_chain().

void rebuild_jump_labels_chain ( )
This function is like rebuild_jump_labels, but doesn't run over
   forced_labels.  It can be used on insn chains that aren't the 
   main function chain.   

References rebuild_jump_labels_1().

Referenced by gimple_expand_cfg().

static void redirect_exp_1 ( rtx ,
rtx  ,
rtx  ,
rtx   
)
static
static void redirect_exp_1 ( )
static
Throughout LOC, redirect OLABEL to NLABEL.  Treat null OLABEL or
   NLABEL as a return.  Accrue modifications into the change group.   

References pc_rtx, redirect_exp_1(), redirect_target(), SET, and validate_change().

int redirect_jump ( )
Make JUMP go to NLABEL instead of where it jumps now.  If the old
   jump target label is unused as a result, it and the code following
   it may be deleted.

   Normally, NLABEL will be a label, but it may also be a RETURN rtx;
   in that case we are to turn the jump into a (possibly conditional)
   return insn.

   The return value will be 1 if the change was made, 0 if it wasn't
   (this can only occur when trying to produce return insns).   

References apply_change_group(), epilogue_completed, redirect_jump_1(), and redirect_jump_2().

Referenced by compare_and_jump_seq(), convert_jumps_to_returns(), dbr_schedule(), fix_crossing_conditional_branches(), force_nonfallthru_and_redirect(), patch_jump_insn(), reorg_redirect_jump(), and try_redirect_by_replacing_jump().

int redirect_jump_1 ( )
Make JUMP go to NLABEL instead of where it jumps now.  Accrue
   the modifications into the change group.  Return false if we did
   not see how to do that.   

References extract_asm_operands(), num_validated_changes(), and redirect_exp_1().

Referenced by dead_or_predicable(), invert_jump_1(), and redirect_jump().

void redirect_jump_2 ( rtx  jump,
rtx  olabel,
rtx  nlabel,
int  delete_unused,
int  invert 
)
Fix up JUMP_LABEL and label ref counts after OLABEL has been replaced with
   NLABEL in JUMP.
   If DELETE_UNUSED is positive, delete related insn to OLABEL if its ref
   count has dropped to zero.   

References confirm_change_group(), delete_related_insns(), find_reg_note(), invert_br_probabilities(), invert_exp_1(), redirect_exp_1(), and remove_note().

Referenced by dead_or_predicable(), invert_jump(), and redirect_jump().

static rtx redirect_target ( )
static
A helper function for redirect_exp_1; examines its input X and returns
   either a LABEL_REF around a label, or a RETURN if X was NULL.   

References ret_rtx.

Referenced by redirect_exp_1().

unsigned int reg_or_subregno ( )
Return regno of the register REG and handle subregs too.   

Referenced by gen_reload(), and push_reload().

static int returnjump_p_1 ( rtx ,
void *   
)
static

Referenced by returnjump_p().

static int returnjump_p_1 ( )
static
Return true if INSN is a (possibly conditional) return insn.   

References SET.

enum rtx_code reverse_condition ( )
Given an rtx-code for a comparison, return the code for the negated
   comparison.  If no such code exists, return UNKNOWN.

   WATCH OUT!  reverse_condition is not safe to use on a jump that might
   be acting on the results of an IEEE floating point comparison, because
   of the special treatment of non-signaling nans in comparisons.
   Use reversed_comparison_code instead.   

Referenced by alter_cond(), do_compare_rtx_and_jump(), emit_store_flag(), emit_store_flag_force(), fold_rtx(), iv_number_of_iterations(), known_cond(), noce_get_condition(), reversed_comparison_code_parts(), and simplify_comparison().

enum rtx_code reverse_condition_maybe_unordered ( )
Similar, but we're allowed to generate unordered comparisons, which
   makes it safe for IEEE floating-point.  Of course, we have to recognize
   that the target will support them too...   

Referenced by do_compare_rtx_and_jump(), emit_store_flag(), emit_store_flag_force(), prepare_float_lib_cmp(), and reversed_comparison_code_parts().

rtx reversed_comparison ( )
Return comparison with reversed code of EXP.
   Return NULL_RTX in case we fail to do the reversal.   

References reversed_comparison_code(), and simplify_gen_relational().

Referenced by simplify_binary_operation_1(), and simplify_if_then_else().

enum rtx_code reversed_comparison_code_parts ( enum rtx_code  code,
const_rtx  arg0,
const_rtx  arg1,
const_rtx  insn 
)
Given a comparison (CODE ARG0 ARG1), inside an insn, INSN, return a code
   of reversed comparison if it is possible to do so.  Otherwise return UNKNOWN.
   UNKNOWN may be returned in case we are having CC_MODE compare and we don't
   know whether it's source is floating point or integer comparison.  Machine
   description should define REVERSIBLE_CC_MODE and REVERSE_CONDITION macros
   to help this function avoid overhead in these cases.   

References prev_nonnote_insn(), reverse_condition(), reverse_condition_maybe_unordered(), RTX_COMM_COMPARE, RTX_COMPARE, rtx_equal_p(), SET, and set_of().

Referenced by combine_simplify_rtx(), emit_conditional_move(), record_jump_equiv(), and reversed_comparison_code().

int rtx_renumbered_equal_p ( )
Like rtx_equal_p except that it considers two REGs as equal
   if they renumber to the same value and considers two commutative
   operations to be the same if the order of the operands has been
   reversed.   

References next_real_insn(), subreg_info::offset, reg_renumber, subreg_info::representable_p, rtx_equal_p(), subreg_get_info(), and targetm.

Referenced by can_replace_by(), equal_different_set_p(), find_equiv_reg(), old_insns_match_p(), and outgoing_edges_match().

enum rtx_code signed_condition ( )
Similarly, return the signed version of a comparison.   

Referenced by simplify_const_relational_operation().

int true_regnum ( )
If X is a hard register or equivalent to one or a subregister of one,
   return the hard register number.  If X is a pseudo register that was not
   assigned a hard register, return the pseudo register number.  Otherwise,
   return -1.  Any rtx is valid for X.   

References lra_in_progress, subreg_info::offset, reg_renumber, subreg_info::representable_p, and subreg_get_info().

Referenced by choose_reload_regs(), clear_reload_reg_in_use(), deallocate_reload_reg(), decompose(), find_equiv_reg(), find_reusable_reload(), reload_cse_simplify_operands(), reload_cse_simplify_set(), reload_reg_free_for_value_p(), and set_reload_reg().

enum rtx_code unsigned_condition ( )
Given a comparison CODE, return the corresponding unsigned comparison.
   If CODE is an equality comparison or already an unsigned comparison,
   CODE is returned.   

Referenced by do_compare_rtx_and_jump(), emit_cmp_and_jump_insns(), emit_conditional_add(), emit_conditional_move(), emit_store_flag_1(), and simplify_comparison().