tree-vectorizer.h revision 1.3 1 1.1 mrg /* Vectorizer
2 1.3 mrg Copyright (C) 2003-2013 Free Software Foundation, Inc.
3 1.1 mrg Contributed by Dorit Naishlos <dorit (at) il.ibm.com>
4 1.1 mrg
5 1.1 mrg This file is part of GCC.
6 1.1 mrg
7 1.1 mrg GCC is free software; you can redistribute it and/or modify it under
8 1.1 mrg the terms of the GNU General Public License as published by the Free
9 1.1 mrg Software Foundation; either version 3, or (at your option) any later
10 1.1 mrg version.
11 1.1 mrg
12 1.1 mrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 1.1 mrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 1.1 mrg FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 1.1 mrg for more details.
16 1.1 mrg
17 1.1 mrg You should have received a copy of the GNU General Public License
18 1.1 mrg along with GCC; see the file COPYING3. If not see
19 1.1 mrg <http://www.gnu.org/licenses/>. */
20 1.1 mrg
21 1.1 mrg #ifndef GCC_TREE_VECTORIZER_H
22 1.1 mrg #define GCC_TREE_VECTORIZER_H
23 1.1 mrg
24 1.1 mrg #include "tree-data-ref.h"
25 1.3 mrg #include "target.h"
26 1.1 mrg
27 1.1 mrg typedef source_location LOC;
28 1.1 mrg #define UNKNOWN_LOC UNKNOWN_LOCATION
29 1.1 mrg #define EXPR_LOC(e) EXPR_LOCATION(e)
30 1.1 mrg #define LOC_FILE(l) LOCATION_FILE (l)
31 1.1 mrg #define LOC_LINE(l) LOCATION_LINE (l)
32 1.1 mrg
33 1.1 mrg /* Used for naming of new temporaries. */
34 1.1 mrg enum vect_var_kind {
35 1.1 mrg vect_simple_var,
36 1.1 mrg vect_pointer_var,
37 1.1 mrg vect_scalar_var
38 1.1 mrg };
39 1.1 mrg
40 1.1 mrg /* Defines type of operation. */
41 1.1 mrg enum operation_type {
42 1.1 mrg unary_op = 1,
43 1.1 mrg binary_op,
44 1.1 mrg ternary_op
45 1.1 mrg };
46 1.1 mrg
47 1.1 mrg /* Define type of available alignment support. */
48 1.1 mrg enum dr_alignment_support {
49 1.1 mrg dr_unaligned_unsupported,
50 1.1 mrg dr_unaligned_supported,
51 1.1 mrg dr_explicit_realign,
52 1.1 mrg dr_explicit_realign_optimized,
53 1.1 mrg dr_aligned
54 1.1 mrg };
55 1.1 mrg
56 1.1 mrg /* Define type of def-use cross-iteration cycle. */
57 1.1 mrg enum vect_def_type {
58 1.1 mrg vect_uninitialized_def = 0,
59 1.1 mrg vect_constant_def = 1,
60 1.1 mrg vect_external_def,
61 1.1 mrg vect_internal_def,
62 1.1 mrg vect_induction_def,
63 1.1 mrg vect_reduction_def,
64 1.1 mrg vect_double_reduction_def,
65 1.1 mrg vect_nested_cycle,
66 1.1 mrg vect_unknown_def_type
67 1.1 mrg };
68 1.1 mrg
69 1.1 mrg #define VECTORIZABLE_CYCLE_DEF(D) (((D) == vect_reduction_def) \
70 1.1 mrg || ((D) == vect_double_reduction_def) \
71 1.1 mrg || ((D) == vect_nested_cycle))
72 1.1 mrg
73 1.3 mrg /* Structure to encapsulate information about a group of like
74 1.3 mrg instructions to be presented to the target cost model. */
75 1.3 mrg typedef struct _stmt_info_for_cost {
76 1.3 mrg int count;
77 1.3 mrg enum vect_cost_for_stmt kind;
78 1.3 mrg gimple stmt;
79 1.3 mrg int misalign;
80 1.3 mrg } stmt_info_for_cost;
81 1.3 mrg
82 1.3 mrg
83 1.3 mrg typedef vec<stmt_info_for_cost> stmt_vector_for_cost;
84 1.3 mrg
85 1.3 mrg static inline void
86 1.3 mrg add_stmt_info_to_vec (stmt_vector_for_cost *stmt_cost_vec, int count,
87 1.3 mrg enum vect_cost_for_stmt kind, gimple stmt, int misalign)
88 1.3 mrg {
89 1.3 mrg stmt_info_for_cost si;
90 1.3 mrg si.count = count;
91 1.3 mrg si.kind = kind;
92 1.3 mrg si.stmt = stmt;
93 1.3 mrg si.misalign = misalign;
94 1.3 mrg stmt_cost_vec->safe_push (si);
95 1.3 mrg }
96 1.1 mrg
97 1.1 mrg /************************************************************************
98 1.1 mrg SLP
99 1.1 mrg ************************************************************************/
100 1.3 mrg typedef void *slp_void_p;
101 1.1 mrg
102 1.3 mrg /* A computation tree of an SLP instance. Each node corresponds to a group of
103 1.1 mrg stmts to be packed in a SIMD stmt. */
104 1.1 mrg typedef struct _slp_tree {
105 1.3 mrg /* Nodes that contain def-stmts of this node statements operands. */
106 1.3 mrg vec<slp_void_p> children;
107 1.1 mrg /* A group of scalar stmts to be vectorized together. */
108 1.3 mrg vec<gimple> stmts;
109 1.1 mrg /* Vectorized stmt/s. */
110 1.3 mrg vec<gimple> vec_stmts;
111 1.1 mrg /* Number of vector stmts that are created to replace the group of scalar
112 1.1 mrg stmts. It is calculated during the transformation phase as the number of
113 1.1 mrg scalar elements in one scalar iteration (GROUP_SIZE) multiplied by VF
114 1.1 mrg divided by vector size. */
115 1.1 mrg unsigned int vec_stmts_size;
116 1.1 mrg } *slp_tree;
117 1.1 mrg
118 1.1 mrg
119 1.1 mrg /* SLP instance is a sequence of stmts in a loop that can be packed into
120 1.1 mrg SIMD stmts. */
121 1.1 mrg typedef struct _slp_instance {
122 1.1 mrg /* The root of SLP tree. */
123 1.1 mrg slp_tree root;
124 1.1 mrg
125 1.1 mrg /* Size of groups of scalar stmts that will be replaced by SIMD stmt/s. */
126 1.1 mrg unsigned int group_size;
127 1.1 mrg
128 1.1 mrg /* The unrolling factor required to vectorized this SLP instance. */
129 1.1 mrg unsigned int unrolling_factor;
130 1.1 mrg
131 1.1 mrg /* Vectorization costs associated with SLP instance. */
132 1.3 mrg stmt_vector_for_cost body_cost_vec;
133 1.1 mrg
134 1.1 mrg /* Loads permutation relatively to the stores, NULL if there is no
135 1.1 mrg permutation. */
136 1.3 mrg vec<int> load_permutation;
137 1.1 mrg
138 1.1 mrg /* The group of nodes that contain loads of this SLP instance. */
139 1.3 mrg vec<slp_tree> loads;
140 1.1 mrg
141 1.1 mrg /* The first scalar load of the instance. The created vector loads will be
142 1.1 mrg inserted before this statement. */
143 1.1 mrg gimple first_load;
144 1.1 mrg } *slp_instance;
145 1.1 mrg
146 1.1 mrg
147 1.1 mrg /* Access Functions. */
148 1.1 mrg #define SLP_INSTANCE_TREE(S) (S)->root
149 1.1 mrg #define SLP_INSTANCE_GROUP_SIZE(S) (S)->group_size
150 1.1 mrg #define SLP_INSTANCE_UNROLLING_FACTOR(S) (S)->unrolling_factor
151 1.3 mrg #define SLP_INSTANCE_BODY_COST_VEC(S) (S)->body_cost_vec
152 1.1 mrg #define SLP_INSTANCE_LOAD_PERMUTATION(S) (S)->load_permutation
153 1.1 mrg #define SLP_INSTANCE_LOADS(S) (S)->loads
154 1.1 mrg #define SLP_INSTANCE_FIRST_LOAD_STMT(S) (S)->first_load
155 1.1 mrg
156 1.3 mrg #define SLP_TREE_CHILDREN(S) (S)->children
157 1.1 mrg #define SLP_TREE_SCALAR_STMTS(S) (S)->stmts
158 1.1 mrg #define SLP_TREE_VEC_STMTS(S) (S)->vec_stmts
159 1.1 mrg #define SLP_TREE_NUMBER_OF_VEC_STMTS(S) (S)->vec_stmts_size
160 1.3 mrg
161 1.3 mrg /* This structure is used in creation of an SLP tree. Each instance
162 1.3 mrg corresponds to the same operand in a group of scalar stmts in an SLP
163 1.3 mrg node. */
164 1.3 mrg typedef struct _slp_oprnd_info
165 1.3 mrg {
166 1.3 mrg /* Def-stmts for the operands. */
167 1.3 mrg vec<gimple> def_stmts;
168 1.3 mrg /* Information about the first statement, its vector def-type, type, the
169 1.3 mrg operand itself in case it's constant, and an indication if it's a pattern
170 1.3 mrg stmt. */
171 1.3 mrg enum vect_def_type first_dt;
172 1.3 mrg tree first_def_type;
173 1.3 mrg tree first_const_oprnd;
174 1.3 mrg bool first_pattern;
175 1.3 mrg } *slp_oprnd_info;
176 1.3 mrg
177 1.3 mrg
178 1.3 mrg
179 1.3 mrg typedef struct _vect_peel_info
180 1.3 mrg {
181 1.3 mrg int npeel;
182 1.3 mrg struct data_reference *dr;
183 1.3 mrg unsigned int count;
184 1.3 mrg } *vect_peel_info;
185 1.3 mrg
186 1.3 mrg typedef struct _vect_peel_extended_info
187 1.3 mrg {
188 1.3 mrg struct _vect_peel_info peel_info;
189 1.3 mrg unsigned int inside_cost;
190 1.3 mrg unsigned int outside_cost;
191 1.3 mrg stmt_vector_for_cost body_cost_vec;
192 1.3 mrg } *vect_peel_extended_info;
193 1.1 mrg
194 1.1 mrg /*-----------------------------------------------------------------*/
195 1.1 mrg /* Info on vectorized loops. */
196 1.1 mrg /*-----------------------------------------------------------------*/
197 1.1 mrg typedef struct _loop_vec_info {
198 1.1 mrg
199 1.1 mrg /* The loop to which this info struct refers to. */
200 1.1 mrg struct loop *loop;
201 1.1 mrg
202 1.1 mrg /* The loop basic blocks. */
203 1.1 mrg basic_block *bbs;
204 1.1 mrg
205 1.1 mrg /* Number of iterations. */
206 1.1 mrg tree num_iters;
207 1.1 mrg tree num_iters_unchanged;
208 1.1 mrg
209 1.1 mrg /* Minimum number of iterations below which vectorization is expected to
210 1.1 mrg not be profitable (as estimated by the cost model).
211 1.1 mrg -1 indicates that vectorization will not be profitable.
212 1.1 mrg FORNOW: This field is an int. Will be a tree in the future, to represent
213 1.1 mrg values unknown at compile time. */
214 1.1 mrg int min_profitable_iters;
215 1.1 mrg
216 1.1 mrg /* Is the loop vectorizable? */
217 1.1 mrg bool vectorizable;
218 1.1 mrg
219 1.1 mrg /* Unrolling factor */
220 1.1 mrg int vectorization_factor;
221 1.1 mrg
222 1.3 mrg /* The loop location in the source. */
223 1.3 mrg LOC loop_line_number;
224 1.3 mrg
225 1.1 mrg /* Unknown DRs according to which loop was peeled. */
226 1.1 mrg struct data_reference *unaligned_dr;
227 1.1 mrg
228 1.1 mrg /* peeling_for_alignment indicates whether peeling for alignment will take
229 1.1 mrg place, and what the peeling factor should be:
230 1.1 mrg peeling_for_alignment = X means:
231 1.1 mrg If X=0: Peeling for alignment will not be applied.
232 1.1 mrg If X>0: Peel first X iterations.
233 1.1 mrg If X=-1: Generate a runtime test to calculate the number of iterations
234 1.1 mrg to be peeled, using the dataref recorded in the field
235 1.1 mrg unaligned_dr. */
236 1.1 mrg int peeling_for_alignment;
237 1.1 mrg
238 1.1 mrg /* The mask used to check the alignment of pointers or arrays. */
239 1.1 mrg int ptr_mask;
240 1.1 mrg
241 1.3 mrg /* The loop nest in which the data dependences are computed. */
242 1.3 mrg vec<loop_p> loop_nest;
243 1.3 mrg
244 1.1 mrg /* All data references in the loop. */
245 1.3 mrg vec<data_reference_p> datarefs;
246 1.1 mrg
247 1.1 mrg /* All data dependences in the loop. */
248 1.3 mrg vec<ddr_p> ddrs;
249 1.1 mrg
250 1.1 mrg /* Data Dependence Relations defining address ranges that are candidates
251 1.1 mrg for a run-time aliasing check. */
252 1.3 mrg vec<ddr_p> may_alias_ddrs;
253 1.1 mrg
254 1.1 mrg /* Statements in the loop that have data references that are candidates for a
255 1.1 mrg runtime (loop versioning) misalignment check. */
256 1.3 mrg vec<gimple> may_misalign_stmts;
257 1.1 mrg
258 1.1 mrg /* All interleaving chains of stores in the loop, represented by the first
259 1.1 mrg stmt in the chain. */
260 1.3 mrg vec<gimple> grouped_stores;
261 1.1 mrg
262 1.3 mrg /* All SLP instances in the loop. This is a subset of the set of GROUP_STORES
263 1.1 mrg of the loop. */
264 1.3 mrg vec<slp_instance> slp_instances;
265 1.1 mrg
266 1.1 mrg /* The unrolling factor needed to SLP the loop. In case of that pure SLP is
267 1.1 mrg applied to the loop, i.e., no unrolling is needed, this is 1. */
268 1.1 mrg unsigned slp_unrolling_factor;
269 1.1 mrg
270 1.3 mrg /* Reduction cycles detected in the loop. Used in loop-aware SLP. */
271 1.3 mrg vec<gimple> reductions;
272 1.3 mrg
273 1.3 mrg /* All reduction chains in the loop, represented by the first
274 1.3 mrg stmt in the chain. */
275 1.3 mrg vec<gimple> reduction_chains;
276 1.3 mrg
277 1.3 mrg /* Hash table used to choose the best peeling option. */
278 1.3 mrg htab_t peeling_htab;
279 1.3 mrg
280 1.3 mrg /* Cost data used by the target cost model. */
281 1.3 mrg void *target_cost_data;
282 1.3 mrg
283 1.3 mrg /* When we have grouped data accesses with gaps, we may introduce invalid
284 1.1 mrg memory accesses. We peel the last iteration of the loop to prevent
285 1.1 mrg this. */
286 1.1 mrg bool peeling_for_gaps;
287 1.1 mrg
288 1.3 mrg /* Reductions are canonicalized so that the last operand is the reduction
289 1.3 mrg operand. If this places a constant into RHS1, this decanonicalizes
290 1.3 mrg GIMPLE for other phases, so we must track when this has occurred and
291 1.3 mrg fix it up. */
292 1.3 mrg bool operands_swapped;
293 1.3 mrg
294 1.1 mrg } *loop_vec_info;
295 1.1 mrg
296 1.1 mrg /* Access Functions. */
297 1.1 mrg #define LOOP_VINFO_LOOP(L) (L)->loop
298 1.1 mrg #define LOOP_VINFO_BBS(L) (L)->bbs
299 1.1 mrg #define LOOP_VINFO_NITERS(L) (L)->num_iters
300 1.1 mrg /* Since LOOP_VINFO_NITERS can change after prologue peeling
301 1.1 mrg retain total unchanged scalar loop iterations for cost model. */
302 1.1 mrg #define LOOP_VINFO_NITERS_UNCHANGED(L) (L)->num_iters_unchanged
303 1.1 mrg #define LOOP_VINFO_COST_MODEL_MIN_ITERS(L) (L)->min_profitable_iters
304 1.1 mrg #define LOOP_VINFO_VECTORIZABLE_P(L) (L)->vectorizable
305 1.1 mrg #define LOOP_VINFO_VECT_FACTOR(L) (L)->vectorization_factor
306 1.1 mrg #define LOOP_VINFO_PTR_MASK(L) (L)->ptr_mask
307 1.3 mrg #define LOOP_VINFO_LOOP_NEST(L) (L)->loop_nest
308 1.1 mrg #define LOOP_VINFO_DATAREFS(L) (L)->datarefs
309 1.1 mrg #define LOOP_VINFO_DDRS(L) (L)->ddrs
310 1.1 mrg #define LOOP_VINFO_INT_NITERS(L) (TREE_INT_CST_LOW ((L)->num_iters))
311 1.1 mrg #define LOOP_PEELING_FOR_ALIGNMENT(L) (L)->peeling_for_alignment
312 1.1 mrg #define LOOP_VINFO_UNALIGNED_DR(L) (L)->unaligned_dr
313 1.1 mrg #define LOOP_VINFO_MAY_MISALIGN_STMTS(L) (L)->may_misalign_stmts
314 1.1 mrg #define LOOP_VINFO_LOC(L) (L)->loop_line_number
315 1.1 mrg #define LOOP_VINFO_MAY_ALIAS_DDRS(L) (L)->may_alias_ddrs
316 1.3 mrg #define LOOP_VINFO_GROUPED_STORES(L) (L)->grouped_stores
317 1.1 mrg #define LOOP_VINFO_SLP_INSTANCES(L) (L)->slp_instances
318 1.1 mrg #define LOOP_VINFO_SLP_UNROLLING_FACTOR(L) (L)->slp_unrolling_factor
319 1.3 mrg #define LOOP_VINFO_REDUCTIONS(L) (L)->reductions
320 1.3 mrg #define LOOP_VINFO_REDUCTION_CHAINS(L) (L)->reduction_chains
321 1.3 mrg #define LOOP_VINFO_PEELING_HTAB(L) (L)->peeling_htab
322 1.3 mrg #define LOOP_VINFO_TARGET_COST_DATA(L) (L)->target_cost_data
323 1.1 mrg #define LOOP_VINFO_PEELING_FOR_GAPS(L) (L)->peeling_for_gaps
324 1.3 mrg #define LOOP_VINFO_OPERANDS_SWAPPED(L) (L)->operands_swapped
325 1.1 mrg
326 1.1 mrg #define LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT(L) \
327 1.3 mrg ((L)->may_misalign_stmts.length () > 0)
328 1.1 mrg #define LOOP_REQUIRES_VERSIONING_FOR_ALIAS(L) \
329 1.3 mrg ((L)->may_alias_ddrs.length () > 0)
330 1.1 mrg
331 1.1 mrg #define NITERS_KNOWN_P(n) \
332 1.1 mrg (host_integerp ((n),0) \
333 1.1 mrg && TREE_INT_CST_LOW ((n)) > 0)
334 1.1 mrg
335 1.1 mrg #define LOOP_VINFO_NITERS_KNOWN_P(L) \
336 1.1 mrg NITERS_KNOWN_P((L)->num_iters)
337 1.1 mrg
338 1.1 mrg static inline loop_vec_info
339 1.1 mrg loop_vec_info_for_loop (struct loop *loop)
340 1.1 mrg {
341 1.1 mrg return (loop_vec_info) loop->aux;
342 1.1 mrg }
343 1.1 mrg
344 1.1 mrg static inline bool
345 1.1 mrg nested_in_vect_loop_p (struct loop *loop, gimple stmt)
346 1.1 mrg {
347 1.1 mrg return (loop->inner
348 1.1 mrg && (loop->inner == (gimple_bb (stmt))->loop_father));
349 1.1 mrg }
350 1.1 mrg
351 1.1 mrg typedef struct _bb_vec_info {
352 1.1 mrg
353 1.1 mrg basic_block bb;
354 1.1 mrg /* All interleaving chains of stores in the basic block, represented by the
355 1.1 mrg first stmt in the chain. */
356 1.3 mrg vec<gimple> grouped_stores;
357 1.1 mrg
358 1.1 mrg /* All SLP instances in the basic block. This is a subset of the set of
359 1.3 mrg GROUP_STORES of the basic block. */
360 1.3 mrg vec<slp_instance> slp_instances;
361 1.1 mrg
362 1.1 mrg /* All data references in the basic block. */
363 1.3 mrg vec<data_reference_p> datarefs;
364 1.1 mrg
365 1.1 mrg /* All data dependences in the basic block. */
366 1.3 mrg vec<ddr_p> ddrs;
367 1.3 mrg
368 1.3 mrg /* Cost data used by the target cost model. */
369 1.3 mrg void *target_cost_data;
370 1.3 mrg
371 1.1 mrg } *bb_vec_info;
372 1.1 mrg
373 1.3 mrg #define BB_VINFO_BB(B) (B)->bb
374 1.3 mrg #define BB_VINFO_GROUPED_STORES(B) (B)->grouped_stores
375 1.3 mrg #define BB_VINFO_SLP_INSTANCES(B) (B)->slp_instances
376 1.3 mrg #define BB_VINFO_DATAREFS(B) (B)->datarefs
377 1.3 mrg #define BB_VINFO_DDRS(B) (B)->ddrs
378 1.3 mrg #define BB_VINFO_TARGET_COST_DATA(B) (B)->target_cost_data
379 1.1 mrg
380 1.1 mrg static inline bb_vec_info
381 1.1 mrg vec_info_for_bb (basic_block bb)
382 1.1 mrg {
383 1.1 mrg return (bb_vec_info) bb->aux;
384 1.1 mrg }
385 1.1 mrg
386 1.1 mrg /*-----------------------------------------------------------------*/
387 1.1 mrg /* Info on vectorized defs. */
388 1.1 mrg /*-----------------------------------------------------------------*/
389 1.1 mrg enum stmt_vec_info_type {
390 1.1 mrg undef_vec_info_type = 0,
391 1.1 mrg load_vec_info_type,
392 1.1 mrg store_vec_info_type,
393 1.1 mrg shift_vec_info_type,
394 1.1 mrg op_vec_info_type,
395 1.1 mrg call_vec_info_type,
396 1.1 mrg assignment_vec_info_type,
397 1.1 mrg condition_vec_info_type,
398 1.1 mrg reduc_vec_info_type,
399 1.1 mrg induc_vec_info_type,
400 1.1 mrg type_promotion_vec_info_type,
401 1.1 mrg type_demotion_vec_info_type,
402 1.1 mrg type_conversion_vec_info_type,
403 1.1 mrg loop_exit_ctrl_vec_info_type
404 1.1 mrg };
405 1.1 mrg
406 1.1 mrg /* Indicates whether/how a variable is used in the scope of loop/basic
407 1.1 mrg block. */
408 1.1 mrg enum vect_relevant {
409 1.1 mrg vect_unused_in_scope = 0,
410 1.1 mrg /* The def is in the inner loop, and the use is in the outer loop, and the
411 1.1 mrg use is a reduction stmt. */
412 1.1 mrg vect_used_in_outer_by_reduction,
413 1.1 mrg /* The def is in the inner loop, and the use is in the outer loop (and is
414 1.1 mrg not part of reduction). */
415 1.1 mrg vect_used_in_outer,
416 1.1 mrg
417 1.1 mrg /* defs that feed computations that end up (only) in a reduction. These
418 1.1 mrg defs may be used by non-reduction stmts, but eventually, any
419 1.1 mrg computations/values that are affected by these defs are used to compute
420 1.1 mrg a reduction (i.e. don't get stored to memory, for example). We use this
421 1.1 mrg to identify computations that we can change the order in which they are
422 1.1 mrg computed. */
423 1.1 mrg vect_used_by_reduction,
424 1.1 mrg
425 1.1 mrg vect_used_in_scope
426 1.1 mrg };
427 1.1 mrg
428 1.1 mrg /* The type of vectorization that can be applied to the stmt: regular loop-based
429 1.1 mrg vectorization; pure SLP - the stmt is a part of SLP instances and does not
430 1.1 mrg have uses outside SLP instances; or hybrid SLP and loop-based - the stmt is
431 1.1 mrg a part of SLP instance and also must be loop-based vectorized, since it has
432 1.1 mrg uses outside SLP sequences.
433 1.1 mrg
434 1.1 mrg In the loop context the meanings of pure and hybrid SLP are slightly
435 1.1 mrg different. By saying that pure SLP is applied to the loop, we mean that we
436 1.1 mrg exploit only intra-iteration parallelism in the loop; i.e., the loop can be
437 1.1 mrg vectorized without doing any conceptual unrolling, cause we don't pack
438 1.1 mrg together stmts from different iterations, only within a single iteration.
439 1.1 mrg Loop hybrid SLP means that we exploit both intra-iteration and
440 1.1 mrg inter-iteration parallelism (e.g., number of elements in the vector is 4
441 1.1 mrg and the slp-group-size is 2, in which case we don't have enough parallelism
442 1.1 mrg within an iteration, so we obtain the rest of the parallelism from subsequent
443 1.1 mrg iterations by unrolling the loop by 2). */
444 1.1 mrg enum slp_vect_type {
445 1.1 mrg loop_vect = 0,
446 1.1 mrg pure_slp,
447 1.1 mrg hybrid
448 1.1 mrg };
449 1.1 mrg
450 1.1 mrg
451 1.1 mrg typedef struct data_reference *dr_p;
452 1.1 mrg
453 1.1 mrg typedef struct _stmt_vec_info {
454 1.1 mrg
455 1.1 mrg enum stmt_vec_info_type type;
456 1.1 mrg
457 1.3 mrg /* Indicates whether this stmts is part of a computation whose result is
458 1.3 mrg used outside the loop. */
459 1.3 mrg bool live;
460 1.3 mrg
461 1.3 mrg /* Stmt is part of some pattern (computation idiom) */
462 1.3 mrg bool in_pattern_p;
463 1.3 mrg
464 1.3 mrg /* For loads only, if there is a store with the same location, this field is
465 1.3 mrg TRUE. */
466 1.3 mrg bool read_write_dep;
467 1.3 mrg
468 1.1 mrg /* The stmt to which this info struct refers to. */
469 1.1 mrg gimple stmt;
470 1.1 mrg
471 1.1 mrg /* The loop_vec_info with respect to which STMT is vectorized. */
472 1.1 mrg loop_vec_info loop_vinfo;
473 1.1 mrg
474 1.3 mrg /* The vector type to be used for the LHS of this statement. */
475 1.1 mrg tree vectype;
476 1.1 mrg
477 1.1 mrg /* The vectorized version of the stmt. */
478 1.1 mrg gimple vectorized_stmt;
479 1.1 mrg
480 1.1 mrg
481 1.1 mrg /** The following is relevant only for stmts that contain a non-scalar
482 1.1 mrg data-ref (array/pointer/struct access). A GIMPLE stmt is expected to have
483 1.1 mrg at most one such data-ref. **/
484 1.1 mrg
485 1.1 mrg /* Information about the data-ref (access function, etc),
486 1.1 mrg relative to the inner-most containing loop. */
487 1.1 mrg struct data_reference *data_ref_info;
488 1.1 mrg
489 1.1 mrg /* Information about the data-ref relative to this loop
490 1.1 mrg nest (the loop that is being considered for vectorization). */
491 1.1 mrg tree dr_base_address;
492 1.1 mrg tree dr_init;
493 1.1 mrg tree dr_offset;
494 1.1 mrg tree dr_step;
495 1.1 mrg tree dr_aligned_to;
496 1.1 mrg
497 1.3 mrg /* For loop PHI nodes, the evolution part of it. This makes sure
498 1.3 mrg this information is still available in vect_update_ivs_after_vectorizer
499 1.3 mrg where we may not be able to re-analyze the PHI nodes evolution as
500 1.3 mrg peeling for the prologue loop can make it unanalyzable. The evolution
501 1.3 mrg part is still correct though. */
502 1.3 mrg tree loop_phi_evolution_part;
503 1.1 mrg
504 1.1 mrg /* Used for various bookkeeping purposes, generally holding a pointer to
505 1.1 mrg some other stmt S that is in some way "related" to this stmt.
506 1.1 mrg Current use of this field is:
507 1.1 mrg If this stmt is part of a pattern (i.e. the field 'in_pattern_p' is
508 1.1 mrg true): S is the "pattern stmt" that represents (and replaces) the
509 1.1 mrg sequence of stmts that constitutes the pattern. Similarly, the
510 1.1 mrg related_stmt of the "pattern stmt" points back to this stmt (which is
511 1.1 mrg the last stmt in the original sequence of stmts that constitutes the
512 1.1 mrg pattern). */
513 1.1 mrg gimple related_stmt;
514 1.1 mrg
515 1.3 mrg /* Used to keep a sequence of def stmts of a pattern stmt if such exists. */
516 1.3 mrg gimple_seq pattern_def_seq;
517 1.3 mrg
518 1.1 mrg /* List of datarefs that are known to have the same alignment as the dataref
519 1.1 mrg of this stmt. */
520 1.3 mrg vec<dr_p> same_align_refs;
521 1.1 mrg
522 1.1 mrg /* Classify the def of this stmt. */
523 1.1 mrg enum vect_def_type def_type;
524 1.1 mrg
525 1.3 mrg /* Whether the stmt is SLPed, loop-based vectorized, or both. */
526 1.3 mrg enum slp_vect_type slp_type;
527 1.3 mrg
528 1.3 mrg /* Interleaving and reduction chains info. */
529 1.3 mrg /* First element in the group. */
530 1.3 mrg gimple first_element;
531 1.3 mrg /* Pointer to the next element in the group. */
532 1.3 mrg gimple next_element;
533 1.3 mrg /* For data-refs, in case that two or more stmts share data-ref, this is the
534 1.3 mrg pointer to the previously detected stmt with the same dr. */
535 1.3 mrg gimple same_dr_stmt;
536 1.3 mrg /* The size of the group. */
537 1.1 mrg unsigned int size;
538 1.1 mrg /* For stores, number of stores from this group seen. We vectorize the last
539 1.1 mrg one. */
540 1.1 mrg unsigned int store_count;
541 1.1 mrg /* For loads only, the gap from the previous load. For consecutive loads, GAP
542 1.1 mrg is 1. */
543 1.1 mrg unsigned int gap;
544 1.1 mrg
545 1.3 mrg /* The minimum negative dependence distance this stmt participates in
546 1.3 mrg or zero if none. */
547 1.3 mrg unsigned int min_neg_dist;
548 1.1 mrg
549 1.3 mrg /* Not all stmts in the loop need to be vectorized. e.g, the increment
550 1.3 mrg of the loop induction variable and computation of array indexes. relevant
551 1.3 mrg indicates whether the stmt needs to be vectorized. */
552 1.3 mrg enum vect_relevant relevant;
553 1.1 mrg
554 1.1 mrg /* The bb_vec_info with respect to which STMT is vectorized. */
555 1.1 mrg bb_vec_info bb_vinfo;
556 1.3 mrg
557 1.3 mrg /* Is this statement vectorizable or should it be skipped in (partial)
558 1.3 mrg vectorization. */
559 1.3 mrg bool vectorizable;
560 1.3 mrg
561 1.3 mrg /* For loads only, true if this is a gather load. */
562 1.3 mrg bool gather_p;
563 1.3 mrg bool stride_load_p;
564 1.1 mrg } *stmt_vec_info;
565 1.1 mrg
566 1.1 mrg /* Access Functions. */
567 1.1 mrg #define STMT_VINFO_TYPE(S) (S)->type
568 1.1 mrg #define STMT_VINFO_STMT(S) (S)->stmt
569 1.1 mrg #define STMT_VINFO_LOOP_VINFO(S) (S)->loop_vinfo
570 1.1 mrg #define STMT_VINFO_BB_VINFO(S) (S)->bb_vinfo
571 1.1 mrg #define STMT_VINFO_RELEVANT(S) (S)->relevant
572 1.1 mrg #define STMT_VINFO_LIVE_P(S) (S)->live
573 1.1 mrg #define STMT_VINFO_VECTYPE(S) (S)->vectype
574 1.1 mrg #define STMT_VINFO_VEC_STMT(S) (S)->vectorized_stmt
575 1.3 mrg #define STMT_VINFO_VECTORIZABLE(S) (S)->vectorizable
576 1.1 mrg #define STMT_VINFO_DATA_REF(S) (S)->data_ref_info
577 1.3 mrg #define STMT_VINFO_GATHER_P(S) (S)->gather_p
578 1.3 mrg #define STMT_VINFO_STRIDE_LOAD_P(S) (S)->stride_load_p
579 1.1 mrg
580 1.1 mrg #define STMT_VINFO_DR_BASE_ADDRESS(S) (S)->dr_base_address
581 1.1 mrg #define STMT_VINFO_DR_INIT(S) (S)->dr_init
582 1.1 mrg #define STMT_VINFO_DR_OFFSET(S) (S)->dr_offset
583 1.1 mrg #define STMT_VINFO_DR_STEP(S) (S)->dr_step
584 1.1 mrg #define STMT_VINFO_DR_ALIGNED_TO(S) (S)->dr_aligned_to
585 1.1 mrg
586 1.1 mrg #define STMT_VINFO_IN_PATTERN_P(S) (S)->in_pattern_p
587 1.1 mrg #define STMT_VINFO_RELATED_STMT(S) (S)->related_stmt
588 1.3 mrg #define STMT_VINFO_PATTERN_DEF_SEQ(S) (S)->pattern_def_seq
589 1.1 mrg #define STMT_VINFO_SAME_ALIGN_REFS(S) (S)->same_align_refs
590 1.1 mrg #define STMT_VINFO_DEF_TYPE(S) (S)->def_type
591 1.3 mrg #define STMT_VINFO_GROUP_FIRST_ELEMENT(S) (S)->first_element
592 1.3 mrg #define STMT_VINFO_GROUP_NEXT_ELEMENT(S) (S)->next_element
593 1.3 mrg #define STMT_VINFO_GROUP_SIZE(S) (S)->size
594 1.3 mrg #define STMT_VINFO_GROUP_STORE_COUNT(S) (S)->store_count
595 1.3 mrg #define STMT_VINFO_GROUP_GAP(S) (S)->gap
596 1.3 mrg #define STMT_VINFO_GROUP_SAME_DR_STMT(S) (S)->same_dr_stmt
597 1.3 mrg #define STMT_VINFO_GROUP_READ_WRITE_DEPENDENCE(S) (S)->read_write_dep
598 1.3 mrg #define STMT_VINFO_GROUPED_ACCESS(S) ((S)->first_element != NULL && (S)->data_ref_info)
599 1.3 mrg #define STMT_VINFO_LOOP_PHI_EVOLUTION_PART(S) (S)->loop_phi_evolution_part
600 1.3 mrg #define STMT_VINFO_MIN_NEG_DIST(S) (S)->min_neg_dist
601 1.3 mrg
602 1.3 mrg #define GROUP_FIRST_ELEMENT(S) (S)->first_element
603 1.3 mrg #define GROUP_NEXT_ELEMENT(S) (S)->next_element
604 1.3 mrg #define GROUP_SIZE(S) (S)->size
605 1.3 mrg #define GROUP_STORE_COUNT(S) (S)->store_count
606 1.3 mrg #define GROUP_GAP(S) (S)->gap
607 1.3 mrg #define GROUP_SAME_DR_STMT(S) (S)->same_dr_stmt
608 1.3 mrg #define GROUP_READ_WRITE_DEPENDENCE(S) (S)->read_write_dep
609 1.1 mrg
610 1.1 mrg #define STMT_VINFO_RELEVANT_P(S) ((S)->relevant != vect_unused_in_scope)
611 1.1 mrg
612 1.1 mrg #define HYBRID_SLP_STMT(S) ((S)->slp_type == hybrid)
613 1.1 mrg #define PURE_SLP_STMT(S) ((S)->slp_type == pure_slp)
614 1.1 mrg #define STMT_SLP_TYPE(S) (S)->slp_type
615 1.1 mrg
616 1.3 mrg #define VECT_MAX_COST 1000
617 1.1 mrg
618 1.1 mrg /* The maximum number of intermediate steps required in multi-step type
619 1.1 mrg conversion. */
620 1.1 mrg #define MAX_INTERM_CVT_STEPS 3
621 1.1 mrg
622 1.3 mrg /* The maximum vectorization factor supported by any target (V32QI). */
623 1.3 mrg #define MAX_VECTORIZATION_FACTOR 32
624 1.3 mrg
625 1.1 mrg /* Avoid GTY(()) on stmt_vec_info. */
626 1.1 mrg typedef void *vec_void_p;
627 1.1 mrg
628 1.3 mrg extern vec<vec_void_p> stmt_vec_info_vec;
629 1.1 mrg
630 1.1 mrg void init_stmt_vec_info_vec (void);
631 1.1 mrg void free_stmt_vec_info_vec (void);
632 1.1 mrg
633 1.3 mrg /* Return a stmt_vec_info corresponding to STMT. */
634 1.3 mrg
635 1.1 mrg static inline stmt_vec_info
636 1.1 mrg vinfo_for_stmt (gimple stmt)
637 1.1 mrg {
638 1.1 mrg unsigned int uid = gimple_uid (stmt);
639 1.1 mrg if (uid == 0)
640 1.1 mrg return NULL;
641 1.1 mrg
642 1.3 mrg return (stmt_vec_info) stmt_vec_info_vec[uid - 1];
643 1.1 mrg }
644 1.1 mrg
645 1.3 mrg /* Set vectorizer information INFO for STMT. */
646 1.3 mrg
647 1.1 mrg static inline void
648 1.1 mrg set_vinfo_for_stmt (gimple stmt, stmt_vec_info info)
649 1.1 mrg {
650 1.1 mrg unsigned int uid = gimple_uid (stmt);
651 1.1 mrg if (uid == 0)
652 1.1 mrg {
653 1.3 mrg gcc_checking_assert (info);
654 1.3 mrg uid = stmt_vec_info_vec.length () + 1;
655 1.1 mrg gimple_set_uid (stmt, uid);
656 1.3 mrg stmt_vec_info_vec.safe_push ((vec_void_p) info);
657 1.1 mrg }
658 1.1 mrg else
659 1.3 mrg stmt_vec_info_vec[uid - 1] = (vec_void_p) info;
660 1.1 mrg }
661 1.1 mrg
662 1.3 mrg /* Return the earlier statement between STMT1 and STMT2. */
663 1.3 mrg
664 1.1 mrg static inline gimple
665 1.1 mrg get_earlier_stmt (gimple stmt1, gimple stmt2)
666 1.1 mrg {
667 1.1 mrg unsigned int uid1, uid2;
668 1.1 mrg
669 1.1 mrg if (stmt1 == NULL)
670 1.1 mrg return stmt2;
671 1.1 mrg
672 1.1 mrg if (stmt2 == NULL)
673 1.1 mrg return stmt1;
674 1.1 mrg
675 1.1 mrg uid1 = gimple_uid (stmt1);
676 1.1 mrg uid2 = gimple_uid (stmt2);
677 1.1 mrg
678 1.1 mrg if (uid1 == 0 || uid2 == 0)
679 1.1 mrg return NULL;
680 1.1 mrg
681 1.3 mrg gcc_checking_assert (uid1 <= stmt_vec_info_vec.length ()
682 1.3 mrg && uid2 <= stmt_vec_info_vec.length ());
683 1.1 mrg
684 1.1 mrg if (uid1 < uid2)
685 1.1 mrg return stmt1;
686 1.1 mrg else
687 1.1 mrg return stmt2;
688 1.1 mrg }
689 1.1 mrg
690 1.3 mrg /* Return the later statement between STMT1 and STMT2. */
691 1.3 mrg
692 1.3 mrg static inline gimple
693 1.3 mrg get_later_stmt (gimple stmt1, gimple stmt2)
694 1.3 mrg {
695 1.3 mrg unsigned int uid1, uid2;
696 1.3 mrg
697 1.3 mrg if (stmt1 == NULL)
698 1.3 mrg return stmt2;
699 1.3 mrg
700 1.3 mrg if (stmt2 == NULL)
701 1.3 mrg return stmt1;
702 1.3 mrg
703 1.3 mrg uid1 = gimple_uid (stmt1);
704 1.3 mrg uid2 = gimple_uid (stmt2);
705 1.3 mrg
706 1.3 mrg if (uid1 == 0 || uid2 == 0)
707 1.3 mrg return NULL;
708 1.3 mrg
709 1.3 mrg gcc_assert (uid1 <= stmt_vec_info_vec.length ());
710 1.3 mrg gcc_assert (uid2 <= stmt_vec_info_vec.length ());
711 1.3 mrg
712 1.3 mrg if (uid1 > uid2)
713 1.3 mrg return stmt1;
714 1.3 mrg else
715 1.3 mrg return stmt2;
716 1.3 mrg }
717 1.3 mrg
718 1.3 mrg /* Return TRUE if a statement represented by STMT_INFO is a part of a
719 1.3 mrg pattern. */
720 1.3 mrg
721 1.1 mrg static inline bool
722 1.1 mrg is_pattern_stmt_p (stmt_vec_info stmt_info)
723 1.1 mrg {
724 1.1 mrg gimple related_stmt;
725 1.1 mrg stmt_vec_info related_stmt_info;
726 1.1 mrg
727 1.1 mrg related_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
728 1.1 mrg if (related_stmt
729 1.1 mrg && (related_stmt_info = vinfo_for_stmt (related_stmt))
730 1.1 mrg && STMT_VINFO_IN_PATTERN_P (related_stmt_info))
731 1.1 mrg return true;
732 1.1 mrg
733 1.1 mrg return false;
734 1.1 mrg }
735 1.1 mrg
736 1.3 mrg /* Return true if BB is a loop header. */
737 1.3 mrg
738 1.1 mrg static inline bool
739 1.1 mrg is_loop_header_bb_p (basic_block bb)
740 1.1 mrg {
741 1.1 mrg if (bb == (bb->loop_father)->header)
742 1.1 mrg return true;
743 1.3 mrg gcc_checking_assert (EDGE_COUNT (bb->preds) == 1);
744 1.1 mrg return false;
745 1.1 mrg }
746 1.1 mrg
747 1.3 mrg /* Return pow2 (X). */
748 1.1 mrg
749 1.1 mrg static inline int
750 1.1 mrg vect_pow2 (int x)
751 1.1 mrg {
752 1.1 mrg int i, res = 1;
753 1.1 mrg
754 1.1 mrg for (i = 0; i < x; i++)
755 1.1 mrg res *= 2;
756 1.1 mrg
757 1.1 mrg return res;
758 1.1 mrg }
759 1.1 mrg
760 1.3 mrg /* Alias targetm.vectorize.builtin_vectorization_cost. */
761 1.3 mrg
762 1.3 mrg static inline int
763 1.3 mrg builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
764 1.3 mrg tree vectype, int misalign)
765 1.3 mrg {
766 1.3 mrg return targetm.vectorize.builtin_vectorization_cost (type_of_cost,
767 1.3 mrg vectype, misalign);
768 1.3 mrg }
769 1.3 mrg
770 1.3 mrg /* Get cost by calling cost target builtin. */
771 1.3 mrg
772 1.3 mrg static inline
773 1.3 mrg int vect_get_stmt_cost (enum vect_cost_for_stmt type_of_cost)
774 1.3 mrg {
775 1.3 mrg return builtin_vectorization_cost (type_of_cost, NULL, 0);
776 1.3 mrg }
777 1.3 mrg
778 1.3 mrg /* Alias targetm.vectorize.init_cost. */
779 1.3 mrg
780 1.3 mrg static inline void *
781 1.3 mrg init_cost (struct loop *loop_info)
782 1.3 mrg {
783 1.3 mrg return targetm.vectorize.init_cost (loop_info);
784 1.3 mrg }
785 1.3 mrg
786 1.3 mrg /* Alias targetm.vectorize.add_stmt_cost. */
787 1.3 mrg
788 1.3 mrg static inline unsigned
789 1.3 mrg add_stmt_cost (void *data, int count, enum vect_cost_for_stmt kind,
790 1.3 mrg stmt_vec_info stmt_info, int misalign,
791 1.3 mrg enum vect_cost_model_location where)
792 1.3 mrg {
793 1.3 mrg return targetm.vectorize.add_stmt_cost (data, count, kind,
794 1.3 mrg stmt_info, misalign, where);
795 1.3 mrg }
796 1.3 mrg
797 1.3 mrg /* Alias targetm.vectorize.finish_cost. */
798 1.3 mrg
799 1.3 mrg static inline void
800 1.3 mrg finish_cost (void *data, unsigned *prologue_cost,
801 1.3 mrg unsigned *body_cost, unsigned *epilogue_cost)
802 1.3 mrg {
803 1.3 mrg targetm.vectorize.finish_cost (data, prologue_cost, body_cost, epilogue_cost);
804 1.3 mrg }
805 1.3 mrg
806 1.3 mrg /* Alias targetm.vectorize.destroy_cost_data. */
807 1.3 mrg
808 1.3 mrg static inline void
809 1.3 mrg destroy_cost_data (void *data)
810 1.3 mrg {
811 1.3 mrg targetm.vectorize.destroy_cost_data (data);
812 1.3 mrg }
813 1.3 mrg
814 1.3 mrg
815 1.1 mrg /*-----------------------------------------------------------------*/
816 1.1 mrg /* Info on data references alignment. */
817 1.1 mrg /*-----------------------------------------------------------------*/
818 1.1 mrg
819 1.1 mrg /* Reflects actual alignment of first access in the vectorized loop,
820 1.1 mrg taking into account peeling/versioning if applied. */
821 1.1 mrg #define DR_MISALIGNMENT(DR) ((int) (size_t) (DR)->aux)
822 1.1 mrg #define SET_DR_MISALIGNMENT(DR, VAL) ((DR)->aux = (void *) (size_t) (VAL))
823 1.1 mrg
824 1.3 mrg /* Return TRUE if the data access is aligned, and FALSE otherwise. */
825 1.3 mrg
826 1.1 mrg static inline bool
827 1.1 mrg aligned_access_p (struct data_reference *data_ref_info)
828 1.1 mrg {
829 1.1 mrg return (DR_MISALIGNMENT (data_ref_info) == 0);
830 1.1 mrg }
831 1.1 mrg
832 1.3 mrg /* Return TRUE if the alignment of the data access is known, and FALSE
833 1.3 mrg otherwise. */
834 1.3 mrg
835 1.1 mrg static inline bool
836 1.1 mrg known_alignment_for_access_p (struct data_reference *data_ref_info)
837 1.1 mrg {
838 1.1 mrg return (DR_MISALIGNMENT (data_ref_info) != -1);
839 1.1 mrg }
840 1.1 mrg
841 1.3 mrg /* Source location */
842 1.3 mrg extern LOC vect_location;
843 1.1 mrg
844 1.1 mrg /*-----------------------------------------------------------------*/
845 1.1 mrg /* Function prototypes. */
846 1.1 mrg /*-----------------------------------------------------------------*/
847 1.1 mrg
848 1.1 mrg /* Simple loop peeling and versioning utilities for vectorizer's purposes -
849 1.1 mrg in tree-vect-loop-manip.c. */
850 1.1 mrg extern void slpeel_make_loop_iterate_ntimes (struct loop *, tree);
851 1.1 mrg extern bool slpeel_can_duplicate_loop_p (const struct loop *, const_edge);
852 1.3 mrg extern void vect_loop_versioning (loop_vec_info, unsigned int, bool);
853 1.1 mrg extern void vect_do_peeling_for_loop_bound (loop_vec_info, tree *,
854 1.3 mrg unsigned int, bool);
855 1.3 mrg extern void vect_do_peeling_for_alignment (loop_vec_info, unsigned int, bool);
856 1.1 mrg extern LOC find_loop_location (struct loop *);
857 1.1 mrg extern bool vect_can_advance_ivs_p (loop_vec_info);
858 1.1 mrg
859 1.1 mrg /* In tree-vect-stmts.c. */
860 1.3 mrg extern unsigned int current_vector_size;
861 1.1 mrg extern tree get_vectype_for_scalar_type (tree);
862 1.3 mrg extern tree get_same_sized_vectype (tree, tree);
863 1.3 mrg extern bool vect_is_simple_use (tree, gimple, loop_vec_info,
864 1.3 mrg bb_vec_info, gimple *,
865 1.1 mrg tree *, enum vect_def_type *);
866 1.3 mrg extern bool vect_is_simple_use_1 (tree, gimple, loop_vec_info,
867 1.3 mrg bb_vec_info, gimple *,
868 1.3 mrg tree *, enum vect_def_type *, tree *);
869 1.3 mrg extern bool supportable_widening_operation (enum tree_code, gimple, tree, tree,
870 1.3 mrg enum tree_code *, enum tree_code *,
871 1.3 mrg int *, vec<tree> *);
872 1.3 mrg extern bool supportable_narrowing_operation (enum tree_code, tree, tree,
873 1.3 mrg enum tree_code *,
874 1.3 mrg int *, vec<tree> *);
875 1.1 mrg extern stmt_vec_info new_stmt_vec_info (gimple stmt, loop_vec_info,
876 1.1 mrg bb_vec_info);
877 1.1 mrg extern void free_stmt_vec_info (gimple stmt);
878 1.1 mrg extern tree vectorizable_function (gimple, tree, tree);
879 1.1 mrg extern void vect_model_simple_cost (stmt_vec_info, int, enum vect_def_type *,
880 1.3 mrg stmt_vector_for_cost *,
881 1.3 mrg stmt_vector_for_cost *);
882 1.3 mrg extern void vect_model_store_cost (stmt_vec_info, int, bool,
883 1.3 mrg enum vect_def_type, slp_tree,
884 1.3 mrg stmt_vector_for_cost *,
885 1.3 mrg stmt_vector_for_cost *);
886 1.3 mrg extern void vect_model_load_cost (stmt_vec_info, int, bool, slp_tree,
887 1.3 mrg stmt_vector_for_cost *,
888 1.3 mrg stmt_vector_for_cost *);
889 1.3 mrg extern unsigned record_stmt_cost (stmt_vector_for_cost *, int,
890 1.3 mrg enum vect_cost_for_stmt, stmt_vec_info,
891 1.3 mrg int, enum vect_cost_model_location);
892 1.1 mrg extern void vect_finish_stmt_generation (gimple, gimple,
893 1.1 mrg gimple_stmt_iterator *);
894 1.1 mrg extern bool vect_mark_stmts_to_be_vectorized (loop_vec_info);
895 1.1 mrg extern tree vect_get_vec_def_for_operand (tree, gimple, tree *);
896 1.1 mrg extern tree vect_init_vector (gimple, tree, tree,
897 1.1 mrg gimple_stmt_iterator *);
898 1.1 mrg extern tree vect_get_vec_def_for_stmt_copy (enum vect_def_type, tree);
899 1.1 mrg extern bool vect_transform_stmt (gimple, gimple_stmt_iterator *,
900 1.1 mrg bool *, slp_tree, slp_instance);
901 1.1 mrg extern void vect_remove_stores (gimple);
902 1.1 mrg extern bool vect_analyze_stmt (gimple, bool *, slp_tree);
903 1.1 mrg extern bool vectorizable_condition (gimple, gimple_stmt_iterator *, gimple *,
904 1.3 mrg tree, int, slp_tree);
905 1.3 mrg extern void vect_get_load_cost (struct data_reference *, int, bool,
906 1.3 mrg unsigned int *, unsigned int *,
907 1.3 mrg stmt_vector_for_cost *,
908 1.3 mrg stmt_vector_for_cost *, bool);
909 1.3 mrg extern void vect_get_store_cost (struct data_reference *, int,
910 1.3 mrg unsigned int *, stmt_vector_for_cost *);
911 1.3 mrg extern bool vect_supportable_shift (enum tree_code, tree);
912 1.3 mrg extern void vect_get_vec_defs (tree, tree, gimple, vec<tree> *,
913 1.3 mrg vec<tree> *, slp_tree, int);
914 1.3 mrg extern tree vect_gen_perm_mask (tree, unsigned char *);
915 1.1 mrg
916 1.1 mrg /* In tree-vect-data-refs.c. */
917 1.1 mrg extern bool vect_can_force_dr_alignment_p (const_tree, unsigned int);
918 1.1 mrg extern enum dr_alignment_support vect_supportable_dr_alignment
919 1.3 mrg (struct data_reference *, bool);
920 1.1 mrg extern tree vect_get_smallest_scalar_type (gimple, HOST_WIDE_INT *,
921 1.1 mrg HOST_WIDE_INT *);
922 1.3 mrg extern bool vect_analyze_data_ref_dependences (loop_vec_info, bb_vec_info,
923 1.3 mrg int *);
924 1.1 mrg extern bool vect_enhance_data_refs_alignment (loop_vec_info);
925 1.1 mrg extern bool vect_analyze_data_refs_alignment (loop_vec_info, bb_vec_info);
926 1.1 mrg extern bool vect_verify_datarefs_alignment (loop_vec_info, bb_vec_info);
927 1.1 mrg extern bool vect_analyze_data_ref_accesses (loop_vec_info, bb_vec_info);
928 1.1 mrg extern bool vect_prune_runtime_alias_test_list (loop_vec_info);
929 1.3 mrg extern tree vect_check_gather (gimple, loop_vec_info, tree *, tree *,
930 1.3 mrg int *);
931 1.3 mrg extern bool vect_analyze_data_refs (loop_vec_info, bb_vec_info, int *);
932 1.3 mrg extern tree vect_create_data_ref_ptr (gimple, tree, struct loop *, tree,
933 1.3 mrg tree *, gimple_stmt_iterator *,
934 1.3 mrg gimple *, bool, bool *,
935 1.3 mrg tree = NULL_TREE);
936 1.1 mrg extern tree bump_vector_ptr (tree, gimple, gimple_stmt_iterator *, gimple, tree);
937 1.1 mrg extern tree vect_create_destination_var (tree, tree);
938 1.3 mrg extern bool vect_grouped_store_supported (tree, unsigned HOST_WIDE_INT);
939 1.3 mrg extern bool vect_store_lanes_supported (tree, unsigned HOST_WIDE_INT);
940 1.3 mrg extern bool vect_grouped_load_supported (tree, unsigned HOST_WIDE_INT);
941 1.3 mrg extern bool vect_load_lanes_supported (tree, unsigned HOST_WIDE_INT);
942 1.3 mrg extern void vect_permute_store_chain (vec<tree> ,unsigned int, gimple,
943 1.3 mrg gimple_stmt_iterator *, vec<tree> *);
944 1.1 mrg extern tree vect_setup_realignment (gimple, gimple_stmt_iterator *, tree *,
945 1.1 mrg enum dr_alignment_support, tree,
946 1.1 mrg struct loop **);
947 1.3 mrg extern void vect_transform_grouped_load (gimple, vec<tree> , int,
948 1.1 mrg gimple_stmt_iterator *);
949 1.3 mrg extern void vect_record_grouped_load_vectors (gimple, vec<tree> );
950 1.1 mrg extern int vect_get_place_in_interleaving_chain (gimple, gimple);
951 1.1 mrg extern tree vect_get_new_vect_var (tree, enum vect_var_kind, const char *);
952 1.1 mrg extern tree vect_create_addr_base_for_vector_ref (gimple, gimple_seq *,
953 1.3 mrg tree, struct loop *,
954 1.3 mrg tree = NULL_TREE);
955 1.1 mrg
956 1.1 mrg /* In tree-vect-loop.c. */
957 1.1 mrg /* FORNOW: Used in tree-parloops.c. */
958 1.1 mrg extern void destroy_loop_vec_info (loop_vec_info, bool);
959 1.3 mrg extern gimple vect_force_simple_reduction (loop_vec_info, gimple, bool, bool *);
960 1.1 mrg /* Drive for loop analysis stage. */
961 1.1 mrg extern loop_vec_info vect_analyze_loop (struct loop *);
962 1.1 mrg /* Drive for loop transformation stage. */
963 1.1 mrg extern void vect_transform_loop (loop_vec_info);
964 1.1 mrg extern loop_vec_info vect_analyze_loop_form (struct loop *);
965 1.1 mrg extern bool vectorizable_live_operation (gimple, gimple_stmt_iterator *,
966 1.1 mrg gimple *);
967 1.3 mrg extern bool vectorizable_reduction (gimple, gimple_stmt_iterator *, gimple *,
968 1.3 mrg slp_tree);
969 1.1 mrg extern bool vectorizable_induction (gimple, gimple_stmt_iterator *, gimple *);
970 1.1 mrg extern tree get_initial_def_for_reduction (gimple, tree, tree *);
971 1.1 mrg extern int vect_min_worthwhile_factor (enum tree_code);
972 1.3 mrg extern int vect_get_known_peeling_cost (loop_vec_info, int, int *, int,
973 1.3 mrg stmt_vector_for_cost *,
974 1.3 mrg stmt_vector_for_cost *);
975 1.3 mrg extern int vect_get_single_scalar_iteration_cost (loop_vec_info);
976 1.1 mrg
977 1.1 mrg /* In tree-vect-slp.c. */
978 1.1 mrg extern void vect_free_slp_instance (slp_instance);
979 1.3 mrg extern bool vect_transform_slp_perm_load (gimple, vec<tree> ,
980 1.1 mrg gimple_stmt_iterator *, int,
981 1.1 mrg slp_instance, bool);
982 1.1 mrg extern bool vect_schedule_slp (loop_vec_info, bb_vec_info);
983 1.1 mrg extern void vect_update_slp_costs_according_to_vf (loop_vec_info);
984 1.1 mrg extern bool vect_analyze_slp (loop_vec_info, bb_vec_info);
985 1.3 mrg extern bool vect_make_slp_decision (loop_vec_info);
986 1.1 mrg extern void vect_detect_hybrid_slp (loop_vec_info);
987 1.3 mrg extern void vect_get_slp_defs (vec<tree> , slp_tree,
988 1.3 mrg vec<vec<tree> > *, int);
989 1.3 mrg
990 1.1 mrg extern LOC find_bb_location (basic_block);
991 1.1 mrg extern bb_vec_info vect_slp_analyze_bb (basic_block);
992 1.1 mrg extern void vect_slp_transform_bb (basic_block);
993 1.1 mrg
994 1.1 mrg /* In tree-vect-patterns.c. */
995 1.1 mrg /* Pattern recognition functions.
996 1.1 mrg Additional pattern recognition functions can (and will) be added
997 1.1 mrg in the future. */
998 1.3 mrg typedef gimple (* vect_recog_func_ptr) (vec<gimple> *, tree *, tree *);
999 1.3 mrg #define NUM_PATTERNS 10
1000 1.3 mrg void vect_pattern_recog (loop_vec_info, bb_vec_info);
1001 1.1 mrg
1002 1.1 mrg /* In tree-vectorizer.c. */
1003 1.1 mrg unsigned vectorize_loops (void);
1004 1.1 mrg
1005 1.1 mrg #endif /* GCC_TREE_VECTORIZER_H */
1006