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

Functions

void set_ssa_name_value ()
void threadedge_initialize_values ()
void threadedge_finalize_values ()
bool potentially_threadable_block ()
static tree lhs_of_dominating_assert ()
static void remove_temporary_equivalences ()
static void record_temporary_equivalence ()
static bool record_temporary_equivalences_from_phis ()
static tree fold_assignment_stmt ()
static gimple record_temporary_equivalences_from_stmts_at_dest (edge e, vec< tree > *stack, tree(*simplify)(gimple, gimple))
static tree simplify_control_stmt_condition (edge e, gimple stmt, gimple dummy_cond, tree(*simplify)(gimple, gimple), bool handle_dominating_asserts)
static bool cond_arg_set_in_bb ()
void propagate_threaded_block_debug_into ()
static edge thread_around_empty_block (edge taken_edge, gimple dummy_cond, bool handle_dominating_asserts, tree(*simplify)(gimple, gimple), bitmap visited)
static bool phi_args_equal_on_edges ()
void thread_across_edge (gimple dummy_cond, edge e, bool handle_dominating_asserts, vec< tree > *stack, tree(*simplify)(gimple, gimple))

Variables

static int stmt_count
vec< treessa_name_values

Function Documentation

static bool cond_arg_set_in_bb ( )
static
Return TRUE if the statement at the end of e->dest depends on
   the output of any statement in BB.   Otherwise return FALSE.

   This is used when we are threading a backedge and need to ensure
   that temporary equivalences from BB do not affect the condition
   in e->dest.   

References edge_def::dest, last, and last_stmt().

Referenced by thread_across_edge().

static tree fold_assignment_stmt ( )
static
Fold the RHS of an assignment statement and return it as a tree.
   May return NULL_TREE if no simplification is possible.   

References fold(), get_gimple_rhs_class(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs3(), gimple_assign_rhs_code(), GIMPLE_BINARY_RHS, GIMPLE_SINGLE_RHS, GIMPLE_TERNARY_RHS, and GIMPLE_UNARY_RHS.

Referenced by record_temporary_equivalences_from_stmts_at_dest().

static tree lhs_of_dominating_assert ( )
static
Return the LHS of any ASSERT_EXPR where OP appears as the first
   argument to the ASSERT_EXPR and in which the ASSERT_EXPR dominates
   BB.  If no such ASSERT_EXPR is found, return OP.   

References CDI_DOMINATORS, dominated_by_p(), gimple_assign_lhs(), gimple_assign_rhs1(), and gimple_assign_single_p().

Referenced by simplify_control_stmt_condition().

static bool phi_args_equal_on_edges ( )
static
E1 and E2 are edges into the same basic block.  Return TRUE if the
   PHI arguments associated with those edges are equal or there are no
   PHI arguments, otherwise return FALSE.   

References edge_def::dest, edge_def::dest_idx, gimple_phi_arg_def(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), and operand_equal_p().

Referenced by thread_across_edge().

bool potentially_threadable_block ( )
Return TRUE if we may be able to thread an incoming edge into
   BB to an outgoing edge from BB.  Return FALSE otherwise.   

References gsi_end_p(), gsi_last_bb(), gsi_stmt(), single_pred_p(), and single_succ_p().

void propagate_threaded_block_debug_into ( )
static void record_temporary_equivalence ( )
static
Record a temporary equivalence, saving enough information so that
   we can restore the state of recorded equivalences when we're
   done processing the current edge.   

References set_ssa_name_value().

Referenced by record_temporary_equivalences_from_phis(), and record_temporary_equivalences_from_stmts_at_dest().

static bool record_temporary_equivalences_from_phis ( )
static
Record temporary equivalences created by PHIs at the target of the
   edge E.  Record unwind information for the equivalences onto STACK.

   If a PHI which prevents threading is encountered, then return FALSE
   indicating we should not thread this edge, else return TRUE.   

References edge_def::dest, gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), record_temporary_equivalence(), stmt_count, and virtual_operand_p().

Referenced by thread_across_edge().

