Add an alternative vector loop iv mechanism
[official-gcc.git] / gcc / tree-vectorizer.h
blob22bbc9a9abc9ebc128505bdd6ab0621e74bc82bb
1 /* Vectorizer
2 Copyright (C) 2003-2017 Free Software Foundation, Inc.
3 Contributed by Dorit Naishlos <dorit@il.ibm.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 GCC_TREE_VECTORIZER_H
22 #define GCC_TREE_VECTORIZER_H
24 #include "tree-data-ref.h"
25 #include "tree-hash-traits.h"
26 #include "target.h"
28 /* Used for naming of new temporaries. */
29 enum vect_var_kind {
30 vect_simple_var,
31 vect_pointer_var,
32 vect_scalar_var,
33 vect_mask_var
36 /* Defines type of operation. */
37 enum operation_type {
38 unary_op = 1,
39 binary_op,
40 ternary_op
43 /* Define type of available alignment support. */
44 enum dr_alignment_support {
45 dr_unaligned_unsupported,
46 dr_unaligned_supported,
47 dr_explicit_realign,
48 dr_explicit_realign_optimized,
49 dr_aligned
52 /* Define type of def-use cross-iteration cycle. */
53 enum vect_def_type {
54 vect_uninitialized_def = 0,
55 vect_constant_def = 1,
56 vect_external_def,
57 vect_internal_def,
58 vect_induction_def,
59 vect_reduction_def,
60 vect_double_reduction_def,
61 vect_nested_cycle,
62 vect_unknown_def_type
65 /* Define type of reduction. */
66 enum vect_reduction_type {
67 TREE_CODE_REDUCTION,
68 COND_REDUCTION,
69 INTEGER_INDUC_COND_REDUCTION,
70 CONST_COND_REDUCTION
73 #define VECTORIZABLE_CYCLE_DEF(D) (((D) == vect_reduction_def) \
74 || ((D) == vect_double_reduction_def) \
75 || ((D) == vect_nested_cycle))
77 /* Structure to encapsulate information about a group of like
78 instructions to be presented to the target cost model. */
79 struct stmt_info_for_cost {
80 int count;
81 enum vect_cost_for_stmt kind;
82 gimple *stmt;
83 int misalign;
86 typedef vec<stmt_info_for_cost> stmt_vector_for_cost;
88 /* Maps base addresses to an innermost_loop_behavior that gives the maximum
89 known alignment for that base. */
90 typedef hash_map<tree_operand_hash,
91 innermost_loop_behavior *> vec_base_alignments;
93 /************************************************************************
94 SLP
95 ************************************************************************/
96 typedef struct _slp_tree *slp_tree;
98 /* A computation tree of an SLP instance. Each node corresponds to a group of
99 stmts to be packed in a SIMD stmt. */
100 struct _slp_tree {
101 /* Nodes that contain def-stmts of this node statements operands. */
102 vec<slp_tree> children;
103 /* A group of scalar stmts to be vectorized together. */
104 vec<gimple *> stmts;
105 /* Load permutation relative to the stores, NULL if there is no
106 permutation. */
107 vec<unsigned> load_permutation;
108 /* Vectorized stmt/s. */
109 vec<gimple *> vec_stmts;
110 /* Number of vector stmts that are created to replace the group of scalar
111 stmts. It is calculated during the transformation phase as the number of
112 scalar elements in one scalar iteration (GROUP_SIZE) multiplied by VF
113 divided by vector size. */
114 unsigned int vec_stmts_size;
115 /* Whether the scalar computations use two different operators. */
116 bool two_operators;
117 /* The DEF type of this node. */
118 enum vect_def_type def_type;
122 /* SLP instance is a sequence of stmts in a loop that can be packed into
123 SIMD stmts. */
124 typedef struct _slp_instance {
125 /* The root of SLP tree. */
126 slp_tree root;
128 /* Size of groups of scalar stmts that will be replaced by SIMD stmt/s. */
129 unsigned int group_size;
131 /* The unrolling factor required to vectorized this SLP instance. */
132 unsigned int unrolling_factor;
134 /* The group of nodes that contain loads of this SLP instance. */
135 vec<slp_tree> loads;
137 /* The SLP node containing the reduction PHIs. */
138 slp_tree reduc_phis;
139 } *slp_instance;
142 /* Access Functions. */
143 #define SLP_INSTANCE_TREE(S) (S)->root
144 #define SLP_INSTANCE_GROUP_SIZE(S) (S)->group_size
145 #define SLP_INSTANCE_UNROLLING_FACTOR(S) (S)->unrolling_factor
146 #define SLP_INSTANCE_LOADS(S) (S)->loads
148 #define SLP_TREE_CHILDREN(S) (S)->children
149 #define SLP_TREE_SCALAR_STMTS(S) (S)->stmts
150 #define SLP_TREE_VEC_STMTS(S) (S)->vec_stmts
151 #define SLP_TREE_NUMBER_OF_VEC_STMTS(S) (S)->vec_stmts_size
152 #define SLP_TREE_LOAD_PERMUTATION(S) (S)->load_permutation
153 #define SLP_TREE_TWO_OPERATORS(S) (S)->two_operators
154 #define SLP_TREE_DEF_TYPE(S) (S)->def_type
158 /* Describes two objects whose addresses must be unequal for the vectorized
159 loop to be valid. */
160 typedef std::pair<tree, tree> vec_object_pair;
162 /* Vectorizer state common between loop and basic-block vectorization. */
163 struct vec_info {
164 enum vec_kind { bb, loop };
166 vec_info (vec_kind, void *);
167 ~vec_info ();
169 /* The type of vectorization. */
170 vec_kind kind;
172 /* All SLP instances. */
173 auto_vec<slp_instance> slp_instances;
175 /* All data references. Freed by free_data_refs, so not an auto_vec. */
176 vec<data_reference_p> datarefs;
178 /* Maps base addresses to an innermost_loop_behavior that gives the maximum
179 known alignment for that base. */
180 vec_base_alignments base_alignments;
182 /* All data dependences. Freed by free_dependence_relations, so not
183 an auto_vec. */
184 vec<ddr_p> ddrs;
186 /* All interleaving chains of stores, represented by the first
187 stmt in the chain. */
188 auto_vec<gimple *> grouped_stores;
190 /* Cost data used by the target cost model. */
191 void *target_cost_data;
194 struct _loop_vec_info;
195 struct _bb_vec_info;
197 template<>
198 template<>
199 inline bool
200 is_a_helper <_loop_vec_info *>::test (vec_info *i)
202 return i->kind == vec_info::loop;
205 template<>
206 template<>
207 inline bool
208 is_a_helper <_bb_vec_info *>::test (vec_info *i)
210 return i->kind == vec_info::bb;
214 /*-----------------------------------------------------------------*/
215 /* Info on vectorized loops. */
216 /*-----------------------------------------------------------------*/
217 typedef struct _loop_vec_info : public vec_info {
218 _loop_vec_info (struct loop *);
219 ~_loop_vec_info ();
221 /* The loop to which this info struct refers to. */
222 struct loop *loop;
224 /* The loop basic blocks. */
225 basic_block *bbs;
227 /* Number of latch executions. */
228 tree num_itersm1;
229 /* Number of iterations. */
230 tree num_iters;
231 /* Number of iterations of the original loop. */
232 tree num_iters_unchanged;
233 /* Condition under which this loop is analyzed and versioned. */
234 tree num_iters_assumptions;
236 /* Threshold of number of iterations below which vectorzation will not be
237 performed. It is calculated from MIN_PROFITABLE_ITERS and
238 PARAM_MIN_VECT_LOOP_BOUND. */
239 unsigned int th;
241 /* When applying loop versioning, the vector form should only be used
242 if the number of scalar iterations is >= this value, on top of all
243 the other requirements. Ignored when loop versioning is not being
244 used. */
245 poly_uint64 versioning_threshold;
247 /* Unrolling factor */
248 int vectorization_factor;
250 /* Maximum runtime vectorization factor, or MAX_VECTORIZATION_FACTOR
251 if there is no particular limit. */
252 unsigned HOST_WIDE_INT max_vectorization_factor;
254 /* Unknown DRs according to which loop was peeled. */
255 struct data_reference *unaligned_dr;
257 /* peeling_for_alignment indicates whether peeling for alignment will take
258 place, and what the peeling factor should be:
259 peeling_for_alignment = X means:
260 If X=0: Peeling for alignment will not be applied.
261 If X>0: Peel first X iterations.
262 If X=-1: Generate a runtime test to calculate the number of iterations
263 to be peeled, using the dataref recorded in the field
264 unaligned_dr. */
265 int peeling_for_alignment;
267 /* The mask used to check the alignment of pointers or arrays. */
268 int ptr_mask;
270 /* The loop nest in which the data dependences are computed. */
271 auto_vec<loop_p> loop_nest;
273 /* Data Dependence Relations defining address ranges that are candidates
274 for a run-time aliasing check. */
275 auto_vec<ddr_p> may_alias_ddrs;
277 /* Data Dependence Relations defining address ranges together with segment
278 lengths from which the run-time aliasing check is built. */
279 auto_vec<dr_with_seg_len_pair_t> comp_alias_ddrs;
281 /* Check that the addresses of each pair of objects is unequal. */
282 auto_vec<vec_object_pair> check_unequal_addrs;
284 /* Statements in the loop that have data references that are candidates for a
285 runtime (loop versioning) misalignment check. */
286 auto_vec<gimple *> may_misalign_stmts;
288 /* Reduction cycles detected in the loop. Used in loop-aware SLP. */
289 auto_vec<gimple *> reductions;
291 /* All reduction chains in the loop, represented by the first
292 stmt in the chain. */
293 auto_vec<gimple *> reduction_chains;
295 /* Cost vector for a single scalar iteration. */
296 auto_vec<stmt_info_for_cost> scalar_cost_vec;
298 /* The unrolling factor needed to SLP the loop. In case of that pure SLP is
299 applied to the loop, i.e., no unrolling is needed, this is 1. */
300 unsigned slp_unrolling_factor;
302 /* Cost of a single scalar iteration. */
303 int single_scalar_iteration_cost;
305 /* Is the loop vectorizable? */
306 bool vectorizable;
308 /* When we have grouped data accesses with gaps, we may introduce invalid
309 memory accesses. We peel the last iteration of the loop to prevent
310 this. */
311 bool peeling_for_gaps;
313 /* When the number of iterations is not a multiple of the vector size
314 we need to peel off iterations at the end to form an epilogue loop. */
315 bool peeling_for_niter;
317 /* Reductions are canonicalized so that the last operand is the reduction
318 operand. If this places a constant into RHS1, this decanonicalizes
319 GIMPLE for other phases, so we must track when this has occurred and
320 fix it up. */
321 bool operands_swapped;
323 /* True if there are no loop carried data dependencies in the loop.
324 If loop->safelen <= 1, then this is always true, either the loop
325 didn't have any loop carried data dependencies, or the loop is being
326 vectorized guarded with some runtime alias checks, or couldn't
327 be vectorized at all, but then this field shouldn't be used.
328 For loop->safelen >= 2, the user has asserted that there are no
329 backward dependencies, but there still could be loop carried forward
330 dependencies in such loops. This flag will be false if normal
331 vectorizer data dependency analysis would fail or require versioning
332 for alias, but because of loop->safelen >= 2 it has been vectorized
333 even without versioning for alias. E.g. in:
334 #pragma omp simd
335 for (int i = 0; i < m; i++)
336 a[i] = a[i + k] * c;
337 (or #pragma simd or #pragma ivdep) we can vectorize this and it will
338 DTRT even for k > 0 && k < m, but without safelen we would not
339 vectorize this, so this field would be false. */
340 bool no_data_dependencies;
342 /* Mark loops having masked stores. */
343 bool has_mask_store;
345 /* If if-conversion versioned this loop before conversion, this is the
346 loop version without if-conversion. */
347 struct loop *scalar_loop;
349 /* For loops being epilogues of already vectorized loops
350 this points to the original vectorized loop. Otherwise NULL. */
351 _loop_vec_info *orig_loop_info;
353 } *loop_vec_info;
355 /* Access Functions. */
356 #define LOOP_VINFO_LOOP(L) (L)->loop
357 #define LOOP_VINFO_BBS(L) (L)->bbs
358 #define LOOP_VINFO_NITERSM1(L) (L)->num_itersm1
359 #define LOOP_VINFO_NITERS(L) (L)->num_iters
360 /* Since LOOP_VINFO_NITERS and LOOP_VINFO_NITERSM1 can change after
361 prologue peeling retain total unchanged scalar loop iterations for
362 cost model. */
363 #define LOOP_VINFO_NITERS_UNCHANGED(L) (L)->num_iters_unchanged
364 #define LOOP_VINFO_NITERS_ASSUMPTIONS(L) (L)->num_iters_assumptions
365 #define LOOP_VINFO_COST_MODEL_THRESHOLD(L) (L)->th
366 #define LOOP_VINFO_VERSIONING_THRESHOLD(L) (L)->versioning_threshold
367 #define LOOP_VINFO_VECTORIZABLE_P(L) (L)->vectorizable
368 #define LOOP_VINFO_VECT_FACTOR(L) (L)->vectorization_factor
369 #define LOOP_VINFO_MAX_VECT_FACTOR(L) (L)->max_vectorization_factor
370 #define LOOP_VINFO_PTR_MASK(L) (L)->ptr_mask
371 #define LOOP_VINFO_LOOP_NEST(L) (L)->loop_nest
372 #define LOOP_VINFO_DATAREFS(L) (L)->datarefs
373 #define LOOP_VINFO_DDRS(L) (L)->ddrs
374 #define LOOP_VINFO_INT_NITERS(L) (TREE_INT_CST_LOW ((L)->num_iters))
375 #define LOOP_VINFO_PEELING_FOR_ALIGNMENT(L) (L)->peeling_for_alignment
376 #define LOOP_VINFO_UNALIGNED_DR(L) (L)->unaligned_dr
377 #define LOOP_VINFO_MAY_MISALIGN_STMTS(L) (L)->may_misalign_stmts
378 #define LOOP_VINFO_MAY_ALIAS_DDRS(L) (L)->may_alias_ddrs
379 #define LOOP_VINFO_COMP_ALIAS_DDRS(L) (L)->comp_alias_ddrs
380 #define LOOP_VINFO_CHECK_UNEQUAL_ADDRS(L) (L)->check_unequal_addrs
381 #define LOOP_VINFO_GROUPED_STORES(L) (L)->grouped_stores
382 #define LOOP_VINFO_SLP_INSTANCES(L) (L)->slp_instances
383 #define LOOP_VINFO_SLP_UNROLLING_FACTOR(L) (L)->slp_unrolling_factor
384 #define LOOP_VINFO_REDUCTIONS(L) (L)->reductions
385 #define LOOP_VINFO_REDUCTION_CHAINS(L) (L)->reduction_chains
386 #define LOOP_VINFO_TARGET_COST_DATA(L) (L)->target_cost_data
387 #define LOOP_VINFO_PEELING_FOR_GAPS(L) (L)->peeling_for_gaps
388 #define LOOP_VINFO_OPERANDS_SWAPPED(L) (L)->operands_swapped
389 #define LOOP_VINFO_PEELING_FOR_NITER(L) (L)->peeling_for_niter
390 #define LOOP_VINFO_NO_DATA_DEPENDENCIES(L) (L)->no_data_dependencies
391 #define LOOP_VINFO_SCALAR_LOOP(L) (L)->scalar_loop
392 #define LOOP_VINFO_HAS_MASK_STORE(L) (L)->has_mask_store
393 #define LOOP_VINFO_SCALAR_ITERATION_COST(L) (L)->scalar_cost_vec
394 #define LOOP_VINFO_SINGLE_SCALAR_ITERATION_COST(L) (L)->single_scalar_iteration_cost
395 #define LOOP_VINFO_ORIG_LOOP_INFO(L) (L)->orig_loop_info
397 #define LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT(L) \
398 ((L)->may_misalign_stmts.length () > 0)
399 #define LOOP_REQUIRES_VERSIONING_FOR_ALIAS(L) \
400 ((L)->comp_alias_ddrs.length () > 0 \
401 || (L)->check_unequal_addrs.length () > 0)
402 #define LOOP_REQUIRES_VERSIONING_FOR_NITERS(L) \
403 (LOOP_VINFO_NITERS_ASSUMPTIONS (L))
404 #define LOOP_REQUIRES_VERSIONING(L) \
405 (LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (L) \
406 || LOOP_REQUIRES_VERSIONING_FOR_ALIAS (L) \
407 || LOOP_REQUIRES_VERSIONING_FOR_NITERS (L))
409 #define LOOP_VINFO_NITERS_KNOWN_P(L) \
410 (tree_fits_shwi_p ((L)->num_iters) && tree_to_shwi ((L)->num_iters) > 0)
412 #define LOOP_VINFO_EPILOGUE_P(L) \
413 (LOOP_VINFO_ORIG_LOOP_INFO (L) != NULL)
415 #define LOOP_VINFO_ORIG_MAX_VECT_FACTOR(L) \
416 (LOOP_VINFO_MAX_VECT_FACTOR (LOOP_VINFO_ORIG_LOOP_INFO (L)))
418 static inline loop_vec_info
419 loop_vec_info_for_loop (struct loop *loop)
421 return (loop_vec_info) loop->aux;
424 static inline bool
425 nested_in_vect_loop_p (struct loop *loop, gimple *stmt)
427 return (loop->inner
428 && (loop->inner == (gimple_bb (stmt))->loop_father));
431 typedef struct _bb_vec_info : public vec_info
433 _bb_vec_info (gimple_stmt_iterator, gimple_stmt_iterator);
434 ~_bb_vec_info ();
436 basic_block bb;
437 gimple_stmt_iterator region_begin;
438 gimple_stmt_iterator region_end;
439 } *bb_vec_info;
441 #define BB_VINFO_BB(B) (B)->bb
442 #define BB_VINFO_GROUPED_STORES(B) (B)->grouped_stores
443 #define BB_VINFO_SLP_INSTANCES(B) (B)->slp_instances
444 #define BB_VINFO_DATAREFS(B) (B)->datarefs
445 #define BB_VINFO_DDRS(B) (B)->ddrs
446 #define BB_VINFO_TARGET_COST_DATA(B) (B)->target_cost_data
448 static inline bb_vec_info
449 vec_info_for_bb (basic_block bb)
451 return (bb_vec_info) bb->aux;
454 /*-----------------------------------------------------------------*/
455 /* Info on vectorized defs. */
456 /*-----------------------------------------------------------------*/
457 enum stmt_vec_info_type {
458 undef_vec_info_type = 0,
459 load_vec_info_type,
460 store_vec_info_type,
461 shift_vec_info_type,
462 op_vec_info_type,
463 call_vec_info_type,
464 call_simd_clone_vec_info_type,
465 assignment_vec_info_type,
466 condition_vec_info_type,
467 comparison_vec_info_type,
468 reduc_vec_info_type,
469 induc_vec_info_type,
470 type_promotion_vec_info_type,
471 type_demotion_vec_info_type,
472 type_conversion_vec_info_type,
473 loop_exit_ctrl_vec_info_type
476 /* Indicates whether/how a variable is used in the scope of loop/basic
477 block. */
478 enum vect_relevant {
479 vect_unused_in_scope = 0,
481 /* The def is only used outside the loop. */
482 vect_used_only_live,
483 /* The def is in the inner loop, and the use is in the outer loop, and the
484 use is a reduction stmt. */
485 vect_used_in_outer_by_reduction,
486 /* The def is in the inner loop, and the use is in the outer loop (and is
487 not part of reduction). */
488 vect_used_in_outer,
490 /* defs that feed computations that end up (only) in a reduction. These
491 defs may be used by non-reduction stmts, but eventually, any
492 computations/values that are affected by these defs are used to compute
493 a reduction (i.e. don't get stored to memory, for example). We use this
494 to identify computations that we can change the order in which they are
495 computed. */
496 vect_used_by_reduction,
498 vect_used_in_scope
501 /* The type of vectorization that can be applied to the stmt: regular loop-based
502 vectorization; pure SLP - the stmt is a part of SLP instances and does not
503 have uses outside SLP instances; or hybrid SLP and loop-based - the stmt is
504 a part of SLP instance and also must be loop-based vectorized, since it has
505 uses outside SLP sequences.
507 In the loop context the meanings of pure and hybrid SLP are slightly
508 different. By saying that pure SLP is applied to the loop, we mean that we
509 exploit only intra-iteration parallelism in the loop; i.e., the loop can be
510 vectorized without doing any conceptual unrolling, cause we don't pack
511 together stmts from different iterations, only within a single iteration.
512 Loop hybrid SLP means that we exploit both intra-iteration and
513 inter-iteration parallelism (e.g., number of elements in the vector is 4
514 and the slp-group-size is 2, in which case we don't have enough parallelism
515 within an iteration, so we obtain the rest of the parallelism from subsequent
516 iterations by unrolling the loop by 2). */
517 enum slp_vect_type {
518 loop_vect = 0,
519 pure_slp,
520 hybrid
523 /* Describes how we're going to vectorize an individual load or store,
524 or a group of loads or stores. */
525 enum vect_memory_access_type {
526 /* An access to an invariant address. This is used only for loads. */
527 VMAT_INVARIANT,
529 /* A simple contiguous access. */
530 VMAT_CONTIGUOUS,
532 /* A contiguous access that goes down in memory rather than up,
533 with no additional permutation. This is used only for stores
534 of invariants. */
535 VMAT_CONTIGUOUS_DOWN,
537 /* A simple contiguous access in which the elements need to be permuted
538 after loading or before storing. Only used for loop vectorization;
539 SLP uses separate permutes. */
540 VMAT_CONTIGUOUS_PERMUTE,
542 /* A simple contiguous access in which the elements need to be reversed
543 after loading or before storing. */
544 VMAT_CONTIGUOUS_REVERSE,
546 /* An access that uses IFN_LOAD_LANES or IFN_STORE_LANES. */
547 VMAT_LOAD_STORE_LANES,
549 /* An access in which each scalar element is loaded or stored
550 individually. */
551 VMAT_ELEMENTWISE,
553 /* A hybrid of VMAT_CONTIGUOUS and VMAT_ELEMENTWISE, used for grouped
554 SLP accesses. Each unrolled iteration uses a contiguous load
555 or store for the whole group, but the groups from separate iterations
556 are combined in the same way as for VMAT_ELEMENTWISE. */
557 VMAT_STRIDED_SLP,
559 /* The access uses gather loads or scatter stores. */
560 VMAT_GATHER_SCATTER
563 typedef struct data_reference *dr_p;
565 typedef struct _stmt_vec_info {
567 enum stmt_vec_info_type type;
569 /* Indicates whether this stmts is part of a computation whose result is
570 used outside the loop. */
571 bool live;
573 /* Stmt is part of some pattern (computation idiom) */
574 bool in_pattern_p;
576 /* Is this statement vectorizable or should it be skipped in (partial)
577 vectorization. */
578 bool vectorizable;
580 /* The stmt to which this info struct refers to. */
581 gimple *stmt;
583 /* The vec_info with respect to which STMT is vectorized. */
584 vec_info *vinfo;
586 /* The vector type to be used for the LHS of this statement. */
587 tree vectype;
589 /* The vectorized version of the stmt. */
590 gimple *vectorized_stmt;
593 /* The following is relevant only for stmts that contain a non-scalar
594 data-ref (array/pointer/struct access). A GIMPLE stmt is expected to have
595 at most one such data-ref. */
597 /* Information about the data-ref (access function, etc),
598 relative to the inner-most containing loop. */
599 struct data_reference *data_ref_info;
601 /* Information about the data-ref relative to this loop
602 nest (the loop that is being considered for vectorization). */
603 innermost_loop_behavior dr_wrt_vec_loop;
605 /* For loop PHI nodes, the base and evolution part of it. This makes sure
606 this information is still available in vect_update_ivs_after_vectorizer
607 where we may not be able to re-analyze the PHI nodes evolution as
608 peeling for the prologue loop can make it unanalyzable. The evolution
609 part is still correct after peeling, but the base may have changed from
610 the version here. */
611 tree loop_phi_evolution_base_unchanged;
612 tree loop_phi_evolution_part;
614 /* Used for various bookkeeping purposes, generally holding a pointer to
615 some other stmt S that is in some way "related" to this stmt.
616 Current use of this field is:
617 If this stmt is part of a pattern (i.e. the field 'in_pattern_p' is
618 true): S is the "pattern stmt" that represents (and replaces) the
619 sequence of stmts that constitutes the pattern. Similarly, the
620 related_stmt of the "pattern stmt" points back to this stmt (which is
621 the last stmt in the original sequence of stmts that constitutes the
622 pattern). */
623 gimple *related_stmt;
625 /* Used to keep a sequence of def stmts of a pattern stmt if such exists. */
626 gimple_seq pattern_def_seq;
628 /* List of datarefs that are known to have the same alignment as the dataref
629 of this stmt. */
630 vec<dr_p> same_align_refs;
632 /* Selected SIMD clone's function info. First vector element
633 is SIMD clone's function decl, followed by a pair of trees (base + step)
634 for linear arguments (pair of NULLs for other arguments). */
635 vec<tree> simd_clone_info;
637 /* Classify the def of this stmt. */
638 enum vect_def_type def_type;
640 /* Whether the stmt is SLPed, loop-based vectorized, or both. */
641 enum slp_vect_type slp_type;
643 /* Interleaving and reduction chains info. */
644 /* First element in the group. */
645 gimple *first_element;
646 /* Pointer to the next element in the group. */
647 gimple *next_element;
648 /* For data-refs, in case that two or more stmts share data-ref, this is the
649 pointer to the previously detected stmt with the same dr. */
650 gimple *same_dr_stmt;
651 /* The size of the group. */
652 unsigned int size;
653 /* For stores, number of stores from this group seen. We vectorize the last
654 one. */
655 unsigned int store_count;
656 /* For loads only, the gap from the previous load. For consecutive loads, GAP
657 is 1. */
658 unsigned int gap;
660 /* The minimum negative dependence distance this stmt participates in
661 or zero if none. */
662 unsigned int min_neg_dist;
664 /* Not all stmts in the loop need to be vectorized. e.g, the increment
665 of the loop induction variable and computation of array indexes. relevant
666 indicates whether the stmt needs to be vectorized. */
667 enum vect_relevant relevant;
669 /* For loads if this is a gather, for stores if this is a scatter. */
670 bool gather_scatter_p;
672 /* True if this is an access with loop-invariant stride. */
673 bool strided_p;
675 /* For both loads and stores. */
676 bool simd_lane_access_p;
678 /* Classifies how the load or store is going to be implemented
679 for loop vectorization. */
680 vect_memory_access_type memory_access_type;
682 /* For reduction loops, this is the type of reduction. */
683 enum vect_reduction_type v_reduc_type;
685 /* For CONST_COND_REDUCTION, record the reduc code. */
686 enum tree_code const_cond_reduc_code;
688 /* On a reduction PHI the reduction type as detected by
689 vect_force_simple_reduction. */
690 enum vect_reduction_type reduc_type;
692 /* On a reduction PHI the def returned by vect_force_simple_reduction.
693 On the def returned by vect_force_simple_reduction the
694 corresponding PHI. */
695 gimple *reduc_def;
697 /* The number of scalar stmt references from active SLP instances. */
698 unsigned int num_slp_uses;
699 } *stmt_vec_info;
701 /* Information about a gather/scatter call. */
702 struct gather_scatter_info {
703 /* The FUNCTION_DECL for the built-in gather/scatter function. */
704 tree decl;
706 /* The loop-invariant base value. */
707 tree base;
709 /* The original scalar offset, which is a non-loop-invariant SSA_NAME. */
710 tree offset;
712 /* Each offset element should be multiplied by this amount before
713 being added to the base. */
714 int scale;
716 /* The definition type for the vectorized offset. */
717 enum vect_def_type offset_dt;
719 /* The type of the vectorized offset. */
720 tree offset_vectype;
723 /* Access Functions. */
724 #define STMT_VINFO_TYPE(S) (S)->type
725 #define STMT_VINFO_STMT(S) (S)->stmt
726 inline loop_vec_info
727 STMT_VINFO_LOOP_VINFO (stmt_vec_info stmt_vinfo)
729 if (loop_vec_info loop_vinfo = dyn_cast <loop_vec_info> (stmt_vinfo->vinfo))
730 return loop_vinfo;
731 return NULL;
733 inline bb_vec_info
734 STMT_VINFO_BB_VINFO (stmt_vec_info stmt_vinfo)
736 if (bb_vec_info bb_vinfo = dyn_cast <bb_vec_info> (stmt_vinfo->vinfo))
737 return bb_vinfo;
738 return NULL;
740 #define STMT_VINFO_RELEVANT(S) (S)->relevant
741 #define STMT_VINFO_LIVE_P(S) (S)->live
742 #define STMT_VINFO_VECTYPE(S) (S)->vectype
743 #define STMT_VINFO_VEC_STMT(S) (S)->vectorized_stmt
744 #define STMT_VINFO_VECTORIZABLE(S) (S)->vectorizable
745 #define STMT_VINFO_DATA_REF(S) (S)->data_ref_info
746 #define STMT_VINFO_GATHER_SCATTER_P(S) (S)->gather_scatter_p
747 #define STMT_VINFO_STRIDED_P(S) (S)->strided_p
748 #define STMT_VINFO_MEMORY_ACCESS_TYPE(S) (S)->memory_access_type
749 #define STMT_VINFO_SIMD_LANE_ACCESS_P(S) (S)->simd_lane_access_p
750 #define STMT_VINFO_VEC_REDUCTION_TYPE(S) (S)->v_reduc_type
751 #define STMT_VINFO_VEC_CONST_COND_REDUC_CODE(S) (S)->const_cond_reduc_code
753 #define STMT_VINFO_DR_WRT_VEC_LOOP(S) (S)->dr_wrt_vec_loop
754 #define STMT_VINFO_DR_BASE_ADDRESS(S) (S)->dr_wrt_vec_loop.base_address
755 #define STMT_VINFO_DR_INIT(S) (S)->dr_wrt_vec_loop.init
756 #define STMT_VINFO_DR_OFFSET(S) (S)->dr_wrt_vec_loop.offset
757 #define STMT_VINFO_DR_STEP(S) (S)->dr_wrt_vec_loop.step
758 #define STMT_VINFO_DR_BASE_ALIGNMENT(S) (S)->dr_wrt_vec_loop.base_alignment
759 #define STMT_VINFO_DR_BASE_MISALIGNMENT(S) \
760 (S)->dr_wrt_vec_loop.base_misalignment
761 #define STMT_VINFO_DR_OFFSET_ALIGNMENT(S) \
762 (S)->dr_wrt_vec_loop.offset_alignment
763 #define STMT_VINFO_DR_STEP_ALIGNMENT(S) \
764 (S)->dr_wrt_vec_loop.step_alignment
766 #define STMT_VINFO_IN_PATTERN_P(S) (S)->in_pattern_p
767 #define STMT_VINFO_RELATED_STMT(S) (S)->related_stmt
768 #define STMT_VINFO_PATTERN_DEF_SEQ(S) (S)->pattern_def_seq
769 #define STMT_VINFO_SAME_ALIGN_REFS(S) (S)->same_align_refs
770 #define STMT_VINFO_SIMD_CLONE_INFO(S) (S)->simd_clone_info
771 #define STMT_VINFO_DEF_TYPE(S) (S)->def_type
772 #define STMT_VINFO_GROUP_FIRST_ELEMENT(S) (S)->first_element
773 #define STMT_VINFO_GROUP_NEXT_ELEMENT(S) (S)->next_element
774 #define STMT_VINFO_GROUP_SIZE(S) (S)->size
775 #define STMT_VINFO_GROUP_STORE_COUNT(S) (S)->store_count
776 #define STMT_VINFO_GROUP_GAP(S) (S)->gap
777 #define STMT_VINFO_GROUP_SAME_DR_STMT(S) (S)->same_dr_stmt
778 #define STMT_VINFO_GROUPED_ACCESS(S) ((S)->first_element != NULL && (S)->data_ref_info)
779 #define STMT_VINFO_LOOP_PHI_EVOLUTION_BASE_UNCHANGED(S) (S)->loop_phi_evolution_base_unchanged
780 #define STMT_VINFO_LOOP_PHI_EVOLUTION_PART(S) (S)->loop_phi_evolution_part
781 #define STMT_VINFO_MIN_NEG_DIST(S) (S)->min_neg_dist
782 #define STMT_VINFO_NUM_SLP_USES(S) (S)->num_slp_uses
783 #define STMT_VINFO_REDUC_TYPE(S) (S)->reduc_type
784 #define STMT_VINFO_REDUC_DEF(S) (S)->reduc_def
786 #define GROUP_FIRST_ELEMENT(S) (S)->first_element
787 #define GROUP_NEXT_ELEMENT(S) (S)->next_element
788 #define GROUP_SIZE(S) (S)->size
789 #define GROUP_STORE_COUNT(S) (S)->store_count
790 #define GROUP_GAP(S) (S)->gap
791 #define GROUP_SAME_DR_STMT(S) (S)->same_dr_stmt
793 #define STMT_VINFO_RELEVANT_P(S) ((S)->relevant != vect_unused_in_scope)
795 #define HYBRID_SLP_STMT(S) ((S)->slp_type == hybrid)
796 #define PURE_SLP_STMT(S) ((S)->slp_type == pure_slp)
797 #define STMT_SLP_TYPE(S) (S)->slp_type
799 struct dataref_aux {
800 /* The misalignment in bytes of the reference, or -1 if not known. */
801 int misalignment;
802 /* The byte alignment that we'd ideally like the reference to have,
803 and the value that misalignment is measured against. */
804 int target_alignment;
805 /* If true the alignment of base_decl needs to be increased. */
806 bool base_misaligned;
807 tree base_decl;
810 #define DR_VECT_AUX(dr) ((dataref_aux *)(dr)->aux)
812 #define VECT_MAX_COST 1000
814 /* The maximum number of intermediate steps required in multi-step type
815 conversion. */
816 #define MAX_INTERM_CVT_STEPS 3
818 /* The maximum vectorization factor supported by any target (V64QI). */
819 #define MAX_VECTORIZATION_FACTOR 64
821 /* Nonzero if TYPE represents a (scalar) boolean type or type
822 in the middle-end compatible with it (unsigned precision 1 integral
823 types). Used to determine which types should be vectorized as
824 VECTOR_BOOLEAN_TYPE_P. */
826 #define VECT_SCALAR_BOOLEAN_TYPE_P(TYPE) \
827 (TREE_CODE (TYPE) == BOOLEAN_TYPE \
828 || ((TREE_CODE (TYPE) == INTEGER_TYPE \
829 || TREE_CODE (TYPE) == ENUMERAL_TYPE) \
830 && TYPE_PRECISION (TYPE) == 1 \
831 && TYPE_UNSIGNED (TYPE)))
833 extern vec<stmt_vec_info> stmt_vec_info_vec;
835 void init_stmt_vec_info_vec (void);
836 void free_stmt_vec_info_vec (void);
838 /* Return a stmt_vec_info corresponding to STMT. */
840 static inline stmt_vec_info
841 vinfo_for_stmt (gimple *stmt)
843 int uid = gimple_uid (stmt);
844 if (uid <= 0)
845 return NULL;
847 return stmt_vec_info_vec[uid - 1];
850 /* Set vectorizer information INFO for STMT. */
852 static inline void
853 set_vinfo_for_stmt (gimple *stmt, stmt_vec_info info)
855 unsigned int uid = gimple_uid (stmt);
856 if (uid == 0)
858 gcc_checking_assert (info);
859 uid = stmt_vec_info_vec.length () + 1;
860 gimple_set_uid (stmt, uid);
861 stmt_vec_info_vec.safe_push (info);
863 else
865 gcc_checking_assert (info == NULL);
866 stmt_vec_info_vec[uid - 1] = info;
870 /* Return the earlier statement between STMT1 and STMT2. */
872 static inline gimple *
873 get_earlier_stmt (gimple *stmt1, gimple *stmt2)
875 unsigned int uid1, uid2;
877 if (stmt1 == NULL)
878 return stmt2;
880 if (stmt2 == NULL)
881 return stmt1;
883 uid1 = gimple_uid (stmt1);
884 uid2 = gimple_uid (stmt2);
886 if (uid1 == 0 || uid2 == 0)
887 return NULL;
889 gcc_checking_assert (uid1 <= stmt_vec_info_vec.length ()
890 && uid2 <= stmt_vec_info_vec.length ());
892 if (uid1 < uid2)
893 return stmt1;
894 else
895 return stmt2;
898 /* Return the later statement between STMT1 and STMT2. */
900 static inline gimple *
901 get_later_stmt (gimple *stmt1, gimple *stmt2)
903 unsigned int uid1, uid2;
905 if (stmt1 == NULL)
906 return stmt2;
908 if (stmt2 == NULL)
909 return stmt1;
911 uid1 = gimple_uid (stmt1);
912 uid2 = gimple_uid (stmt2);
914 if (uid1 == 0 || uid2 == 0)
915 return NULL;
917 gcc_assert (uid1 <= stmt_vec_info_vec.length ());
918 gcc_assert (uid2 <= stmt_vec_info_vec.length ());
920 if (uid1 > uid2)
921 return stmt1;
922 else
923 return stmt2;
926 /* Return TRUE if a statement represented by STMT_INFO is a part of a
927 pattern. */
929 static inline bool
930 is_pattern_stmt_p (stmt_vec_info stmt_info)
932 gimple *related_stmt;
933 stmt_vec_info related_stmt_info;
935 related_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
936 if (related_stmt
937 && (related_stmt_info = vinfo_for_stmt (related_stmt))
938 && STMT_VINFO_IN_PATTERN_P (related_stmt_info))
939 return true;
941 return false;
944 /* Return true if BB is a loop header. */
946 static inline bool
947 is_loop_header_bb_p (basic_block bb)
949 if (bb == (bb->loop_father)->header)
950 return true;
951 gcc_checking_assert (EDGE_COUNT (bb->preds) == 1);
952 return false;
955 /* Return pow2 (X). */
957 static inline int
958 vect_pow2 (int x)
960 int i, res = 1;
962 for (i = 0; i < x; i++)
963 res *= 2;
965 return res;
968 /* Alias targetm.vectorize.builtin_vectorization_cost. */
970 static inline int
971 builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
972 tree vectype, int misalign)
974 return targetm.vectorize.builtin_vectorization_cost (type_of_cost,
975 vectype, misalign);
978 /* Get cost by calling cost target builtin. */
980 static inline
981 int vect_get_stmt_cost (enum vect_cost_for_stmt type_of_cost)
983 return builtin_vectorization_cost (type_of_cost, NULL, 0);
986 /* Alias targetm.vectorize.init_cost. */
988 static inline void *
989 init_cost (struct loop *loop_info)
991 return targetm.vectorize.init_cost (loop_info);
994 /* Alias targetm.vectorize.add_stmt_cost. */
996 static inline unsigned
997 add_stmt_cost (void *data, int count, enum vect_cost_for_stmt kind,
998 stmt_vec_info stmt_info, int misalign,
999 enum vect_cost_model_location where)
1001 return targetm.vectorize.add_stmt_cost (data, count, kind,
1002 stmt_info, misalign, where);
1005 /* Alias targetm.vectorize.finish_cost. */
1007 static inline void
1008 finish_cost (void *data, unsigned *prologue_cost,
1009 unsigned *body_cost, unsigned *epilogue_cost)
1011 targetm.vectorize.finish_cost (data, prologue_cost, body_cost, epilogue_cost);
1014 /* Alias targetm.vectorize.destroy_cost_data. */
1016 static inline void
1017 destroy_cost_data (void *data)
1019 targetm.vectorize.destroy_cost_data (data);
1022 /*-----------------------------------------------------------------*/
1023 /* Info on data references alignment. */
1024 /*-----------------------------------------------------------------*/
1025 inline void
1026 set_dr_misalignment (struct data_reference *dr, int val)
1028 dataref_aux *data_aux = DR_VECT_AUX (dr);
1030 if (!data_aux)
1032 data_aux = XCNEW (dataref_aux);
1033 dr->aux = data_aux;
1036 data_aux->misalignment = val;
1039 inline int
1040 dr_misalignment (struct data_reference *dr)
1042 return DR_VECT_AUX (dr)->misalignment;
1045 /* Reflects actual alignment of first access in the vectorized loop,
1046 taking into account peeling/versioning if applied. */
1047 #define DR_MISALIGNMENT(DR) dr_misalignment (DR)
1048 #define SET_DR_MISALIGNMENT(DR, VAL) set_dr_misalignment (DR, VAL)
1049 #define DR_MISALIGNMENT_UNKNOWN (-1)
1051 /* Only defined once DR_MISALIGNMENT is defined. */
1052 #define DR_TARGET_ALIGNMENT(DR) DR_VECT_AUX (DR)->target_alignment
1054 /* Return true if data access DR is aligned to its target alignment
1055 (which may be less than a full vector). */
1057 static inline bool
1058 aligned_access_p (struct data_reference *data_ref_info)
1060 return (DR_MISALIGNMENT (data_ref_info) == 0);
1063 /* Return TRUE if the alignment of the data access is known, and FALSE
1064 otherwise. */
1066 static inline bool
1067 known_alignment_for_access_p (struct data_reference *data_ref_info)
1069 return (DR_MISALIGNMENT (data_ref_info) != DR_MISALIGNMENT_UNKNOWN);
1072 /* Return the minimum alignment in bytes that the vectorized version
1073 of DR is guaranteed to have. */
1075 static inline unsigned int
1076 vect_known_alignment_in_bytes (struct data_reference *dr)
1078 if (DR_MISALIGNMENT (dr) == DR_MISALIGNMENT_UNKNOWN)
1079 return TYPE_ALIGN_UNIT (TREE_TYPE (DR_REF (dr)));
1080 if (DR_MISALIGNMENT (dr) == 0)
1081 return DR_TARGET_ALIGNMENT (dr);
1082 return DR_MISALIGNMENT (dr) & -DR_MISALIGNMENT (dr);
1085 /* Return the behavior of DR with respect to the vectorization context
1086 (which for outer loop vectorization might not be the behavior recorded
1087 in DR itself). */
1089 static inline innermost_loop_behavior *
1090 vect_dr_behavior (data_reference *dr)
1092 gimple *stmt = DR_STMT (dr);
1093 stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
1094 loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
1095 if (loop_vinfo == NULL
1096 || !nested_in_vect_loop_p (LOOP_VINFO_LOOP (loop_vinfo), stmt))
1097 return &DR_INNERMOST (dr);
1098 else
1099 return &STMT_VINFO_DR_WRT_VEC_LOOP (stmt_info);
1102 /* Return true if the vect cost model is unlimited. */
1103 static inline bool
1104 unlimited_cost_model (loop_p loop)
1106 if (loop != NULL && loop->force_vectorize
1107 && flag_simd_cost_model != VECT_COST_MODEL_DEFAULT)
1108 return flag_simd_cost_model == VECT_COST_MODEL_UNLIMITED;
1109 return (flag_vect_cost_model == VECT_COST_MODEL_UNLIMITED);
1112 /* Return the number of copies needed for loop vectorization when
1113 a statement operates on vectors of type VECTYPE. This is the
1114 vectorization factor divided by the number of elements in
1115 VECTYPE and is always known at compile time. */
1117 static inline unsigned int
1118 vect_get_num_copies (loop_vec_info loop_vinfo, tree vectype)
1120 gcc_checking_assert (LOOP_VINFO_VECT_FACTOR (loop_vinfo)
1121 % TYPE_VECTOR_SUBPARTS (vectype) == 0);
1122 return (LOOP_VINFO_VECT_FACTOR (loop_vinfo)
1123 / TYPE_VECTOR_SUBPARTS (vectype));
1126 /* Return the size of the value accessed by unvectorized data reference DR.
1127 This is only valid once STMT_VINFO_VECTYPE has been calculated for the
1128 associated gimple statement, since that guarantees that DR accesses
1129 either a scalar or a scalar equivalent. ("Scalar equivalent" here
1130 includes things like V1SI, which can be vectorized in the same way
1131 as a plain SI.) */
1133 inline unsigned int
1134 vect_get_scalar_dr_size (struct data_reference *dr)
1136 return tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr))));
1139 /* Source location */
1140 extern source_location vect_location;
1142 /*-----------------------------------------------------------------*/
1143 /* Function prototypes. */
1144 /*-----------------------------------------------------------------*/
1146 /* Simple loop peeling and versioning utilities for vectorizer's purposes -
1147 in tree-vect-loop-manip.c. */
1148 extern void slpeel_make_loop_iterate_ntimes (struct loop *, tree, tree,
1149 tree, bool);
1150 extern bool slpeel_can_duplicate_loop_p (const struct loop *, const_edge);
1151 struct loop *slpeel_tree_duplicate_loop_to_edge_cfg (struct loop *,
1152 struct loop *, edge);
1153 extern void vect_loop_versioning (loop_vec_info, unsigned int, bool,
1154 poly_uint64);
1155 extern struct loop *vect_do_peeling (loop_vec_info, tree, tree,
1156 tree *, tree *, tree *, int, bool, bool);
1157 extern source_location find_loop_location (struct loop *);
1158 extern bool vect_can_advance_ivs_p (loop_vec_info);
1160 /* In tree-vect-stmts.c. */
1161 extern unsigned int current_vector_size;
1162 extern tree get_vectype_for_scalar_type (tree);
1163 extern tree get_mask_type_for_scalar_type (tree);
1164 extern tree get_same_sized_vectype (tree, tree);
1165 extern bool vect_is_simple_use (tree, vec_info *, gimple **,
1166 enum vect_def_type *);
1167 extern bool vect_is_simple_use (tree, vec_info *, gimple **,
1168 enum vect_def_type *, tree *);
1169 extern bool supportable_widening_operation (enum tree_code, gimple *, tree,
1170 tree, enum tree_code *,
1171 enum tree_code *, int *,
1172 vec<tree> *);
1173 extern bool supportable_narrowing_operation (enum tree_code, tree, tree,
1174 enum tree_code *,
1175 int *, vec<tree> *);
1176 extern stmt_vec_info new_stmt_vec_info (gimple *stmt, vec_info *);
1177 extern void free_stmt_vec_info (gimple *stmt);
1178 extern void vect_model_simple_cost (stmt_vec_info, int, enum vect_def_type *,
1179 int, stmt_vector_for_cost *,
1180 stmt_vector_for_cost *);
1181 extern void vect_model_store_cost (stmt_vec_info, int, vect_memory_access_type,
1182 enum vect_def_type, slp_tree,
1183 stmt_vector_for_cost *,
1184 stmt_vector_for_cost *);
1185 extern void vect_model_load_cost (stmt_vec_info, int, vect_memory_access_type,
1186 slp_tree, stmt_vector_for_cost *,
1187 stmt_vector_for_cost *);
1188 extern unsigned record_stmt_cost (stmt_vector_for_cost *, int,
1189 enum vect_cost_for_stmt, stmt_vec_info,
1190 int, enum vect_cost_model_location);
1191 extern void vect_finish_stmt_generation (gimple *, gimple *,
1192 gimple_stmt_iterator *);
1193 extern bool vect_mark_stmts_to_be_vectorized (loop_vec_info);
1194 extern tree vect_get_vec_def_for_operand_1 (gimple *, enum vect_def_type);
1195 extern tree vect_get_vec_def_for_operand (tree, gimple *, tree = NULL);
1196 extern void vect_get_vec_defs (tree, tree, gimple *, vec<tree> *,
1197 vec<tree> *, slp_tree);
1198 extern void vect_get_vec_defs_for_stmt_copy (enum vect_def_type *,
1199 vec<tree> *, vec<tree> *);
1200 extern tree vect_init_vector (gimple *, tree, tree,
1201 gimple_stmt_iterator *);
1202 extern tree vect_get_vec_def_for_stmt_copy (enum vect_def_type, tree);
1203 extern bool vect_transform_stmt (gimple *, gimple_stmt_iterator *,
1204 bool *, slp_tree, slp_instance);
1205 extern void vect_remove_stores (gimple *);
1206 extern bool vect_analyze_stmt (gimple *, bool *, slp_tree, slp_instance);
1207 extern bool vectorizable_condition (gimple *, gimple_stmt_iterator *,
1208 gimple **, tree, int, slp_tree);
1209 extern void vect_get_load_cost (struct data_reference *, int, bool,
1210 unsigned int *, unsigned int *,
1211 stmt_vector_for_cost *,
1212 stmt_vector_for_cost *, bool);
1213 extern void vect_get_store_cost (struct data_reference *, int,
1214 unsigned int *, stmt_vector_for_cost *);
1215 extern bool vect_supportable_shift (enum tree_code, tree);
1216 extern tree vect_gen_perm_mask_any (tree, const vec_perm_indices &);
1217 extern tree vect_gen_perm_mask_checked (tree, const vec_perm_indices &);
1218 extern void optimize_mask_stores (struct loop*);
1220 /* In tree-vect-data-refs.c. */
1221 extern bool vect_can_force_dr_alignment_p (const_tree, unsigned int);
1222 extern enum dr_alignment_support vect_supportable_dr_alignment
1223 (struct data_reference *, bool);
1224 extern tree vect_get_smallest_scalar_type (gimple *, HOST_WIDE_INT *,
1225 HOST_WIDE_INT *);
1226 extern bool vect_analyze_data_ref_dependences (loop_vec_info, int *);
1227 extern bool vect_slp_analyze_instance_dependence (slp_instance);
1228 extern bool vect_enhance_data_refs_alignment (loop_vec_info);
1229 extern bool vect_analyze_data_refs_alignment (loop_vec_info);
1230 extern bool vect_verify_datarefs_alignment (loop_vec_info);
1231 extern bool vect_slp_analyze_and_verify_instance_alignment (slp_instance);
1232 extern bool vect_analyze_data_ref_accesses (vec_info *);
1233 extern bool vect_prune_runtime_alias_test_list (loop_vec_info);
1234 extern bool vect_check_gather_scatter (gimple *, loop_vec_info,
1235 gather_scatter_info *);
1236 extern bool vect_analyze_data_refs (vec_info *, int *);
1237 extern void vect_record_base_alignments (vec_info *);
1238 extern tree vect_create_data_ref_ptr (gimple *, tree, struct loop *, tree,
1239 tree *, gimple_stmt_iterator *,
1240 gimple **, bool, bool *,
1241 tree = NULL_TREE);
1242 extern tree bump_vector_ptr (tree, gimple *, gimple_stmt_iterator *, gimple *,
1243 tree);
1244 extern tree vect_create_destination_var (tree, tree);
1245 extern bool vect_grouped_store_supported (tree, unsigned HOST_WIDE_INT);
1246 extern bool vect_store_lanes_supported (tree, unsigned HOST_WIDE_INT);
1247 extern bool vect_grouped_load_supported (tree, bool, unsigned HOST_WIDE_INT);
1248 extern bool vect_load_lanes_supported (tree, unsigned HOST_WIDE_INT);
1249 extern void vect_permute_store_chain (vec<tree> ,unsigned int, gimple *,
1250 gimple_stmt_iterator *, vec<tree> *);
1251 extern tree vect_setup_realignment (gimple *, gimple_stmt_iterator *, tree *,
1252 enum dr_alignment_support, tree,
1253 struct loop **);
1254 extern void vect_transform_grouped_load (gimple *, vec<tree> , int,
1255 gimple_stmt_iterator *);
1256 extern void vect_record_grouped_load_vectors (gimple *, vec<tree> );
1257 extern tree vect_get_new_vect_var (tree, enum vect_var_kind, const char *);
1258 extern tree vect_get_new_ssa_name (tree, enum vect_var_kind,
1259 const char * = NULL);
1260 extern tree vect_create_addr_base_for_vector_ref (gimple *, gimple_seq *,
1261 tree, tree = NULL_TREE);
1263 /* In tree-vect-loop.c. */
1264 /* FORNOW: Used in tree-parloops.c. */
1265 extern gimple *vect_force_simple_reduction (loop_vec_info, gimple *,
1266 bool *, bool);
1267 /* Used in gimple-loop-interchange.c. */
1268 extern bool check_reduction_path (location_t, loop_p, gphi *, tree,
1269 enum tree_code);
1270 /* Drive for loop analysis stage. */
1271 extern loop_vec_info vect_analyze_loop (struct loop *, loop_vec_info);
1272 extern tree vect_build_loop_niters (loop_vec_info, bool * = NULL);
1273 extern void vect_gen_vector_loop_niters (loop_vec_info, tree, tree *,
1274 tree *, bool);
1275 /* Drive for loop transformation stage. */
1276 extern struct loop *vect_transform_loop (loop_vec_info);
1277 extern loop_vec_info vect_analyze_loop_form (struct loop *);
1278 extern bool vectorizable_live_operation (gimple *, gimple_stmt_iterator *,
1279 slp_tree, int, gimple **);
1280 extern bool vectorizable_reduction (gimple *, gimple_stmt_iterator *,
1281 gimple **, slp_tree, slp_instance);
1282 extern bool vectorizable_induction (gimple *, gimple_stmt_iterator *,
1283 gimple **, slp_tree);
1284 extern tree get_initial_def_for_reduction (gimple *, tree, tree *);
1285 extern bool vect_worthwhile_without_simd_p (vec_info *, tree_code);
1286 extern int vect_get_known_peeling_cost (loop_vec_info, int, int *,
1287 stmt_vector_for_cost *,
1288 stmt_vector_for_cost *,
1289 stmt_vector_for_cost *);
1291 /* In tree-vect-slp.c. */
1292 extern void vect_free_slp_instance (slp_instance);
1293 extern bool vect_transform_slp_perm_load (slp_tree, vec<tree> ,
1294 gimple_stmt_iterator *, int,
1295 slp_instance, bool, unsigned *);
1296 extern bool vect_slp_analyze_operations (vec_info *);
1297 extern bool vect_schedule_slp (vec_info *);
1298 extern bool vect_analyze_slp (vec_info *, unsigned);
1299 extern bool vect_make_slp_decision (loop_vec_info);
1300 extern void vect_detect_hybrid_slp (loop_vec_info);
1301 extern void vect_get_slp_defs (vec<tree> , slp_tree, vec<vec<tree> > *);
1302 extern bool vect_slp_bb (basic_block);
1303 extern gimple *vect_find_last_scalar_stmt_in_slp (slp_tree);
1304 extern bool is_simple_and_all_uses_invariant (gimple *, loop_vec_info);
1306 /* In tree-vect-patterns.c. */
1307 /* Pattern recognition functions.
1308 Additional pattern recognition functions can (and will) be added
1309 in the future. */
1310 typedef gimple *(* vect_recog_func_ptr) (vec<gimple *> *, tree *, tree *);
1311 #define NUM_PATTERNS 14
1312 void vect_pattern_recog (vec_info *);
1314 /* In tree-vectorizer.c. */
1315 unsigned vectorize_loops (void);
1316 bool vect_stmt_in_region_p (vec_info *, gimple *);
1317 void vect_free_loop_info_assumptions (struct loop *);
1319 #endif /* GCC_TREE_VECTORIZER_H */