]> gcc.gnu.org Git - gcc.git/blame - gcc/loop.h
reload1.c (struct elim_table): Delete MAX_OFFSET member.
[gcc.git] / gcc / loop.h
CommitLineData
23b2ce53 1/* Loop optimization definitions for GNU C-Compiler
cac8ce95 2 Copyright (C) 1991, 1995, 1998 Free Software Foundation, Inc.
23b2ce53
RS
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
a35311b0
RK
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */
23b2ce53
RS
20
21/* Get the luid of an insn. Catch the error of trying to reference the LUID
22 of an insn added during loop, since these don't have LUIDs. */
23
24#define INSN_LUID(INSN) \
25 (INSN_UID (INSN) < max_uid_for_loop ? uid_luid[INSN_UID (INSN)] \
26 : (abort (), -1))
27
28/* A "basic induction variable" or biv is a pseudo reg that is set
29 (within this loop) only by incrementing or decrementing it. */
30/* A "general induction variable" or giv is a pseudo reg whose
31 value is a linear function of a biv. */
32
33/* Bivs are recognized by `basic_induction_var';
34 Givs by `general_induct_var'. */
35
36/* An enum for the two different types of givs, those that are used
37 as memory addresses and those that are calculated into registers. */
38enum g_types { DEST_ADDR, DEST_REG };
39
40/* A `struct induction' is created for every instruction that sets
41 an induction variable (either a biv or a giv). */
42
43struct induction
44{
45 rtx insn; /* The insn that sets a biv or giv */
46 rtx new_reg; /* New register, containing strength reduced
47 version of this giv. */
48 rtx src_reg; /* Biv from which this giv is computed.
49 (If this is a biv, then this is the biv.) */
50 enum g_types giv_type; /* Indicate whether DEST_ADDR or DEST_REG */
51 rtx dest_reg; /* Destination register for insn: this is the
52 register which was the biv or giv.
53 For a biv, this equals src_reg.
54 For a DEST_ADDR type giv, this is 0. */
55 rtx *location; /* Place in the insn where this giv occurs.
56 If GIV_TYPE is DEST_REG, this is 0. */
57 enum machine_mode mode; /* The mode of this biv or giv */
58 enum machine_mode mem_mode; /* For DEST_ADDR, mode of the memory object. */
59 rtx mult_val; /* Multiplicative factor for src_reg. */
60 rtx add_val; /* Additive constant for that product. */
61 int benefit; /* Gain from eliminating this insn. */
62 rtx final_value; /* If the giv is used outside the loop, and its
63 final value could be calculated, it is put
64 here, and the giv is made replaceable. Set
65 the giv to this value before the loop. */
66 unsigned replaceable : 1; /* 1 if we can substitute the strength-reduced
67 variable for the original variable.
68 0 means they must be kept separate and the
69 new one must be copied into the old pseudo
70 reg each time the old one is set. */
71 unsigned not_replaceable : 1; /* Used to prevent duplicating work. This is
72 1 if we know that the giv definitely can
73 not be made replaceable, in which case we
74 don't bother checking the variable again
75 even if further info is available.
76 Both this and the above can be zero. */
77 unsigned ignore : 1; /* 1 prohibits further processing of giv */
125e4dcf
JW
78 unsigned always_computable : 1;/* 1 if this value is computable every
79 iteration. */
80 unsigned always_executed : 1; /* 1 if this set occurs each iteration. */
8fd297fb
RK
81 unsigned maybe_multiple : 1; /* Only used for a biv and 1 if this biv
82 update may be done multiple times per
83 iteration. */
23b2ce53
RS
84 unsigned cant_derive : 1; /* For giv's, 1 if this giv cannot derive
85 another giv. This occurs in many cases
86 where a giv's lifetime spans an update to
87 a biv. */
88 unsigned combined_with : 1; /* 1 if this giv has been combined with. It
89 then cannot combine with any other giv. */
90 unsigned maybe_dead : 1; /* 1 if this giv might be dead. In that case,
91 we won't use it to eliminate a biv, it
92 would probably lose. */
125e4dcf
JW
93 unsigned auto_inc_opt : 1; /* 1 if this giv had its increment output next
94 to it to try to form an auto-inc address. */
7e7ca3a1
JW
95 unsigned unrolled : 1; /* 1 if new register has been allocated and
96 initialized in unrolled loop. */
9ae8ffe7 97 unsigned shared : 1;
45f97e2e 98 unsigned no_const_addval : 1; /* 1 if add_val does not contain a const. */
23b2ce53
RS
99 int lifetime; /* Length of life of this giv */
100 int times_used; /* # times this giv is used. */
101 rtx derive_adjustment; /* If nonzero, is an adjustment to be
102 subtracted from add_val when this giv
103 derives another. This occurs when the
104 giv spans a biv update by incrementation. */
105 struct induction *next_iv; /* For givs, links together all givs that are
106 based on the same biv. For bivs, links
107 together all biv entries that refer to the
108 same biv register. */
109 struct induction *same; /* If this giv has been combined with another
110 giv, this points to the base giv. The base
111 giv will have COMBINED_WITH non-zero. */
3245eea0 112 HOST_WIDE_INT const_adjust; /* Used by loop unrolling, when an address giv
23b2ce53
RS
113 is split, and a constant is eliminated from
114 the address, the -constant is stored here
115 for later use. */
2a2af110
JW
116 struct induction *same_insn; /* If there are multiple identical givs in
117 the same insn, then all but one have this
118 field set, and they all point to the giv
119 that doesn't have this field set. */
23b2ce53
RS
120};
121
122/* A `struct iv_class' is created for each biv. */
123
124struct iv_class {
125 int regno; /* Pseudo reg which is the biv. */
126 int biv_count; /* Number of insns setting this reg. */
127 struct induction *biv; /* List of all insns that set this reg. */
128 int giv_count; /* Number of DEST_REG givs computed from this
129 biv. The resulting count is only used in
130 check_dbra_loop. */
131 struct induction *giv; /* List of all insns that compute a giv
132 from this reg. */
133 int total_benefit; /* Sum of BENEFITs of all those givs */
134 rtx initial_value; /* Value of reg at loop start */
135 rtx initial_test; /* Test performed on BIV before loop */
136 struct iv_class *next; /* Links all class structures together */
6dc42e49 137 rtx init_insn; /* insn which initializes biv, 0 if none. */
23b2ce53
RS
138 rtx init_set; /* SET of INIT_INSN, if any. */
139 unsigned incremented : 1; /* 1 if somewhere incremented/decremented */
140 unsigned eliminable : 1; /* 1 if plausible candidate for elimination. */
141 unsigned nonneg : 1; /* 1 if we added a REG_NONNEG note for this. */
142 unsigned reversed : 1; /* 1 if we reversed the loop that this
143 biv controls. */
144};
145
146/* Definitions used by the basic induction variable discovery code. */
147enum iv_mode { UNKNOWN_INDUCT, BASIC_INDUCT, NOT_BASIC_INDUCT,
148 GENERAL_INDUCT };
149
150/* Variables declared in loop.c, but also needed in unroll.c. */
151
152extern int *uid_luid;
153extern int max_uid_for_loop;
154extern int *uid_loop_num;
155extern int *loop_outer_loop;
156extern rtx *loop_number_exit_labels;
85ee7452 157extern int *loop_number_exit_count;
3245eea0 158extern unsigned HOST_WIDE_INT loop_n_iterations;
23b2ce53
RS
159extern int max_reg_before_loop;
160
161extern FILE *loop_dump_stream;
162
163extern enum iv_mode *reg_iv_type;
164extern struct induction **reg_iv_info;
165extern struct iv_class **reg_biv_class;
166extern struct iv_class *loop_iv_list;
167
168/* Forward declarations for non-static functions declared in loop.c and
169 unroll.c. */
521f2d6f
JW
170int invariant_p PROTO((rtx));
171rtx get_condition_for_loop PROTO((rtx));
172void emit_iv_add_mult PROTO((rtx, rtx, rtx, rtx, rtx));
23b2ce53 173
23b2ce53 174/* Forward declarations for non-static functions declared in stmt.c. */
521f2d6f
JW
175void find_loop_tree_blocks PROTO((void));
176void unroll_block_trees PROTO((void));
177
178void unroll_loop PROTO((rtx, int, rtx, rtx, int));
179rtx biv_total_increment PROTO((struct iv_class *, rtx, rtx));
180unsigned HOST_WIDE_INT loop_iterations PROTO((rtx, rtx));
181rtx final_biv_value PROTO((struct iv_class *, rtx, rtx));
182rtx final_giv_value PROTO((struct induction *, rtx, rtx));
183void emit_unrolled_add PROTO((rtx, rtx, rtx));
09dcbd74 184int back_branch_in_range_p PROTO((rtx, rtx, rtx));
8c660648 185
237a9795 186extern int *loop_unroll_factor;
cac8ce95
DE
187
188#ifdef HAVE_decrement_and_branch_on_count
189extern rtx loop_iteration_var;
190extern rtx loop_initial_value;
191extern rtx loop_increment;
192extern rtx loop_final_value;
193extern enum rtx_code loop_comparison_code;
194#endif /* HAVE_decrement_and_branch_on_count */
8c660648 195
This page took 0.592886 seconds and 5 git commands to generate.