static gimple record_temporary_equivalences_from_stmts_at_dest ( edge  e,
vec< tree > *  stack,
tree(*)(gimple, gimple simplify 
)
static
Try to simplify each statement in E->dest, ultimately leading to
   a simplification of the COND_EXPR at the end of E->dest.

   Record unwind information for temporary equivalences onto STACK.

   Use SIMPLIFY (a pointer to a callback function) to further simplify
   statements using pass specific information.

   We might consider marking just those statements which ultimately
   feed the COND_EXPR.  It's not clear if the overhead of bookkeeping
   would be recovered by trying to simplify fewer statements.

   If we are able to simplify a statement into the form
   SSA_NAME = (SSA_NAME | gimple invariant), then we can record
   a context sensitive equivalence which may help us simplify
   later statements in E->dest.   

References copy(), edge_def::dest, fold_assignment_stmt(), fold_call_stmt(), free(), gimple_asm_volatile_p(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_single_p(), gimple_call_fndecl(), gimple_call_lhs(), gimple_get_lhs(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), is_gimple_call(), is_gimple_debug(), is_gimple_min_invariant(), record_temporary_equivalence(), and stmt_count.

Referenced by thread_across_edge().

static void remove_temporary_equivalences ( )
static
We record temporary equivalences created by PHI nodes or
   statements within the target block.  Doing so allows us to
   identify more jump threading opportunities, even in blocks
   with side effects.

   We keep track of those temporary equivalences in a stack
   structure so that we can unwind them when we're done processing
   a particular edge.  This routine handles unwinding the data
   structures.   

References set_ssa_name_value().

Referenced by thread_across_edge().

void set_ssa_name_value ( )
Set the value for the SSA name NAME to VALUE.   
static tree simplify_control_stmt_condition ( edge  e,
gimple  stmt,
gimple  dummy_cond,
tree(*)(gimple, gimple simplify,
bool  handle_dominating_asserts 
)
static
Simplify the control statement at the end of the block E->dest.

   To avoid allocating memory unnecessarily, a scratch GIMPLE_COND
   is available to use/clobber in DUMMY_COND.

   Use SIMPLIFY (a pointer to a callback function) to further simplify
   a condition using pass specific information.

   Return the simplified condition or NULL if simplification could
   not be performed.   

References fold_defer_overflow_warnings(), fold_undefer_overflow_warnings(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_cond_set_code(), gimple_cond_set_lhs(), gimple_cond_set_rhs(), gimple_goto_dest(), gimple_switch_index(), is_gimple_min_invariant(), lhs_of_dominating_assert(), edge_def::src, swap_tree_comparison(), tree_swap_operands_p(), and WARN_STRICT_OVERFLOW_CONDITIONAL.

Referenced by thread_across_edge(), and thread_around_empty_block().

void thread_across_edge ( gimple  dummy_cond,
edge  e,
bool  handle_dominating_asserts,
vec< tree > *  stack,
tree(*)(gimple, gimple simplify 
)
We are exiting E->src, see if E->dest ends with a conditional
   jump which has a known value when reached via E.

   Special care is necessary if E is a back edge in the CFG as we
   may have already recorded equivalences for E->dest into our
   various tables, including the result of the conditional at
   the end of E->dest.  Threading opportunities are severely
   limited in that case to avoid short-circuiting the loop
   incorrectly.

   Note it is quite common for the first block inside a loop to
   end with a conditional which is either always true or always
   false when reached via the loop backedge.  Thus we do not want
   to blindly disable threading across a loop backedge.

   DUMMY_COND is a shared cond_expr used by condition simplification as scratch,
   to avoid allocating memory.

   HANDLE_DOMINATING_ASSERTS is true if we should try to replace operands of
   the simplified condition with left-hand sides of ASSERT_EXPRs they are
   used in.

   STACK is used to undo temporary equivalences created during the walk of
   E->dest.

   SIMPLIFY is a pass-specific function used to simplify statements.   

References bitmap_clear(), bitmap_set_bit(), cond_arg_set_in_bb(), edge_def::dest, find_edge(), find_taken_edge(), edge_def::flags, basic_block_def::index, is_gimple_min_invariant(), path, phi_args_equal_on_edges(), propagate_threaded_block_debug_into(), record_temporary_equivalences_from_phis(), record_temporary_equivalences_from_stmts_at_dest(), register_jump_thread(), remove_temporary_equivalences(), simplify_control_stmt_condition(), edge_def::src, stmt_count, basic_block_def::succs, thread_around_empty_block(), visited, and vNULL.

Referenced by dom_thread_across_edge(), and identify_jump_threads().

static edge thread_around_empty_block ( edge  taken_edge,
gimple  dummy_cond,
bool  handle_dominating_asserts,
tree(*)(gimple, gimple simplify,
bitmap  visited 
)
static
TAKEN_EDGE represents the an edge taken as a result of jump threading.
   See if we can thread around TAKEN_EDGE->dest as well.  If so, return
   the edge out of TAKEN_EDGE->dest that we can statically compute will be
   traversed.

   We are much more restrictive as to the contents of TAKEN_EDGE->dest
   as the path isolation code in tree-ssa-threadupdate.c isn't prepared
   to handle copying intermediate blocks on a threaded path. 

   Long term a more consistent and structured approach to path isolation
   would be a huge help.    

References bitmap_bit_p(), bitmap_set_bit(), edge_def::dest, find_taken_edge(), gsi_end_p(), gsi_start_nondebug_bb(), gsi_start_phis(), gsi_stmt(), basic_block_def::index, is_gimple_min_invariant(), simplify_control_stmt_condition(), single_pred_p(), and single_succ_p().

Referenced by thread_across_edge().

void threadedge_finalize_values ( void  )
Free the per SSA_NAME value-handle array.   

Referenced by execute_vrp(), and tree_ssa_dominator_optimize().

void threadedge_initialize_values ( void  )
Initialize the per SSA_NAME value-handles array.  Returns it.   

Referenced by execute_vrp(), and tree_ssa_dominator_optimize().


Variable Documentation

vec<tree> ssa_name_values
Array to record value-handles per SSA_NAME.   

Referenced by tree_ssa_dominator_optimize().

int stmt_count
static
@verbatim SSA Jump Threading

Copyright (C) 2005-2013 Free Software Foundation, Inc. Contributed by Jeff Law law@r.nosp@m.edha.nosp@m.t.com

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/.

To avoid code explosion due to jump threading, we limit the
   number of statements we are going to copy.  This variable
   holds the number of statements currently seen that we'll have
   to copy as part of the jump threading process.   

Referenced by record_temporary_equivalences_from_phis(), record_temporary_equivalences_from_stmts_at_dest(), and thread_across_edge().