GCC Middle and Back End API Reference
tree-ssa-threadbackward.h
Go to the documentation of this file.
1/* Header file for the SSA backward jump threader.
2 Copyright (C) 2026 Free Software Foundation, Inc.
3 Contributed by Aldy Hernandez <aldy@quesejoda.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9Software Foundation; either version 3, or (at your option) any later
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for 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 GCC_TREE_SSA_THREADBACKWARD_H
22#define GCC_TREE_SSA_THREADBACKWARD_H
23
24class gimple_ranger;
27
28// Path registry for the backwards threader. After all paths have been
29// registered with register_path(), thread_through_all_blocks() is called
30// to modify the CFG.
31
33{
34public:
35 bool register_path (const vec<basic_block> &, edge taken);
36};
37
38// Back threader flags.
39#define BT_NONE 0
40// Generate fast code at the expense of code size.
41#define BT_SPEED 1
42// Resolve unknown SSAs on entry to a threading path. If set, use the
43// ranger. If not, assume all ranges on entry to a path are VARYING.
44#define BT_RESOLVE 2
45
47{
48public:
49 back_threader (function *fun, unsigned flags, bool first);
50 virtual ~back_threader ();
51 unsigned thread_blocks ();
52 void search ();
53 unsigned apply ();
54protected:
55 // The path solver for the search.
57private:
59 bool debug_counter ();
61 void maybe_register_path_dump (edge taken_edge);
62 void find_paths_to_names (basic_block bb, bitmap imports, unsigned,
68 virtual void debug ();
69 virtual void dump (FILE *out);
70
72
73 // Current path being analyzed.
75 // Flag to mark visited BBs while analyzing a path.
77 // The set of SSA names, any of which could potentially change the
78 // value of the final conditional in a path.
80 // The last statement in the path.
82 // Marker to differentiate unreachable edges.
83 static const edge UNREACHABLE_EDGE;
84 // Set to TRUE if unknown SSA names along a path should be resolved
85 // with the ranger. Otherwise, unknown SSA names are assumed to be
86 // VARYING. Setting to true is more precise but slower.
88 // Ranger for the path solver.
90 // Path solver, reused across all candidate paths.
92 unsigned m_flags;
93 // Set to TRUE for the first of each thread[12] pass or the first of
94 // each threadfull[12] pass. This is used to differentiate between
95 // the different threading passes so we can set up debug counters.
96 bool m_first;
97};
98
99#endif // GCC_TREE_SSA_THREADBACKWARD_H
Definition cfg.h:186
Definition bitmap.h:950
Definition vec.h:1667
back_jt_path_registry()
Definition tree-ssa-threadupdate.cc:240
Definition tree-ssa-threadbackward.cc:53
Definition tree-ssa-threadbackward.h:33
bool register_path(const vec< basic_block > &, edge taken)
Definition tree-ssa-threadbackward.cc:901
unsigned apply()
Definition tree-ssa-threadbackward.cc:950
virtual void dump(FILE *out)
Definition tree-ssa-threadbackward.cc:632
edge find_taken_edge(const vec< basic_block > &path)
Definition tree-ssa-threadbackward.cc:318
unsigned thread_blocks()
Definition tree-ssa-threadbackward.cc:965
void maybe_register_path_dump(edge taken_edge)
Definition tree-ssa-threadbackward.cc:264
edge find_taken_edge_goto(const vec< basic_block > &path, ggoto *)
Definition tree-ssa-threadbackward.cc:340
virtual void debug()
Definition tree-ssa-threadbackward.cc:649
auto_bb_flag m_visited_flag
Definition tree-ssa-threadbackward.h:76
function * m_fun
Definition tree-ssa-threadbackward.h:87
auto_bitmap m_imports
Definition tree-ssa-threadbackward.h:79
virtual path_range_query * make_solver(gimple_ranger &)
Definition tree-ssa-threadbackward.cc:925
void maybe_thread_block(basic_block bb)
Definition tree-ssa-threadbackward.cc:584
static const edge UNREACHABLE_EDGE
Definition tree-ssa-threadbackward.h:83
path_range_query * m_solver
Definition tree-ssa-threadbackward.h:91
edge find_taken_edge_switch(const vec< basic_block > &path, gswitch *)
Definition tree-ssa-threadbackward.cc:369
void find_paths_to_names(basic_block bb, bitmap imports, unsigned, back_threader_profitability &)
Definition tree-ssa-threadbackward.cc:426
auto_vec< basic_block > m_path
Definition tree-ssa-threadbackward.h:74
gimple_ranger * m_ranger
Definition tree-ssa-threadbackward.h:89
bool m_first
Definition tree-ssa-threadbackward.h:96
bool debug_counter()
Definition tree-ssa-threadbackward.cc:224
unsigned m_flags
Definition tree-ssa-threadbackward.h:92
edge maybe_register_path(back_threader_profitability &)
Definition tree-ssa-threadbackward.cc:289
gimple * m_last_stmt
Definition tree-ssa-threadbackward.h:81
void search()
Definition tree-ssa-threadbackward.cc:933
edge find_taken_edge_cond(const vec< basic_block > &path, gcond *)
Definition tree-ssa-threadbackward.cc:394
back_threader(function *fun, unsigned flags, bool first)
Definition tree-ssa-threadbackward.cc:193
back_threader_registry m_registry
Definition tree-ssa-threadbackward.h:71
Definition gimple-range.h:48
Definition gimple-range-path.h:37
struct basic_block_def * basic_block
Definition coretypes.h:359
class edge_def * edge
Definition coretypes.h:356
class bitmap_head * bitmap
Definition coretypes.h:51
Definition function.h:249
Definition gimple.h:864
Definition gimple.h:883
Definition gimple.h:224
Definition gimple.h:901
Definition vec.h:450