GCC Middle and Back End API Reference
ifcvt.h
Go to the documentation of this file.
1/* If-conversion header file.
2 Copyright (C) 2014-2026 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_IFCVT_H
21#define GCC_IFCVT_H
22
23/* Structure to group all of the information to process IF-THEN and
24 IF-THEN-ELSE blocks for the conditional execution support. */
25
27{
28 basic_block test_bb; /* First test block. */
29 basic_block then_bb; /* THEN block. */
30 basic_block else_bb; /* ELSE block or NULL. */
31 basic_block join_bb; /* Join THEN/ELSE blocks. */
32 basic_block last_test_bb; /* Last bb to hold && or || tests. */
33 int num_multiple_test_blocks; /* # of && and || basic blocks. */
34 int num_and_and_blocks; /* # of && blocks. */
35 int num_or_or_blocks; /* # of || blocks. */
36 int num_multiple_test_insns; /* # of insns in && and || blocks. */
37 bool and_and_p; /* Complex test is &&. */
38 int num_then_insns; /* # of insns in THEN block. */
39 int num_else_insns; /* # of insns in ELSE block. */
40 int pass; /* Pass number. */
41};
42
44{
45 /* A list of indices to instructions that we need to rewire into this
46 instruction when we replace them with temporary conditional moves. */
48 /* The true targets for a conditional move. */
50 /* The temporaries introduced to allow us to not consider register
51 overlap. */
53 /* The insn from the original block that this entry describes. */
55 /* True if the destination is live out of the block, so the value has to be
56 selected with a conditional move rather than moved unconditionally. */
58};
59
60/* Used by noce_process_if_block to communicate with its subroutines.
61
62 The subroutines know that A and B may be evaluated freely. They
63 know that X is a register. They should insert new instructions
64 before cond_earliest. */
65
67{
68 /* The basic blocks that make up the IF-THEN-{ELSE-,}JOIN block. */
70
71 /* The jump that ends TEST_BB. */
73
74 /* The jump condition. */
76
77 /* Reversed jump condition. */
79
80 /* New insns should be inserted before this one. */
82
83 /* Insns in the THEN and ELSE block. There is always just this
84 one insn in those blocks. The insns are single_set insns.
85 If there was no ELSE block, INSN_B is the last insn before
86 COND_EARLIEST, or NULL_RTX. In the former case, the insn
87 operands are still valid, as if INSN_B was moved down below
88 the jump. */
90
91 /* The SET_SRC of INSN_A and INSN_B. */
93
94 /* The SET_DEST of INSN_A. */
96
97 /* The original set destination that the THEN and ELSE basic blocks finally
98 write their result to. */
100 /* True if this if block is not canonical. In the canonical form of
101 if blocks, the THEN_BB is the block reached via the fallthru edge
102 from TEST_BB. For the noce transformations, we allow the symmetric
103 form as well. */
105
106 /* True if THEN_BB is conditional on !COND rather than COND.
107 This is used if:
108
109 - JUMP branches to THEN_BB on COND
110 - JUMP falls through to JOIN_BB on !COND
111 - COND cannot be reversed. */
113
114 /* True if the contents of then_bb and else_bb are a
115 simple single set instruction. */
118
119 /* True if we're optimizing the control block for speed, false if
120 we're optimizing for size. */
122
123 /* An estimate of the cost of the original, un-converted if-region. It
124 covers COND and JUMP plus the arms: both arms when optimizing for size,
125 and their branch-probability-weighted average when optimizing for speed,
126 since then only one of them runs. See noce_original_region_cost. */
127 unsigned int original_cost;
128
129 /* Maximum permissible cost for the unconditional sequence we should
130 generate to replace this branch. */
131 unsigned int max_seq_cost;
132
133 /* The name of the noce transform that succeeded in if-converting
134 this structure. Used for debugging. */
135 const char *transform_name;
136};
137
138#endif /* GCC_IFCVT_H */
Definition vec.h:1667
struct basic_block_def * basic_block
Definition coretypes.h:351
struct rtx_def * rtx
Definition coretypes.h:57
Definition ifcvt.h:27
int num_multiple_test_insns
Definition ifcvt.h:36
basic_block test_bb
Definition ifcvt.h:28
int num_or_or_blocks
Definition ifcvt.h:35
int num_multiple_test_blocks
Definition ifcvt.h:33
int num_then_insns
Definition ifcvt.h:38
int num_else_insns
Definition ifcvt.h:39
int num_and_and_blocks
Definition ifcvt.h:34
basic_block else_bb
Definition ifcvt.h:30
basic_block last_test_bb
Definition ifcvt.h:32
bool and_and_p
Definition ifcvt.h:37
basic_block then_bb
Definition ifcvt.h:29
basic_block join_bb
Definition ifcvt.h:31
int pass
Definition ifcvt.h:40
Definition ifcvt.h:67
unsigned int max_seq_cost
Definition ifcvt.h:131
bool speed_p
Definition ifcvt.h:121
bool then_else_reversed
Definition ifcvt.h:104
rtx rev_cond
Definition ifcvt.h:78
basic_block test_bb
Definition ifcvt.h:69
basic_block else_bb
Definition ifcvt.h:69
rtx_insn * insn_a
Definition ifcvt.h:89
rtx_insn * cond_earliest
Definition ifcvt.h:81
rtx orig_x
Definition ifcvt.h:99
rtx b
Definition ifcvt.h:92
rtx x
Definition ifcvt.h:95
basic_block then_bb
Definition ifcvt.h:69
bool else_simple
Definition ifcvt.h:117
bool cond_inverted
Definition ifcvt.h:112
rtx cond
Definition ifcvt.h:75
rtx_insn * jump
Definition ifcvt.h:72
bool then_simple
Definition ifcvt.h:116
basic_block join_bb
Definition ifcvt.h:69
rtx_insn * insn_b
Definition ifcvt.h:89
unsigned int original_cost
Definition ifcvt.h:127
rtx a
Definition ifcvt.h:92
const char * transform_name
Definition ifcvt.h:135
Definition ifcvt.h:44
rtx target
Definition ifcvt.h:49
bool need_cmov
Definition ifcvt.h:57
auto_vec< int > rewired_src
Definition ifcvt.h:47
rtx temporary
Definition ifcvt.h:52
rtx_insn * unmodified_insn
Definition ifcvt.h:54
Definition rtl.h:549