1 /* Analysis Utilities for Loop Vectorization.
2 Copyright (C) 2006, 2007 Free Software Foundation, Inc.
3 Contributed by Dorit Nuzman <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 2, or (at your option) any later
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
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
24 #include "coretypes.h"
30 #include "basic-block.h"
31 #include "diagnostic.h"
32 #include "tree-flow.h"
33 #include "tree-dump.h"
39 #include "tree-data-ref.h"
40 #include "tree-vectorizer.h"
44 /* Function prototypes */
45 static void vect_pattern_recog_1
46 (tree (* ) (tree
, tree
*, tree
*), block_stmt_iterator
);
47 static bool widened_name_p (tree
, tree
, tree
*, tree
*);
49 /* Pattern recognition functions */
50 static tree
vect_recog_widen_sum_pattern (tree
, tree
*, tree
*);
51 static tree
vect_recog_widen_mult_pattern (tree
, tree
*, tree
*);
52 static tree
vect_recog_dot_prod_pattern (tree
, tree
*, tree
*);
53 static tree
vect_recog_pow_pattern (tree
, tree
*, tree
*);
54 static vect_recog_func_ptr vect_vect_recog_func_ptrs
[NUM_PATTERNS
] = {
55 vect_recog_widen_mult_pattern
,
56 vect_recog_widen_sum_pattern
,
57 vect_recog_dot_prod_pattern
,
58 vect_recog_pow_pattern
};
61 /* Function widened_name_p
63 Check whether NAME, an ssa-name used in USE_STMT,
64 is a result of a type-promotion, such that:
65 DEF_STMT: NAME = NOP (name0)
66 where the type of name0 (HALF_TYPE) is smaller than the type of NAME.
70 widened_name_p (tree name
, tree use_stmt
, tree
*half_type
, tree
*def_stmt
)
73 loop_vec_info loop_vinfo
;
74 stmt_vec_info stmt_vinfo
;
76 tree type
= TREE_TYPE (name
);
78 enum vect_def_type dt
;
81 stmt_vinfo
= vinfo_for_stmt (use_stmt
);
82 loop_vinfo
= STMT_VINFO_LOOP_VINFO (stmt_vinfo
);
84 if (!vect_is_simple_use (name
, loop_vinfo
, def_stmt
, &def
, &dt
))
87 if (dt
!= vect_loop_def
88 && dt
!= vect_invariant_def
&& dt
!= vect_constant_def
)
94 if (TREE_CODE (*def_stmt
) != GIMPLE_MODIFY_STMT
)
97 expr
= GIMPLE_STMT_OPERAND (*def_stmt
, 1);
98 if (TREE_CODE (expr
) != NOP_EXPR
)
101 oprnd0
= TREE_OPERAND (expr
, 0);
103 *half_type
= TREE_TYPE (oprnd0
);
104 if (!INTEGRAL_TYPE_P (type
) || !INTEGRAL_TYPE_P (*half_type
)
105 || (TYPE_UNSIGNED (type
) != TYPE_UNSIGNED (*half_type
))
106 || (TYPE_PRECISION (type
) < (TYPE_PRECISION (*half_type
) * 2)))
109 if (!vect_is_simple_use (oprnd0
, loop_vinfo
, &dummy
, &dummy
, &dt
))
116 /* Function vect_recog_dot_prod_pattern
118 Try to find the following pattern:
124 sum_0 = phi <init, sum_1>
127 S3 x_T = (TYPE1) x_t;
128 S4 y_T = (TYPE1) y_t;
130 [S6 prod = (TYPE2) prod; #optional]
131 S7 sum_1 = prod + sum_0;
133 where 'TYPE1' is exactly double the size of type 'type', and 'TYPE2' is the
134 same size of 'TYPE1' or bigger. This is a special case of a reduction
139 * LAST_STMT: A stmt from which the pattern search begins. In the example,
140 when this function is called with S7, the pattern {S3,S4,S5,S6,S7} will be
145 * TYPE_IN: The type of the input arguments to the pattern.
147 * TYPE_OUT: The type of the output of this pattern.
149 * Return value: A new stmt that will be used to replace the sequence of
150 stmts that constitute the pattern. In this case it will be:
151 WIDEN_DOT_PRODUCT <x_t, y_t, sum_0>
155 vect_recog_dot_prod_pattern (tree last_stmt
, tree
*type_in
, tree
*type_out
)
159 tree oprnd00
, oprnd01
;
160 stmt_vec_info stmt_vinfo
= vinfo_for_stmt (last_stmt
);
161 tree type
, half_type
;
165 if (TREE_CODE (last_stmt
) != GIMPLE_MODIFY_STMT
)
168 expr
= GIMPLE_STMT_OPERAND (last_stmt
, 1);
169 type
= TREE_TYPE (expr
);
171 /* Look for the following pattern
175 DDPROD = (TYPE2) DPROD;
176 sum_1 = DDPROD + sum_0;
178 - DX is double the size of X
179 - DY is double the size of Y
180 - DX, DY, DPROD all have the same type
181 - sum is the same size of DPROD or bigger
182 - sum has been recognized as a reduction variable.
184 This is equivalent to:
185 DPROD = X w* Y; #widen mult
186 sum_1 = DPROD w+ sum_0; #widen summation
188 DPROD = X w* Y; #widen mult
189 sum_1 = DPROD + sum_0; #summation
192 /* Starting from LAST_STMT, follow the defs of its uses in search
193 of the above pattern. */
195 if (TREE_CODE (expr
) != PLUS_EXPR
)
198 if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo
))
200 /* Has been detected as widening-summation? */
202 stmt
= STMT_VINFO_RELATED_STMT (stmt_vinfo
);
203 expr
= GIMPLE_STMT_OPERAND (stmt
, 1);
204 type
= TREE_TYPE (expr
);
205 if (TREE_CODE (expr
) != WIDEN_SUM_EXPR
)
207 oprnd0
= TREE_OPERAND (expr
, 0);
208 oprnd1
= TREE_OPERAND (expr
, 1);
209 half_type
= TREE_TYPE (oprnd0
);
215 if (STMT_VINFO_DEF_TYPE (stmt_vinfo
) != vect_reduction_def
)
217 oprnd0
= TREE_OPERAND (expr
, 0);
218 oprnd1
= TREE_OPERAND (expr
, 1);
219 if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0
)) != TYPE_MAIN_VARIANT (type
)
220 || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1
)) != TYPE_MAIN_VARIANT (type
))
224 if (widened_name_p (oprnd0
, stmt
, &half_type
, &def_stmt
))
227 expr
= GIMPLE_STMT_OPERAND (stmt
, 1);
228 oprnd0
= TREE_OPERAND (expr
, 0);
234 /* So far so good. Since last_stmt was detected as a (summation) reduction,
235 we know that oprnd1 is the reduction variable (defined by a loop-header
236 phi), and oprnd0 is an ssa-name defined by a stmt in the loop body.
237 Left to check that oprnd0 is defined by a (widen_)mult_expr */
239 prod_type
= half_type
;
240 stmt
= SSA_NAME_DEF_STMT (oprnd0
);
242 stmt_vinfo
= vinfo_for_stmt (stmt
);
243 gcc_assert (stmt_vinfo
);
244 if (STMT_VINFO_DEF_TYPE (stmt_vinfo
) != vect_loop_def
)
246 expr
= GIMPLE_STMT_OPERAND (stmt
, 1);
247 if (TREE_CODE (expr
) != MULT_EXPR
)
249 if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo
))
251 /* Has been detected as a widening multiplication? */
253 stmt
= STMT_VINFO_RELATED_STMT (stmt_vinfo
);
254 expr
= GIMPLE_STMT_OPERAND (stmt
, 1);
255 if (TREE_CODE (expr
) != WIDEN_MULT_EXPR
)
257 stmt_vinfo
= vinfo_for_stmt (stmt
);
258 gcc_assert (stmt_vinfo
);
259 gcc_assert (STMT_VINFO_DEF_TYPE (stmt_vinfo
) == vect_loop_def
);
260 oprnd00
= TREE_OPERAND (expr
, 0);
261 oprnd01
= TREE_OPERAND (expr
, 1);
265 tree half_type0
, half_type1
;
269 oprnd0
= TREE_OPERAND (expr
, 0);
270 oprnd1
= TREE_OPERAND (expr
, 1);
271 if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0
))
272 != TYPE_MAIN_VARIANT (prod_type
)
273 || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1
))
274 != TYPE_MAIN_VARIANT (prod_type
))
276 if (!widened_name_p (oprnd0
, stmt
, &half_type0
, &def_stmt
))
278 oprnd00
= TREE_OPERAND (GIMPLE_STMT_OPERAND (def_stmt
, 1), 0);
279 if (!widened_name_p (oprnd1
, stmt
, &half_type1
, &def_stmt
))
281 oprnd01
= TREE_OPERAND (GIMPLE_STMT_OPERAND (def_stmt
, 1), 0);
282 if (TYPE_MAIN_VARIANT (half_type0
) != TYPE_MAIN_VARIANT (half_type1
))
284 if (TYPE_PRECISION (prod_type
) != TYPE_PRECISION (half_type0
) * 2)
288 half_type
= TREE_TYPE (oprnd00
);
289 *type_in
= half_type
;
292 /* Pattern detected. Create a stmt to be used to replace the pattern: */
293 pattern_expr
= build3 (DOT_PROD_EXPR
, type
, oprnd00
, oprnd01
, oprnd1
);
294 if (vect_print_dump_info (REPORT_DETAILS
))
296 fprintf (vect_dump
, "vect_recog_dot_prod_pattern: detected: ");
297 print_generic_expr (vect_dump
, pattern_expr
, TDF_SLIM
);
303 /* Function vect_recog_widen_mult_pattern
305 Try to find the following pattern:
308 TYPE a_T, b_T, prod_T;
314 S5 prod_T = a_T * b_T;
316 where type 'TYPE' is at least double the size of type 'type'.
320 * LAST_STMT: A stmt from which the pattern search begins. In the example,
321 when this function is called with S5, the pattern {S3,S4,S5} is be detected.
325 * TYPE_IN: The type of the input arguments to the pattern.
327 * TYPE_OUT: The type of the output of this pattern.
329 * Return value: A new stmt that will be used to replace the sequence of
330 stmts that constitute the pattern. In this case it will be:
331 WIDEN_MULT <a_t, b_t>
335 vect_recog_widen_mult_pattern (tree last_stmt
,
340 tree def_stmt0
, def_stmt1
;
342 tree type
, half_type0
, half_type1
;
346 enum tree_code dummy_code
;
348 if (TREE_CODE (last_stmt
) != GIMPLE_MODIFY_STMT
)
351 expr
= GIMPLE_STMT_OPERAND (last_stmt
, 1);
352 type
= TREE_TYPE (expr
);
354 /* Starting from LAST_STMT, follow the defs of its uses in search
355 of the above pattern. */
357 if (TREE_CODE (expr
) != MULT_EXPR
)
360 oprnd0
= TREE_OPERAND (expr
, 0);
361 oprnd1
= TREE_OPERAND (expr
, 1);
362 if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0
)) != TYPE_MAIN_VARIANT (type
)
363 || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1
)) != TYPE_MAIN_VARIANT (type
))
366 /* Check argument 0 */
367 if (!widened_name_p (oprnd0
, last_stmt
, &half_type0
, &def_stmt0
))
369 oprnd0
= TREE_OPERAND (GIMPLE_STMT_OPERAND (def_stmt0
, 1), 0);
371 /* Check argument 1 */
372 if (!widened_name_p (oprnd1
, last_stmt
, &half_type1
, &def_stmt1
))
374 oprnd1
= TREE_OPERAND (GIMPLE_STMT_OPERAND (def_stmt1
, 1), 0);
376 if (TYPE_MAIN_VARIANT (half_type0
) != TYPE_MAIN_VARIANT (half_type1
))
379 /* Pattern detected. */
380 if (vect_print_dump_info (REPORT_DETAILS
))
381 fprintf (vect_dump
, "vect_recog_widen_mult_pattern: detected: ");
383 /* Check target support */
384 vectype
= get_vectype_for_scalar_type (half_type0
);
386 || !supportable_widening_operation (WIDEN_MULT_EXPR
, last_stmt
, vectype
,
387 &dummy
, &dummy
, &dummy_code
,
392 *type_out
= NULL_TREE
;
394 /* Pattern supported. Create a stmt to be used to replace the pattern: */
395 pattern_expr
= build2 (WIDEN_MULT_EXPR
, type
, oprnd0
, oprnd1
);
396 if (vect_print_dump_info (REPORT_DETAILS
))
397 print_generic_expr (vect_dump
, pattern_expr
, TDF_SLIM
);
402 /* Function vect_recog_pow_pattern
404 Try to find the following pattern:
408 with POW being one of pow, powf, powi, powif and N being
413 * LAST_STMT: A stmt from which the pattern search begins.
417 * TYPE_IN: The type of the input arguments to the pattern.
419 * TYPE_OUT: The type of the output of this pattern.
421 * Return value: A new stmt that will be used to replace the sequence of
422 stmts that constitute the pattern. In this case it will be:
429 vect_recog_pow_pattern (tree last_stmt
, tree
*type_in
, tree
*type_out
)
435 if (TREE_CODE (last_stmt
) != GIMPLE_MODIFY_STMT
)
438 expr
= GIMPLE_STMT_OPERAND (last_stmt
, 1);
439 type
= TREE_TYPE (expr
);
441 if (TREE_CODE (expr
) != CALL_EXPR
)
444 fn
= get_callee_fndecl (expr
);
445 switch (DECL_FUNCTION_CODE (fn
))
451 base
= CALL_EXPR_ARG (expr
, 0);
452 exp
= CALL_EXPR_ARG (expr
, 1);
453 if (TREE_CODE (exp
) != REAL_CST
454 && TREE_CODE (exp
) != INTEGER_CST
)
462 /* We now have a pow or powi builtin function call with a constant
465 *type_out
= NULL_TREE
;
467 /* Catch squaring. */
468 if ((host_integerp (exp
, 0)
469 && tree_low_cst (exp
, 0) == 2)
470 || (TREE_CODE (exp
) == REAL_CST
471 && REAL_VALUES_EQUAL (TREE_REAL_CST (exp
), dconst2
)))
473 *type_in
= TREE_TYPE (base
);
474 return build2 (MULT_EXPR
, TREE_TYPE (base
), base
, base
);
477 /* Catch square root. */
478 if (TREE_CODE (exp
) == REAL_CST
479 && REAL_VALUES_EQUAL (TREE_REAL_CST (exp
), dconsthalf
))
481 tree newfn
= mathfn_built_in (TREE_TYPE (base
), BUILT_IN_SQRT
);
482 *type_in
= get_vectype_for_scalar_type (TREE_TYPE (base
));
485 newfn
= build_call_expr (newfn
, 1, base
);
486 if (vectorizable_function (newfn
, *type_in
, *type_in
) != NULL_TREE
)
495 /* Function vect_recog_widen_sum_pattern
497 Try to find the following pattern:
500 TYPE x_T, sum = init;
502 sum_0 = phi <init, sum_1>
505 S3 sum_1 = x_T + sum_0;
507 where type 'TYPE' is at least double the size of type 'type', i.e - we're
508 summing elements of type 'type' into an accumulator of type 'TYPE'. This is
509 a special case of a reduction computation.
513 * LAST_STMT: A stmt from which the pattern search begins. In the example,
514 when this function is called with S3, the pattern {S2,S3} will be detected.
518 * TYPE_IN: The type of the input arguments to the pattern.
520 * TYPE_OUT: The type of the output of this pattern.
522 * Return value: A new stmt that will be used to replace the sequence of
523 stmts that constitute the pattern. In this case it will be:
524 WIDEN_SUM <x_t, sum_0>
528 vect_recog_widen_sum_pattern (tree last_stmt
, tree
*type_in
, tree
*type_out
)
532 stmt_vec_info stmt_vinfo
= vinfo_for_stmt (last_stmt
);
533 tree type
, half_type
;
536 if (TREE_CODE (last_stmt
) != GIMPLE_MODIFY_STMT
)
539 expr
= GIMPLE_STMT_OPERAND (last_stmt
, 1);
540 type
= TREE_TYPE (expr
);
542 /* Look for the following pattern
545 In which DX is at least double the size of X, and sum_1 has been
546 recognized as a reduction variable.
549 /* Starting from LAST_STMT, follow the defs of its uses in search
550 of the above pattern. */
552 if (TREE_CODE (expr
) != PLUS_EXPR
)
555 if (STMT_VINFO_DEF_TYPE (stmt_vinfo
) != vect_reduction_def
)
558 oprnd0
= TREE_OPERAND (expr
, 0);
559 oprnd1
= TREE_OPERAND (expr
, 1);
560 if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0
)) != TYPE_MAIN_VARIANT (type
)
561 || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1
)) != TYPE_MAIN_VARIANT (type
))
564 /* So far so good. Since last_stmt was detected as a (summation) reduction,
565 we know that oprnd1 is the reduction variable (defined by a loop-header
566 phi), and oprnd0 is an ssa-name defined by a stmt in the loop body.
567 Left to check that oprnd0 is defined by a cast from type 'type' to type
570 if (!widened_name_p (oprnd0
, last_stmt
, &half_type
, &stmt
))
573 oprnd0
= TREE_OPERAND (GIMPLE_STMT_OPERAND (stmt
, 1), 0);
574 *type_in
= half_type
;
577 /* Pattern detected. Create a stmt to be used to replace the pattern: */
578 pattern_expr
= build2 (WIDEN_SUM_EXPR
, type
, oprnd0
, oprnd1
);
579 if (vect_print_dump_info (REPORT_DETAILS
))
581 fprintf (vect_dump
, "vect_recog_widen_sum_pattern: detected: ");
582 print_generic_expr (vect_dump
, pattern_expr
, TDF_SLIM
);
588 /* Function vect_pattern_recog_1
591 PATTERN_RECOG_FUNC: A pointer to a function that detects a certain
593 STMT: A stmt from which the pattern search should start.
595 If PATTERN_RECOG_FUNC successfully detected the pattern, it creates an
596 expression that computes the same functionality and can be used to
597 replace the sequence of stmts that are involved in the pattern.
600 This function checks if the expression returned by PATTERN_RECOG_FUNC is
601 supported in vector form by the target. We use 'TYPE_IN' to obtain the
602 relevant vector type. If 'TYPE_IN' is already a vector type, then this
603 indicates that target support had already been checked by PATTERN_RECOG_FUNC.
604 If 'TYPE_OUT' is also returned by PATTERN_RECOG_FUNC, we check that it fits
605 to the available target pattern.
607 This function also does some bookkeeping, as explained in the documentation
608 for vect_recog_pattern. */
611 vect_pattern_recog_1 (
612 tree (* vect_recog_func
) (tree
, tree
*, tree
*),
613 block_stmt_iterator si
)
615 tree stmt
= bsi_stmt (si
);
616 stmt_vec_info stmt_info
= vinfo_for_stmt (stmt
);
617 stmt_vec_info pattern_stmt_info
;
618 loop_vec_info loop_vinfo
= STMT_VINFO_LOOP_VINFO (stmt_info
);
620 tree pattern_vectype
;
621 tree type_in
, type_out
;
627 pattern_expr
= (* vect_recog_func
) (stmt
, &type_in
, &type_out
);
631 if (VECTOR_MODE_P (TYPE_MODE (type_in
)))
633 /* No need to check target support (already checked by the pattern
634 recognition function). */
635 pattern_vectype
= type_in
;
639 enum tree_code vec_mode
;
640 enum insn_code icode
;
643 /* Check target support */
644 pattern_vectype
= get_vectype_for_scalar_type (type_in
);
645 if (!pattern_vectype
)
648 optab
= optab_for_tree_code (TREE_CODE (pattern_expr
), pattern_vectype
);
649 vec_mode
= TYPE_MODE (pattern_vectype
);
651 || (icode
= optab
->handlers
[(int) vec_mode
].insn_code
) ==
654 && (!get_vectype_for_scalar_type (type_out
)
655 || (insn_data
[icode
].operand
[0].mode
!=
656 TYPE_MODE (get_vectype_for_scalar_type (type_out
))))))
660 /* Found a vectorizable pattern. */
661 if (vect_print_dump_info (REPORT_DETAILS
))
663 fprintf (vect_dump
, "pattern recognized: ");
664 print_generic_expr (vect_dump
, pattern_expr
, TDF_SLIM
);
667 /* Mark the stmts that are involved in the pattern,
668 create a new stmt to express the pattern and insert it. */
669 code
= TREE_CODE (pattern_expr
);
670 pattern_type
= TREE_TYPE (pattern_expr
);
671 var
= create_tmp_var (pattern_type
, "patt");
672 add_referenced_var (var
);
673 var_name
= make_ssa_name (var
, NULL_TREE
);
674 pattern_expr
= build_gimple_modify_stmt (var_name
, pattern_expr
);
675 SSA_NAME_DEF_STMT (var_name
) = pattern_expr
;
676 bsi_insert_before (&si
, pattern_expr
, BSI_SAME_STMT
);
677 ann
= stmt_ann (pattern_expr
);
678 set_stmt_info (ann
, new_stmt_vec_info (pattern_expr
, loop_vinfo
));
679 pattern_stmt_info
= vinfo_for_stmt (pattern_expr
);
681 STMT_VINFO_RELATED_STMT (pattern_stmt_info
) = stmt
;
682 STMT_VINFO_DEF_TYPE (pattern_stmt_info
) = STMT_VINFO_DEF_TYPE (stmt_info
);
683 STMT_VINFO_VECTYPE (pattern_stmt_info
) = pattern_vectype
;
684 STMT_VINFO_IN_PATTERN_P (stmt_info
) = true;
685 STMT_VINFO_RELATED_STMT (stmt_info
) = pattern_expr
;
691 /* Function vect_pattern_recog
694 LOOP_VINFO - a struct_loop_info of a loop in which we want to look for
697 Output - for each computation idiom that is detected we insert a new stmt
698 that provides the same functionality and that can be vectorized. We
699 also record some information in the struct_stmt_info of the relevant
700 stmts, as explained below:
702 At the entry to this function we have the following stmts, with the
703 following initial value in the STMT_VINFO fields:
705 stmt in_pattern_p related_stmt vec_stmt
707 S2: a_2 = ..use(a_i).. - - -
708 S3: a_1 = ..use(a_2).. - - -
709 S4: a_0 = ..use(a_1).. - - -
710 S5: ... = ..use(a_0).. - - -
712 Say the sequence {S1,S2,S3,S4} was detected as a pattern that can be
713 represented by a single stmt. We then:
714 - create a new stmt S6 that will replace the pattern.
715 - insert the new stmt S6 before the last stmt in the pattern
716 - fill in the STMT_VINFO fields as follows:
718 in_pattern_p related_stmt vec_stmt
720 S2: a_2 = ..use(a_i).. - - -
721 S3: a_1 = ..use(a_2).. - - -
722 > S6: a_new = .... - S4 -
723 S4: a_0 = ..use(a_1).. true S6 -
724 S5: ... = ..use(a_0).. - - -
726 (the last stmt in the pattern (S4) and the new pattern stmt (S6) point
727 to each other through the RELATED_STMT field).
729 S6 will be marked as relevant in vect_mark_stmts_to_be_vectorized instead
730 of S4 because it will replace all its uses. Stmts {S1,S2,S3} will
731 remain irrelevant unless used by stmts other than S4.
733 If vectorization succeeds, vect_transform_stmt will skip over {S1,S2,S3}
734 (because they are marked as irrelevant). It will vectorize S6, and record
735 a pointer to the new vector stmt VS6 both from S6 (as usual), and also
736 from S4. We do that so that when we get to vectorizing stmts that use the
737 def of S4 (like S5 that uses a_0), we'll know where to take the relevant
738 vector-def from. S4 will be skipped, and S5 will be vectorized as usual:
740 in_pattern_p related_stmt vec_stmt
742 S2: a_2 = ..use(a_i).. - - -
743 S3: a_1 = ..use(a_2).. - - -
744 > VS6: va_new = .... - - -
745 S6: a_new = .... - S4 VS6
746 S4: a_0 = ..use(a_1).. true S6 VS6
747 > VS5: ... = ..vuse(va_new).. - - -
748 S5: ... = ..use(a_0).. - - -
750 DCE could then get rid of {S1,S2,S3,S4,S5,S6} (if their defs are not used
751 elsewhere), and we'll end up with:
754 VS5: ... = ..vuse(va_new)..
756 If vectorization does not succeed, DCE will clean S6 away (its def is
757 not used), and we'll end up with the original sequence.
761 vect_pattern_recog (loop_vec_info loop_vinfo
)
763 struct loop
*loop
= LOOP_VINFO_LOOP (loop_vinfo
);
764 basic_block
*bbs
= LOOP_VINFO_BBS (loop_vinfo
);
765 unsigned int nbbs
= loop
->num_nodes
;
766 block_stmt_iterator si
;
769 tree (* vect_recog_func_ptr
) (tree
, tree
*, tree
*);
771 if (vect_print_dump_info (REPORT_DETAILS
))
772 fprintf (vect_dump
, "=== vect_pattern_recog ===");
774 /* Scan through the loop stmts, applying the pattern recognition
775 functions starting at each stmt visited: */
776 for (i
= 0; i
< nbbs
; i
++)
778 basic_block bb
= bbs
[i
];
779 for (si
= bsi_start (bb
); !bsi_end_p (si
); bsi_next (&si
))
781 stmt
= bsi_stmt (si
);
783 /* Scan over all generic vect_recog_xxx_pattern functions. */
784 for (j
= 0; j
< NUM_PATTERNS
; j
++)
786 vect_recog_func_ptr
= vect_vect_recog_func_ptrs
[j
];
787 vect_pattern_recog_1 (vect_recog_func_ptr
, si
);