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


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_condjump_p ( )
   Return true when insn is a conditional jump.  This function works for
   instructions containing PC sets in PARALLELs.  The instruction may have
   various other effects so before removing the jump you must verify

   Note that unlike condjump_p it returns false for unconditional jumps.  

References SET.

Referenced by cfg_layout_redirect_edge_and_branch_force(), delete_prior_computation(), edge_probability_reliable_p(), get_last_bb_insn(), next_real_insn(), outof_cfg_layout_mode(), prev_nondebug_insn(), and remove_predictions_associated_with_edge().

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

Referenced by emit_debug_insn().

static unsigned int cleanup_barriers ( )
   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.
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.  
     UNKNOWN comparison codes can happen as a result of trying to revert
     comparison codes.
     They can't match anything, so we have to reject them here.  
int condjump_in_parallel_p ( )
   Return nonzero if INSN is a (possibly) conditional jump inside a

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

Referenced by delete_prior_computation(), and get_jump_flags().

rtx condjump_label ( )
   Return the label of a conditional jump.  
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.  

Referenced by delete_prior_computation().

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.  
             Patch this insn out of the chain.  
             We don't do this all at once, because we
             must preserve all NOTEs.  
     Note that if TO is an unconditional jump
     we *do not* delete the BARRIER that follows,
     since the peephole that replaces this sequence
     is also an unconditional jump in that case.  
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.  
     This insn is already deleted => return first following nondeleted.  
     If instruction is followed by a barrier,
     delete the barrier too.  
     If this is a call, then we have to remove the var tracking note
     for the call arguments.  
     If deleting a jump, decrement the count of the label,
     and delete the label if it is now unused.  
           This can delete NEXT or PREV,
           either directly if NEXT is JUMP_LABEL (INSN),
           or indirectly through more levels of jumps.  
             If we're deleting the tablejump, delete the dispatch table.
             We may not be able to kill the label immediately preceding
             just yet, as it might be referenced in code leading up to
             the tablejump.  
     Likewise if we're deleting a dispatch table.  
     Likewise for any JUMP_P / INSN / CALL_INSN with a
             This could also be a NOTE_INSN_DELETED_LABEL note.  
     If INSN was a label and a dispatch table follows it,
     delete the dispatch table.  The tablejump must have gone already.
     It isn't useful to fall through into a table.  
     If INSN was a label, delete insns following it if now unreachable.  
             Keep going past other deleted labels to delete what follows.  
               Note: if this deletes a jump, it can cause more
               deletion of unreachable code, after a different label.
               As long as the value from this recursive call is correct,
               this invocation functions correctly.  
     I feel a little doubtful about this loop,
     but I see no clean and sure alternative way
     to find the first insn after INSN that is not now deleted.
     I hope this works.  

Referenced by delete_computation(), delete_prior_computation(), fill_simple_delay_slots(), and note_delay_statistics().

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

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

   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.  
static void init_label_info ( )
   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.  
         REG_LABEL_TARGET notes (including the JUMP_LABEL field) are
         sticky and not reset here; that way we won't lose association
         with a label when e.g. the source for a target register
         disappears out of reach for targets that may use jump-target
         registers.  Jump transformations are supposed to transform
         any REG_LABEL_TARGET notes.  The target label reference in a
         branch may disappear from the branch (and from the
         instruction before it) for other reasons, like register

References reg_mentioned_p(), and remove_note().

