GCC Middle and Back End API Reference
tree-ssa-ifcombine.c File Reference

Functions

static bool recognize_if_then_else (basic_block cond_bb, basic_block *then_bb, basic_block *else_bb)
static bool bb_no_side_effects_p ()
static bool same_phi_args_p ()
static tree get_name_for_bit_test ()
static bool recognize_single_bit_test ()
static bool recognize_bits_test ()
static bool ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, basic_block outer_cond_bb, bool outer_inv, bool result_inv)
static bool tree_ssa_ifcombine_bb ()
static unsigned int tree_ssa_ifcombine ()
static bool gate_ifcombine ()
gimple_opt_passmake_pass_tree_ifcombine ()

Function Documentation

static bool bb_no_side_effects_p ( )
static
Verify if the basic block BB does not have side-effects.  Return
   true in this case, else false.   

References gimple_has_side_effects(), gimple_vuse(), gsi_end_p(), gsi_next(), gsi_start_bb(), and gsi_stmt().

Referenced by tree_ssa_ifcombine_bb().

static bool gate_ifcombine ( )
static
static tree get_name_for_bit_test ( )
static
Return the best representative SSA name for CANDIDATE which is used
   in a bit test.   

References candidate(), gimple_assign_rhs1(), gimple_assign_rhs_code(), has_single_use(), and is_gimple_assign().

Referenced by recognize_bits_test(), and recognize_single_bit_test().

static bool ifcombine_ifandif ( basic_block  inner_cond_bb,
bool  inner_inv,
basic_block  outer_cond_bb,
bool  outer_inv,
bool  result_inv 
)
static
If-convert on a and pattern with a common else block.  The inner
   if is specified by its INNER_COND_BB, the outer by OUTER_COND_BB.
   inner_inv, outer_inv and result_inv indicate whether the conditions
   are inverted.
   Returns true if the edges to the common else basic-block were merged.   

References build_int_cst(), canonicalize_cond_expr_cond(), dump_file, force_gimple_operand_gsi(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_cond_set_condition_from_tree(), gsi_for_stmt(), GSI_SAME_STMT, invert_tree_comparison(), last_stmt(), maybe_fold_and_comparisons(), print_generic_expr(), recognize_bits_test(), recognize_single_bit_test(), tcc_comparison, unsigned_type_for(), and update_stmt().

Referenced by tree_ssa_ifcombine_bb().

gimple_opt_pass* make_pass_tree_ifcombine ( )
static bool recognize_bits_test ( )
static
Recognize a bit test pattern in a GIMPLE_COND and its defining
   statements.  Store the name being tested in *NAME and the bits
   in *BITS.  The COND_EXPR computes *NAME & *BITS.
   Returns true if the pattern matched, false otherwise.   

References get_name_for_bit_test(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), integer_zerop(), and is_gimple_assign().

Referenced by ifcombine_ifandif().

static bool recognize_if_then_else ( basic_block  cond_bb,
basic_block then_bb,
basic_block else_bb 
)
static
@verbatim Combining of if-expressions on trees.

Copyright (C) 2007-2013 Free Software Foundation, Inc. Contributed by Richard Guenther rguen.nosp@m.ther.nosp@m.@suse.nosp@m..de

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 pass combines COND_EXPRs to simplify control flow.  It
   currently recognizes bit tests and comparisons in chains that
   represent logical and or logical or of two COND_EXPRs.

   It does so by walking basic blocks in a approximate reverse
   post-dominator order and trying to match CFG patterns that
   represent logical and or logical or of two COND_EXPRs.
   Transformations are done if the COND_EXPR conditions match
   either

     1. two single bit tests X & (1 << Yn) (for logical and)

     2. two bit tests X & Yn (for logical or)

     3. two comparisons X OPn Y (for logical or)

   To simplify this pass, removing basic blocks and dead code
   is left to CFG cleanup and DCE.   
Recognize a if-then-else CFG pattern starting to match with the
   COND_BB basic-block containing the COND_EXPR.  The recognized
   then end else blocks are stored to *THEN_BB and *ELSE_BB.  If
   *THEN_BB and/or *ELSE_BB are already set, they are required to
   match the then and else basic-blocks to make the pattern match.
   Returns true if the pattern matched, false otherwise.   

References edge_def::dest, edge_def::flags, and basic_block_def::succs.

Referenced by tree_ssa_ifcombine_bb().

static bool recognize_single_bit_test ( )
static
Recognize a single bit test pattern in GIMPLE_COND and its defining
   statements.  Store the name being tested in *NAME and the bit
   in *BIT.  The GIMPLE_COND computes *NAME & (1 << *BIT).
   Returns true if the pattern matched, false otherwise.   

References build_int_cst(), get_name_for_bit_test(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_ssa_name_copy_p(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), integer_onep(), integer_pow2p(), integer_zerop(), is_gimple_assign(), and tree_log2().

Referenced by ifcombine_ifandif().

static bool same_phi_args_p ( )
static
Verify if all PHI node arguments in DEST for edges from BB1 or
   BB2 to DEST are the same.  This makes the CFG merge point
   free from side-effects.  Return true in this case, else false.   

References find_edge(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), and operand_equal_p().

Referenced by tree_ssa_ifcombine_bb().

static unsigned int tree_ssa_ifcombine ( )
static
static bool tree_ssa_ifcombine_bb ( )
static
Recognize a CFG pattern and dispatch to the appropriate
   if-conversion helper.  We start with BB as the innermost
   worker basic-block.  Returns true if a transformation was done.   

References bb_no_side_effects_p(), ifcombine_ifandif(), recognize_if_then_else(), same_phi_args_p(), single_pred(), and single_pred_p().

Referenced by tree_ssa_ifcombine().