GCC Middle and Back End API Reference
tree-ssa-threadupdate.h
Go to the documentation of this file.
1/* Communication between registering jump thread requests and
2 updating the SSA/CFG for jump threading.
3 Copyright (C) 2013-2026 Free Software Foundation, Inc.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef _TREE_SSA_THREADUPDATE_H
22#define _TREE_SSA_THREADUPDATE_H 1
23
31
32// We keep the registered jump threading opportunities in this
33// vector as edge pairs (original_edge, target_edge).
34
43
55
56// Abstract class for the jump thread registry.
57//
58// When all candidates have been registered with
59// register_jump_thread(), thread_through_all_blocks() is called to
60// update the CFG.
61
63{
64public:
65 jt_path_registry (bool backedge_threads);
66 virtual ~jt_path_registry ();
68 bool thread_through_all_blocks (bool peel_loop_headers);
71 void debug ();
72protected:
73 void debug_path (FILE *, int pathno);
74 void remove_path (unsigned pathno);
75 void remove_path (unsigned pathno, edge first);
76 void add_first_edge (edge);
77 void drop_first_edge (edge);
78 unsigned first_edge_count (edge);
80 // How many registered paths start on a given edge.
82 unsigned long m_num_threaded_edges;
83private:
84 virtual bool update_cfg (bool peel_loop_headers) = 0;
87 // True if threading through back edges is allowed. This is only
88 // allowed in the generic copier in the backward threader.
91};
92
93// Forward threader path registry using a custom BB copier.
94
96{
97public:
101private:
102 bool update_cfg (bool peel_loop_headers) override;
103 void mark_threaded_blocks (bitmap threaded_blocks);
104 bool thread_block_1 (basic_block, bool noloop_only, bool joiners);
105 bool thread_block (basic_block, bool noloop_only);
107 bool may_peel_loop_headers);
108 class redirection_data *lookup_redirection_data (edge e, enum insert_option);
109
111
112 // Main data structure to hold information for duplicates of BB.
114};
115
116// Backward threader path registry using a generic BB copier.
117
119{
120public:
122private:
123 bool update_cfg (bool peel_loop_headers) override;
124 void adjust_paths_after_duplication (unsigned curr_path_num);
125 bool duplicate_thread_path (edge entry, edge exit, basic_block *region,
126 unsigned n_region, unsigned current_path_no,
127 const char **failure_reason);
128 bool rewire_first_differing_edge (unsigned path_num, unsigned edge_num);
130 unsigned cand_path_num);
131};
132
133// Rather than search all the edges in jump thread paths each time DOM
134// is able to simply if control statement, we build a hash table with
135// the deleted edges. We only care about the address of the edge, not
136// its contents.
138{
139 static hashval_t hash (edge e) { return htab_hash_pointer (e); }
140 static bool equal (edge e1, edge e2) { return e1 == e2; }
141};
142
143extern unsigned int estimate_threading_killed_stmts (basic_block);
144
146{
147 /* BB does not dominate latch of the LOOP. */
149 /* The LOOP is broken (there is no path from the header to its latch. */
151 /* BB dominates the latch of the LOOP. */
153};
154
156
157// In tree-ssa-dom.cc.
158extern void free_dom_edge_info (edge);
159
160#endif
void adjust_paths_after_duplication(unsigned curr_path_num)
Definition tree-ssa-threadupdate.cc:2409
bool rewire_first_differing_edge(unsigned path_num, unsigned edge_num)
Definition tree-ssa-threadupdate.cc:2292
bool update_cfg(bool peel_loop_headers) override
Definition tree-ssa-threadupdate.cc:2705
bool duplicate_thread_path(edge entry, edge exit, basic_block *region, unsigned n_region, unsigned current_path_no, const char **failure_reason)
Definition tree-ssa-threadupdate.cc:2457
bool adjust_one_path(vec< jump_thread_edge * > *curr_path, unsigned cand_path_num)
Definition tree-ssa-threadupdate.cc:2329
back_jt_path_registry()
Definition tree-ssa-threadupdate.cc:241
fwd_jt_path_registry()
Definition tree-ssa-threadupdate.cc:229
bool thread_block_1(basic_block, bool noloop_only, bool joiners)
Definition tree-ssa-threadupdate.cc:1469
hash_table< struct removed_edges > * m_removed_edges
Definition tree-ssa-threadupdate.h:110
hash_table< redirection_data > * m_redirection_data
Definition tree-ssa-threadupdate.h:113
class redirection_data * lookup_redirection_data(edge e, enum insert_option)
Definition tree-ssa-threadupdate.cc:503
bool thread_block(basic_block, bool noloop_only)
Definition tree-ssa-threadupdate.cc:1663
bool thread_through_loop_header(class loop *loop, bool may_peel_loop_headers)
Definition tree-ssa-threadupdate.cc:1744
bool update_cfg(bool peel_loop_headers) override
Definition tree-ssa-threadupdate.cc:2766
void mark_threaded_blocks(bitmap threaded_blocks)
Definition tree-ssa-threadupdate.cc:2001
void remove_jump_threads_including(edge)
Definition tree-ssa-threadupdate.cc:2661
Definition hash-map.h:40
Definition hash-table.h:375
unsigned long m_num_threaded_edges
Definition tree-ssa-threadupdate.h:82
bool cancel_invalid_paths(vec< jump_thread_edge * > &path)
Definition tree-ssa-threadupdate.cc:2859
unsigned first_edge_count(edge)
Definition tree-ssa-threadupdate.cc:222
bool thread_through_all_blocks(bool peel_loop_headers)
Definition tree-ssa-threadupdate.cc:2682
void remove_path(unsigned pathno)
Definition tree-ssa-threadupdate.cc:195
jump_thread_path_allocator m_allocator
Definition tree-ssa-threadupdate.h:86
virtual bool update_cfg(bool peel_loop_headers)=0
hash_map< edge, unsigned > m_first_edge_counts
Definition tree-ssa-threadupdate.h:81
void debug_path(FILE *, int pathno)
Definition tree-ssa-threadupdate.cc:2266
bool m_backedge_threads
Definition tree-ssa-threadupdate.h:89
DISABLE_COPY_AND_ASSIGN(jt_path_registry)
bool register_jump_thread(vec< jump_thread_edge * > *)
Definition tree-ssa-threadupdate.cc:2970
void add_first_edge(edge)
Definition tree-ssa-threadupdate.cc:203
void drop_first_edge(edge)
Definition tree-ssa-threadupdate.cc:211
vec< jump_thread_edge * > * allocate_thread_path()
Definition tree-ssa-threadupdate.cc:255
void debug()
Definition tree-ssa-threadupdate.cc:2277
jt_path_registry(bool backedge_threads)
Definition tree-ssa-threadupdate.cc:170
void push_edge(vec< jump_thread_edge * > *path, edge, jump_thread_edge_type)
Definition tree-ssa-threadupdate.cc:247
vec< vec< jump_thread_edge * > * > m_paths
Definition tree-ssa-threadupdate.h:79
Definition tree-ssa-threadupdate.h:36
jump_thread_edge_type type
Definition tree-ssa-threadupdate.h:41
edge e
Definition tree-ssa-threadupdate.h:40
jump_thread_edge(edge e, jump_thread_edge_type t)
Definition tree-ssa-threadupdate.h:38
Definition tree-ssa-threadupdate.h:45
obstack m_obstack
Definition tree-ssa-threadupdate.h:53
jump_thread_edge * allocate_thread_edge(edge, jump_thread_edge_type)
Definition tree-ssa-threadupdate.cc:154
DISABLE_COPY_AND_ASSIGN(jump_thread_path_allocator)
jump_thread_path_allocator()
Definition tree-ssa-threadupdate.cc:143
vec< jump_thread_edge * > * allocate_thread_path()
Definition tree-ssa-threadupdate.cc:162
Definition cfgloop.h:120
struct basic_block_def * basic_block
Definition coretypes.h:351
class edge_def * edge
Definition coretypes.h:348
class bitmap_head * bitmap
Definition coretypes.h:51
Definition hash-traits.h:303
Definition tree-ssa-threadupdate.cc:116
Definition tree-ssa-threadupdate.h:138
static bool equal(edge e1, edge e2)
Definition tree-ssa-threadupdate.h:140
static hashval_t hash(edge e)
Definition tree-ssa-threadupdate.h:139
Definition vec.h:450
void free_dom_edge_info(edge e)
Definition tree-ssa-dom.cc:399
unsigned int estimate_threading_killed_stmts(basic_block bb)
Definition tree-ssa-threadupdate.cc:3030
enum bb_dom_status determine_bb_domination_status(class loop *loop, basic_block bb)
Definition tree-ssa-threadupdate.cc:1686
bb_dom_status
Definition tree-ssa-threadupdate.h:146
@ DOMST_DOMINATING
Definition tree-ssa-threadupdate.h:152
@ DOMST_LOOP_BROKEN
Definition tree-ssa-threadupdate.h:150
@ DOMST_NONDOMINATING
Definition tree-ssa-threadupdate.h:148
jump_thread_edge_type
Definition tree-ssa-threadupdate.h:25
@ EDGE_START_JUMP_THREAD
Definition tree-ssa-threadupdate.h:26
@ EDGE_COPY_SRC_JOINER_BLOCK
Definition tree-ssa-threadupdate.h:28
@ EDGE_NO_COPY_SRC_BLOCK
Definition tree-ssa-threadupdate.h:29
@ EDGE_COPY_SRC_BLOCK
Definition tree-ssa-threadupdate.h:27