SSA Jump Threading
Copyright (C) 2005-2024 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/>.
void back_jt_path_registry::adjust_paths_after_duplication |
( |
unsigned | curr_path_num | ) |
|
|
privateinherited |
After a path has been jump threaded, adjust the remaining paths
that are subsets of this path, so these paths can be safely
threaded within the context of the new threaded path.
For example, suppose we have just threaded:
5 -> 6 -> 7 -> 8 -> 12 => 5 -> 6' -> 7' -> 8' -> 12'
And we have an upcoming threading candidate:
5 -> 6 -> 7 -> 8 -> 15 -> 20
This function adjusts the upcoming path into:
8' -> 15 -> 20
CURR_PATH_NUM is an index into the global paths table. It
specifies the path that was just threaded.
References cancel_thread(), jt_path_registry::debug_path(), dump_file, dump_flags, gcc_assert, ggc_alloc(), jt_path_registry::m_paths, MIN, back_jt_path_registry::rewire_first_differing_edge(), and TDF_DETAILS.
Referenced by back_jt_path_registry::duplicate_thread_path().
Duplicates a jump-thread path of N_REGION basic blocks.
The ENTRY edge is redirected to the duplicate of the region.
Remove the last conditional statement in the last basic block in the REGION,
and create a single fallthru edge pointing to the same destination as the
EXIT edge.
CURRENT_PATH_NO is an index into the global paths[] table
specifying the jump-thread path.
Returns false if it is unable to copy the region, true otherwise.
References add_phi_args_after_copy(), back_jt_path_registry::adjust_paths_after_duplication(), profile_probability::always(), bb_in_bbs(), can_copy_bbs_p(), copy_bbs(), basic_block_def::count, count, find_edge(), flush_pending_stmts(), FOR_EACH_EDGE, free(), free_original_copy_tables(), gcc_assert, get_bb_copy(), get_bb_original(), ggc_alloc(), loop::header, i, initialize_original_copy_tables(), make_edge(), mark_loop_for_removal(), NULL, redirect_edge_and_branch(), redirect_edge_and_branch_force(), remove_ctrl_stmt_and_useless_edges(), rescan_loop_exit(), scale_bbs_frequencies_profile_count(), set_loop_copy(), single_succ_edge(), single_succ_p(), split_edge_bb_loc(), basic_block_def::succs, update_bb_profile_for_threading(), and verify_jump_thread().
Referenced by back_jt_path_registry::update_cfg().
Register a jump threading opportunity. We queue up all the jump
threading opportunities discovered by a pass and update the CFG
and SSA form all at once.
E is the edge we can thread, E2 is the new target edge, i.e., we
are effectively recording that E->dest can be changed to E2->dest
after fixing the SSA graph.
Return TRUE if PATH was successfully threaded.
References jt_path_registry::cancel_invalid_paths(), dbg_cnt(), dump_file, dump_flags, dump_jump_thread_path(), gcc_checking_assert, ggc_alloc(), jt_path_registry::m_paths, and TDF_DETAILS.
Referenced by register_path(), and jump_threader::thread_across_edge().
bool jt_path_registry::thread_through_all_blocks |
( |
bool | peel_loop_headers | ) |
|
|
inherited |
Thread all paths that have been queued for jump threading, and
update the CFG accordingly.
It is the caller's responsibility to fix the dominance information
and rewrite duplicated SSA_NAMEs back into SSA form.
If PEEL_LOOP_HEADERS is false, avoid threading edges through loop
headers if it does not simplify the loop.
Returns true if one or more edges were threaded.
References cfun, ggc_alloc(), LOOPS_NEED_FIXUP, loops_state_set(), jt_path_registry::m_num_threaded_edges, jt_path_registry::m_paths, statistics_counter_event(), and jt_path_registry::update_cfg().
Referenced by back_threader::thread_blocks(), and jump_threader::thread_through_all_blocks().