1 /* Communication between registering jump thread requests and
2 updating the SSA/CFG for jump threading.
3 Copyright (C) 2013-2021 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef _TREE_SSA_THREADUPDATE_H
22 #define _TREE_SSA_THREADUPDATE_H 1
24 enum jump_thread_edge_type
26 EDGE_START_JUMP_THREAD
,
29 EDGE_COPY_SRC_JOINER_BLOCK
,
30 EDGE_NO_COPY_SRC_BLOCK
33 // We keep the registered jump threading opportunities in this
34 // vector as edge pairs (original_edge, target_edge).
36 class jump_thread_edge
39 jump_thread_edge (edge e
, jump_thread_edge_type t
) : e (e
), type (t
) {}
42 jump_thread_edge_type type
;
45 class jump_thread_path_allocator
48 jump_thread_path_allocator ();
49 ~jump_thread_path_allocator ();
50 jump_thread_edge
*allocate_thread_edge (edge
, jump_thread_edge_type
);
51 vec
<jump_thread_edge
*> *allocate_thread_path ();
53 DISABLE_COPY_AND_ASSIGN (jump_thread_path_allocator
);
57 // This is the underlying jump thread registry. When all candidates
58 // have been registered with register_jump_thread(),
59 // thread_through_all_blocks() is called to actually change the CFG.
61 class jump_thread_path_registry
64 jump_thread_path_registry ();
65 ~jump_thread_path_registry ();
66 void register_jump_thread (vec
<jump_thread_edge
*> *);
67 void remove_jump_threads_including (edge
);
68 bool thread_through_all_blocks (bool);
69 jump_thread_edge
*allocate_thread_edge (edge e
, jump_thread_edge_type t
);
70 vec
<jump_thread_edge
*> *allocate_thread_path ();
74 void debug_path (FILE *, int pathno
);
75 void mark_threaded_blocks (bitmap threaded_blocks
);
76 bool rewire_first_differing_edge (unsigned path_num
, unsigned edge_num
);
77 void adjust_paths_after_duplication (unsigned curr_path_num
);
78 bool duplicate_thread_path (edge entry
,
82 unsigned current_path_no
);
83 bool thread_block_1 (basic_block
, bool noloop_only
, bool joiners
);
84 bool thread_block (basic_block
, bool noloop_only
);
85 bool thread_through_loop_header (class loop
*loop
,
86 bool may_peel_loop_headers
);
87 class redirection_data
*lookup_redirection_data (edge e
, enum insert_option
);
89 vec
<vec
<jump_thread_edge
*> *> m_paths
;
91 hash_table
<struct removed_edges
> *m_removed_edges
;
93 // Main data structure to hold information for duplicates of BB.
94 hash_table
<redirection_data
> *m_redirection_data
;
96 // Jump threading statistics.
97 unsigned long m_num_threaded_edges
;
99 jump_thread_path_allocator m_allocator
;
102 // Rather than search all the edges in jump thread paths each time DOM
103 // is able to simply if control statement, we build a hash table with
104 // the deleted edges. We only care about the address of the edge, not
106 struct removed_edges
: nofree_ptr_hash
<edge_def
>
108 static hashval_t
hash (edge e
) { return htab_hash_pointer (e
); }
109 static bool equal (edge e1
, edge e2
) { return e1
== e2
; }
112 extern unsigned int estimate_threading_killed_stmts (basic_block
);
116 /* BB does not dominate latch of the LOOP. */
118 /* The LOOP is broken (there is no path from the header to its latch. */
120 /* BB dominates the latch of the LOOP. */
124 enum bb_dom_status
determine_bb_domination_status (class loop
*, basic_block
);
126 // In tree-ssa-dom.c.
127 extern void free_dom_edge_info (edge
);