static int invert_exp_1 ( rtx  ,
static int invert_exp_1 ( )
   Invert the jump condition X contained in jump insn INSN.  Accrue the
   modifications into the change group.  Return nonzero for success.  
         We can do this in two ways:  The preferable way, which can only
         be done if this is not an integer comparison, is to reverse
         the comparison code.  Otherwise, swap the THEN-part and ELSE-part
         of the IF_THEN_ELSE.  If we can't do either, fail.  

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

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 next_real_insn().

Referenced by add_labels_and_missing_jumps(), delete_prior_computation(), make_pass_into_cfg_layout_mode(), and note_delay_statistics().

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.  
     redirect_jump_1 will fail of nlabel == olabel, and the current use is
     in Pmode, so checking this is not merely an optimization.  

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

bool jump_to_label_p ( )
   Return true iff INSN is a jump and its JUMP_LABEL is a label, not
   NULL or a return.  
rtl_opt_pass* make_pass_cleanup_barriers ( )
static void mark_all_labels ( rtx  )
static void mark_all_labels ( )
   Mark the label each jump jumps to.
   Combine consecutive labels, and count uses of labels.  
             In cfglayout mode, we don't bother with trivial next-insn
             propagation of LABEL_REFs into JUMP_LABEL.  This will be
             handled by other optimizers using better algorithms.  
             In cfglayout mode, there may be non-insns between the
             basic blocks.  If those non-insns represent tablejump data,
             they contain label references that we must record.  
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.  

Referenced by next_real_insn(), and sets_cc0_p().

static void mark_jump_label_1 ( rtx  ,
rtx  ,
bool  ,
static void mark_jump_label_1 ( )
   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
         If this is a constant-pool reference, see if it is a label.  
         Handle operands in the condition of an if-then-else as for a
         non-jump insn.  
           Ignore remaining references to unreachable labels that
           have been deleted.  
           Ignore references to labels of containing functions.  
                   Do not change a previous setting of JUMP_LABEL.  If the
                   JUMP_LABEL slot is occupied by a different label,
                   create a note for this label.  
                   Add a REG_LABEL_OPERAND or REG_LABEL_TARGET note
                   for LABEL unless there already is one.  All uses of
                   a label, except for the primary target of a jump,
                   must have such a note.  
       Do walk the labels in a vector, but not the first operand of an
       ADDR_DIFF_VEC.  Don't set the JUMP_LABEL of a vector.  
     The primary target of a tablejump is the label of the ADDR_VEC,
     which is canonically mentioned *last* in the insn.  To get it
     marked as JUMP_LABEL, we iterate over items in reverse order.  
static void mark_jump_label_asm ( rtx  ,

Referenced by only_sets_cc0_p().

static void mark_jump_label_asm ( )
   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.  
static void maybe_propagate_label_ref ( )
   A subroutine of mark_all_labels.  Trivially propagate a simple label
   load into a jump_insn that uses it.  
     If the previous non-jump insn sets something to a label,
     something that this jump insn uses, make that label the primary
     target of this insn if we don't yet have any.  That previous
     insn must be a single_set and not refer to more than one label.
     The jump insn must not refer to other labels as jump targets
     and must be a plain (set (pc) ...), maybe in a parallel, and
     may refer to the item being set only directly or as one of the
     arms in an IF_THEN_ELSE.  
             The source must be the direct LABEL_REF, not a
             PLUS, UNSPEC, IF_THEN_ELSE etc.  
             The CODE_LABEL referred to in the note must be the
             CODE_LABEL in the LABEL_REF of the "set".  We can
             conveniently use it for the marker function, which
             requires a LABEL_REF wrapping.  

References mark_jump_label_1(), and rtx_equal_p().

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

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

int onlyjump_p ( )
   Return true if INSN is a jump that only transfers control and
   nothing more.  

Referenced by cond_exec_find_if_block(), and outof_cfg_layout_mode().

rtx pc_set ( )
   Return set of PC, otherwise NULL.  
     The set is allowed to appear either as the insn pattern or
     the first set in a PARALLEL.  
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 remove_death(), and split_live_ranges_for_shrink_wrap().

static void rebuild_jump_labels_1 ( )
   Worker for rebuild_jump_labels and rebuild_jump_labels_chain.  
     Keep track of labels used from static data; we don't track them
     closely enough to delete them here, so make sure their reference
     count doesn't drop to zero.  

Referenced by rebuild_jump_labels().

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 get_insns(), and prev_nonnote_insn().

static void redirect_exp_1 ( rtx ,
rtx  ,
rtx  ,

Referenced by redirect_jump_1().

static void redirect_exp_1 ( )
   Throughout LOC, redirect OLABEL to NLABEL.  Treat null OLABEL or
   NLABEL as a return.  Accrue modifications into the change group.  
         Skip the condition of an IF_THEN_ELSE.  We only want to
         change jump destinations, not eventual label comparisons.  

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

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).  
         If there is no label, we are asked to redirect to the EXIT block.
         When before the epilogue is emitted, return/simple_return cannot be
         created so we return 0 immediately.  After the epilogue is emitted,
         we always expect a label, either a non-null label, or a
         return/simple_return RTX.  

References validate_change().

Referenced by fixup_new_cold_bb().

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 confirm_change_group(), and redirect_exp_1().

Referenced by redirect_exp_1().

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
   If DELETE_UNUSED is positive, delete related insn to OLABEL if its ref
   count has dropped to zero.  
     Negative DELETE_UNUSED used to be used to signalize behavior on
     moving FUNCTION_END note.  Just sanity check that no user still worry
     about this.  
     Update labels in any REG_EQUAL note.  
         Undefined labels will remain outside the insn stream.  

Referenced by redirect_exp_1().

static rtx redirect_target ( )
   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.  
unsigned int reg_or_subregno ( )
   Return regno of the register REG and handle subregs too.  

Referenced by inherit_piecemeal_p().

int returnjump_p ( )
   Return TRUE if INSN is a return jump.  

Referenced by find_auto_inc(), and outof_cfg_layout_mode().

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

References side_effects_p().

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 notice_source_line().

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 emit_cstore().

rtx reversed_comparison ( )
   Return comparison with reversed code of EXP.
   Return NULL_RTX in case we fail to do the reversal.  
enum rtx_code reversed_comparison_code ( )
   A wrapper around the previous function to take COMPARISON as rtx
   expression.  This simplifies many callers.  

Referenced by cond_exec_find_if_block(), end_ifcvt_sequence(), get_jump_flags(), and noce_try_addcc().

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.  
     If this is not actually a comparison, we can't reverse it.  
     First see if machine description supplies us way to reverse the
     comparison.  Give it priority over everything else to allow
     machine description to do tricks.  
     Try a few special cases based on the comparison code.  
         It is always safe to reverse EQ and NE, even for the floating
         point.  Similarly the unsigned comparisons are never used for
         floating point so we can reverse them in the default way.  
         In case we already see unordered comparison, we can be sure to
         be dealing with floating point so we don't need any more tests.  
         We don't have safe way to reverse these yet.  
         Try to search for the comparison to determine the real mode.
         This code is expensive, but with sane machine description it
         will be never used, since REVERSIBLE_CC_MODE will return true
         in all cases.  
         These CONST_CAST's are okay because prev_nonnote_insn just
         returns its argument and we assign it to a const_rtx
                 We can get past reg-reg moves.  This may be useful for model
                 of i387 comparisons that first move flag registers around.  
             If register is clobbered in some ununderstandable way,
             give up.  
     Test for an integer condition, or a floating-point comparison
     in which NaNs can be ignored.  

Referenced by emit_cmp_and_jump_insn_1(), and subst().

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
         If we haven't done any renumbering, don't
         make any assumptions.  
     Now we have disposed of all the cases
     in which different rtx codes can match.  
         We can't assume nonlocal labels have their following insns yet.  
         Two label-refs are equivalent if they point at labels
         in the same position in the instruction stream.  
         If we didn't match EQ equality above, they aren't the same.  
     (MULT:SI x y) and (MULT:HI x y) are NOT equivalent.  
     MEMs referring to different address space are not equivalent.  
     For commutative operations, the RTX match if the operand match in any
     order.  Also handle the simple binary and unary cases without a loop.  
     Compare the elements.  If any pair of corresponding elements
     fail to match, return 0 for the whole things.  
             Fall through.  
int sets_cc0_p ( )
   Return 1 if X is an RTX that does nothing but set the condition codes
   and CLOBBER or USE registers.
   Return -1 if X does explicitly set the condition codes,
   but also does other things.  

References mark_jump_label().

Referenced by df_simulate_one_insn_forwards(), reload_combine_recognize_const_pattern(), and try_merge_delay_insns().

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

Referenced by simplify_relational_operation_1().

int simplejump_p ( )
   Return 1 if INSN is an unconditional jump and nothing else.  

References SET.

Referenced by record_insns().

enum rtx_code swap_condition ( )
   Similar, but return the code when two operands of a comparison are swapped.
   This IS safe for IEEE floating-point.  

Referenced by emit_cmp_and_jump_insn_1(), notice_source_line(), recog_for_combine(), and simplify_relational_operation_1().

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.  

Referenced by copy_replacements_1(), find_valid_class_1(), and operands_match_p().

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.