OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [tree-vect-patterns.c] - Blame information for rev 199

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* Analysis Utilities for Loop Vectorization.
2
   Copyright (C) 2006, 2007 Free Software Foundation, Inc.
3
   Contributed by Dorit Nuzman <dorit@il.ibm.com>
4
 
5
This file is part of GCC.
6
 
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.
11
 
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.
16
 
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/>.  */
20
 
21
#include "config.h"
22
#include "system.h"
23
#include "coretypes.h"
24
#include "tm.h"
25
#include "ggc.h"
26
#include "tree.h"
27
 
28
#include "target.h"
29
#include "basic-block.h"
30
#include "diagnostic.h"
31
#include "tree-flow.h"
32
#include "tree-dump.h"
33
#include "timevar.h"
34
#include "cfgloop.h"
35
#include "expr.h"
36
#include "optabs.h"
37
#include "params.h"
38
#include "tree-data-ref.h"
39
#include "tree-vectorizer.h"
40
#include "recog.h"
41
#include "toplev.h"
42
 
43
/* Function prototypes */
44
static void vect_pattern_recog_1
45
  (tree (* ) (tree, tree *, tree *), block_stmt_iterator);
46
static bool widened_name_p (tree, tree, tree *, tree *);
47
 
48
/* Pattern recognition functions  */
49
static tree vect_recog_widen_sum_pattern (tree, tree *, tree *);
50
static tree vect_recog_widen_mult_pattern (tree, tree *, tree *);
51
static tree vect_recog_dot_prod_pattern (tree, tree *, tree *);
52
static vect_recog_func_ptr vect_vect_recog_func_ptrs[NUM_PATTERNS] = {
53
        vect_recog_widen_mult_pattern,
54
        vect_recog_widen_sum_pattern,
55
        vect_recog_dot_prod_pattern};
56
 
57
 
58
/* Function widened_name_p
59
 
60
   Check whether NAME, an ssa-name used in USE_STMT,
61
   is a result of a type-promotion, such that:
62
     DEF_STMT: NAME = NOP (name0)
63
   where the type of name0 (HALF_TYPE) is smaller than the type of NAME.
64
*/
65
 
66
static bool
67
widened_name_p (tree name, tree use_stmt, tree *half_type, tree *def_stmt)
68
{
69
  tree dummy;
70
  loop_vec_info loop_vinfo;
71
  stmt_vec_info stmt_vinfo;
72
  tree expr;
73
  tree type = TREE_TYPE (name);
74
  tree oprnd0;
75
  enum vect_def_type dt;
76
  tree def;
77
 
78
  stmt_vinfo = vinfo_for_stmt (use_stmt);
79
  loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_vinfo);
80
 
81
  if (!vect_is_simple_use (name, loop_vinfo, def_stmt, &def, &dt))
82
    return false;
83
 
84
  if (dt != vect_loop_def
85
      && dt != vect_invariant_def && dt != vect_constant_def)
86
    return false;
87
 
88
  if (! *def_stmt)
89
    return false;
90
 
91
  if (TREE_CODE (*def_stmt) != MODIFY_EXPR)
92
    return false;
93
 
94
  expr = TREE_OPERAND (*def_stmt, 1);
95
  if (TREE_CODE (expr) != NOP_EXPR)
96
    return false;
97
 
98
  oprnd0 = TREE_OPERAND (expr, 0);
99
 
100
  *half_type = TREE_TYPE (oprnd0);
101
  if (!INTEGRAL_TYPE_P (type) || !INTEGRAL_TYPE_P (*half_type)
102
      || (TYPE_UNSIGNED (type) != TYPE_UNSIGNED (*half_type))
103
      || (TYPE_PRECISION (type) < (TYPE_PRECISION (*half_type) * 2)))
104
    return false;
105
 
106
  if (!vect_is_simple_use (oprnd0, loop_vinfo, &dummy, &dummy, &dt))
107
    return false;
108
 
109
  if (dt != vect_invariant_def && dt != vect_constant_def
110
      && dt != vect_loop_def)
111
    return false;
112
 
113
  return true;
114
}
115
 
116
 
117
/* Function vect_recog_dot_prod_pattern
118
 
119
   Try to find the following pattern:
120
 
121
     type x_t, y_t;
122
     TYPE1 prod;
123
     TYPE2 sum = init;
124
   loop:
125
     sum_0 = phi <init, sum_1>
126
     S1  x_t = ...
127
     S2  y_t = ...
128
     S3  x_T = (TYPE1) x_t;
129
     S4  y_T = (TYPE1) y_t;
130
     S5  prod = x_T * y_T;
131
     [S6  prod = (TYPE2) prod;  #optional]
132
     S7  sum_1 = prod + sum_0;
133
 
134
   where 'TYPE1' is exactly double the size of type 'type', and 'TYPE2' is the
135
   same size of 'TYPE1' or bigger. This is a special case of a reduction
136
   computation.
137
 
138
   Input:
139
 
140
   * LAST_STMT: A stmt from which the pattern search begins. In the example,
141
   when this function is called with S7, the pattern {S3,S4,S5,S6,S7} will be
142
   detected.
143
 
144
   Output:
145
 
146
   * TYPE_IN: The type of the input arguments to the pattern.
147
 
148
   * TYPE_OUT: The type of the output  of this pattern.
149
 
150
   * Return value: A new stmt that will be used to replace the sequence of
151
   stmts that constitute the pattern. In this case it will be:
152
        WIDEN_DOT_PRODUCT <x_t, y_t, sum_0>
153
*/
154
 
155
static tree
156
vect_recog_dot_prod_pattern (tree last_stmt, tree *type_in, tree *type_out)
157
{
158
  tree stmt, expr;
159
  tree oprnd0, oprnd1;
160
  tree oprnd00, oprnd01;
161
  stmt_vec_info stmt_vinfo = vinfo_for_stmt (last_stmt);
162
  tree type, half_type;
163
  tree pattern_expr;
164
  tree prod_type;
165
 
166
  if (TREE_CODE (last_stmt) != MODIFY_EXPR)
167
    return NULL;
168
 
169
  expr = TREE_OPERAND (last_stmt, 1);
170
  type = TREE_TYPE (expr);
171
 
172
  /* Look for the following pattern
173
          DX = (TYPE1) X;
174
          DY = (TYPE1) Y;
175
          DPROD = DX * DY;
176
          DDPROD = (TYPE2) DPROD;
177
          sum_1 = DDPROD + sum_0;
178
     In which
179
     - DX is double the size of X
180
     - DY is double the size of Y
181
     - DX, DY, DPROD all have the same type
182
     - sum is the same size of DPROD or bigger
183
     - sum has been recognized as a reduction variable.
184
 
185
     This is equivalent to:
186
       DPROD = X w* Y;          #widen mult
187
       sum_1 = DPROD w+ sum_0;  #widen summation
188
     or
189
       DPROD = X w* Y;          #widen mult
190
       sum_1 = DPROD + sum_0;   #summation
191
   */
192
 
193
  /* Starting from LAST_STMT, follow the defs of its uses in search
194
     of the above pattern.  */
195
 
196
  if (TREE_CODE (expr) != PLUS_EXPR)
197
    return NULL;
198
 
199
  if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo))
200
    {
201
      /* Has been detected as widening-summation?  */
202
 
203
      stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo);
204
      expr = TREE_OPERAND (stmt, 1);
205
      type = TREE_TYPE (expr);
206
      if (TREE_CODE (expr) != WIDEN_SUM_EXPR)
207
        return NULL;
208
      oprnd0 = TREE_OPERAND (expr, 0);
209
      oprnd1 = TREE_OPERAND (expr, 1);
210
      half_type = TREE_TYPE (oprnd0);
211
    }
212
  else
213
    {
214
      tree def_stmt;
215
 
216
      if (STMT_VINFO_DEF_TYPE (stmt_vinfo) != vect_reduction_def)
217
        return NULL;
218
      oprnd0 = TREE_OPERAND (expr, 0);
219
      oprnd1 = TREE_OPERAND (expr, 1);
220
      if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0)) != TYPE_MAIN_VARIANT (type)
221
          || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1)) != TYPE_MAIN_VARIANT (type))
222
        return NULL;
223
      stmt = last_stmt;
224
 
225
      if (widened_name_p (oprnd0, stmt, &half_type, &def_stmt))
226
        {
227
          stmt = def_stmt;
228
          expr = TREE_OPERAND (stmt, 1);
229
          oprnd0 = TREE_OPERAND (expr, 0);
230
        }
231
      else
232
        half_type = type;
233
    }
234
 
235
  /* So far so good. Since last_stmt was detected as a (summation) reduction,
236
     we know that oprnd1 is the reduction variable (defined by a loop-header
237
     phi), and oprnd0 is an ssa-name defined by a stmt in the loop body.
238
     Left to check that oprnd0 is defined by a (widen_)mult_expr  */
239
 
240
  prod_type = half_type;
241
  stmt = SSA_NAME_DEF_STMT (oprnd0);
242
  gcc_assert (stmt);
243
  stmt_vinfo = vinfo_for_stmt (stmt);
244
  gcc_assert (stmt_vinfo);
245
  if (STMT_VINFO_DEF_TYPE (stmt_vinfo) != vect_loop_def)
246
    return NULL;
247
  expr = TREE_OPERAND (stmt, 1);
248
  if (TREE_CODE (expr) != MULT_EXPR)
249
    return NULL;
250
  if (STMT_VINFO_IN_PATTERN_P (stmt_vinfo))
251
    {
252
      /* Has been detected as a widening multiplication?  */
253
 
254
      stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo);
255
      expr = TREE_OPERAND (stmt, 1);
256
      if (TREE_CODE (expr) != WIDEN_MULT_EXPR)
257
        return NULL;
258
      stmt_vinfo = vinfo_for_stmt (stmt);
259
      gcc_assert (stmt_vinfo);
260
      gcc_assert (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_loop_def);
261
      oprnd00 = TREE_OPERAND (expr, 0);
262
      oprnd01 = TREE_OPERAND (expr, 1);
263
    }
264
  else
265
    {
266
      tree half_type0, half_type1;
267
      tree def_stmt;
268
      tree oprnd0, oprnd1;
269
 
270
      oprnd0 = TREE_OPERAND (expr, 0);
271
      oprnd1 = TREE_OPERAND (expr, 1);
272
      if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0))
273
                                != TYPE_MAIN_VARIANT (prod_type)
274
          || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1))
275
                                != TYPE_MAIN_VARIANT (prod_type))
276
        return NULL;
277
      if (!widened_name_p (oprnd0, stmt, &half_type0, &def_stmt))
278
        return NULL;
279
      oprnd00 = TREE_OPERAND (TREE_OPERAND (def_stmt, 1), 0);
280
      if (!widened_name_p (oprnd1, stmt, &half_type1, &def_stmt))
281
        return NULL;
282
      oprnd01 = TREE_OPERAND (TREE_OPERAND (def_stmt, 1), 0);
283
      if (TYPE_MAIN_VARIANT (half_type0) != TYPE_MAIN_VARIANT (half_type1))
284
        return NULL;
285
      if (TYPE_PRECISION (prod_type) != TYPE_PRECISION (half_type0) * 2)
286
        return NULL;
287
    }
288
 
289
  half_type = TREE_TYPE (oprnd00);
290
  *type_in = half_type;
291
  *type_out = type;
292
 
293
  /* Pattern detected. Create a stmt to be used to replace the pattern: */
294
  pattern_expr = build3 (DOT_PROD_EXPR, type, oprnd00, oprnd01, oprnd1);
295
  if (vect_print_dump_info (REPORT_DETAILS))
296
    {
297
      fprintf (vect_dump, "vect_recog_dot_prod_pattern: detected: ");
298
      print_generic_expr (vect_dump, pattern_expr, TDF_SLIM);
299
    }
300
  return pattern_expr;
301
}
302
 
303
 
304
/* Function vect_recog_widen_mult_pattern
305
 
306
   Try to find the following pattern:
307
 
308
     type a_t, b_t;
309
     TYPE a_T, b_T, prod_T;
310
 
311
     S1  a_t = ;
312
     S2  b_t = ;
313
     S3  a_T = (TYPE) a_t;
314
     S4  b_T = (TYPE) b_t;
315
     S5  prod_T = a_T * b_T;
316
 
317
   where type 'TYPE' is at least double the size of type 'type'.
318
 
319
   Input:
320
 
321
   * LAST_STMT: A stmt from which the pattern search begins. In the example,
322
   when this function is called with S5, the pattern {S3,S4,S5} is be detected.
323
 
324
   Output:
325
 
326
   * TYPE_IN: The type of the input arguments to the pattern.
327
 
328
   * TYPE_OUT: The type of the output  of this pattern.
329
 
330
   * Return value: A new stmt that will be used to replace the sequence of
331
   stmts that constitute the pattern. In this case it will be:
332
        WIDEN_MULT <a_t, b_t>
333
*/
334
 
335
static tree
336
vect_recog_widen_mult_pattern (tree last_stmt ATTRIBUTE_UNUSED,
337
                               tree *type_in ATTRIBUTE_UNUSED,
338
                               tree *type_out ATTRIBUTE_UNUSED)
339
{
340
  /* Yet to be implemented.   */
341
  return NULL;
342
}
343
 
344
 
345
/* Function vect_recog_widen_sum_pattern
346
 
347
   Try to find the following pattern:
348
 
349
     type x_t;
350
     TYPE x_T, sum = init;
351
   loop:
352
     sum_0 = phi <init, sum_1>
353
     S1  x_t = *p;
354
     S2  x_T = (TYPE) x_t;
355
     S3  sum_1 = x_T + sum_0;
356
 
357
   where type 'TYPE' is at least double the size of type 'type', i.e - we're
358
   summing elements of type 'type' into an accumulator of type 'TYPE'. This is
359
   a special case of a reduction computation.
360
 
361
   Input:
362
 
363
   * LAST_STMT: A stmt from which the pattern search begins. In the example,
364
   when this function is called with S3, the pattern {S2,S3} will be detected.
365
 
366
   Output:
367
 
368
   * TYPE_IN: The type of the input arguments to the pattern.
369
 
370
   * TYPE_OUT: The type of the output of this pattern.
371
 
372
   * Return value: A new stmt that will be used to replace the sequence of
373
   stmts that constitute the pattern. In this case it will be:
374
        WIDEN_SUM <x_t, sum_0>
375
*/
376
 
377
static tree
378
vect_recog_widen_sum_pattern (tree last_stmt, tree *type_in, tree *type_out)
379
{
380
  tree stmt, expr;
381
  tree oprnd0, oprnd1;
382
  stmt_vec_info stmt_vinfo = vinfo_for_stmt (last_stmt);
383
  tree type, half_type;
384
  tree pattern_expr;
385
 
386
  if (TREE_CODE (last_stmt) != MODIFY_EXPR)
387
    return NULL;
388
 
389
  expr = TREE_OPERAND (last_stmt, 1);
390
  type = TREE_TYPE (expr);
391
 
392
  /* Look for the following pattern
393
          DX = (TYPE) X;
394
          sum_1 = DX + sum_0;
395
     In which DX is at least double the size of X, and sum_1 has been
396
     recognized as a reduction variable.
397
   */
398
 
399
  /* Starting from LAST_STMT, follow the defs of its uses in search
400
     of the above pattern.  */
401
 
402
  if (TREE_CODE (expr) != PLUS_EXPR)
403
    return NULL;
404
 
405
  if (STMT_VINFO_DEF_TYPE (stmt_vinfo) != vect_reduction_def)
406
    return NULL;
407
 
408
  oprnd0 = TREE_OPERAND (expr, 0);
409
  oprnd1 = TREE_OPERAND (expr, 1);
410
  if (TYPE_MAIN_VARIANT (TREE_TYPE (oprnd0)) != TYPE_MAIN_VARIANT (type)
411
      || TYPE_MAIN_VARIANT (TREE_TYPE (oprnd1)) != TYPE_MAIN_VARIANT (type))
412
    return NULL;
413
 
414
  /* So far so good. Since last_stmt was detected as a (summation) reduction,
415
     we know that oprnd1 is the reduction variable (defined by a loop-header
416
     phi), and oprnd0 is an ssa-name defined by a stmt in the loop body.
417
     Left to check that oprnd0 is defined by a cast from type 'type' to type
418
     'TYPE'.  */
419
 
420
  if (!widened_name_p (oprnd0, last_stmt, &half_type, &stmt))
421
    return NULL;
422
 
423
  oprnd0 = TREE_OPERAND (TREE_OPERAND (stmt, 1), 0);
424
  *type_in = half_type;
425
  *type_out = type;
426
 
427
  /* Pattern detected. Create a stmt to be used to replace the pattern: */
428
  pattern_expr = build2 (WIDEN_SUM_EXPR, type, oprnd0, oprnd1);
429
  if (vect_print_dump_info (REPORT_DETAILS))
430
    {
431
      fprintf (vect_dump, "vect_recog_widen_sum_pattern: detected: ");
432
      print_generic_expr (vect_dump, pattern_expr, TDF_SLIM);
433
    }
434
  return pattern_expr;
435
}
436
 
437
 
438
/* Function vect_pattern_recog_1
439
 
440
   Input:
441
   PATTERN_RECOG_FUNC: A pointer to a function that detects a certain
442
        computation pattern.
443
   STMT: A stmt from which the pattern search should start.
444
 
445
   If PATTERN_RECOG_FUNC successfully detected the pattern, it creates an
446
   expression that computes the same functionality and can be used to
447
   replace the sequence of stmts that are involved in the pattern.
448
 
449
   Output:
450
   This function checks if the expression returned by PATTERN_RECOG_FUNC is
451
   supported in vector form by the target.  We use 'TYPE_IN' to obtain the
452
   relevant vector type. If 'TYPE_IN' is already a vector type, then this
453
   indicates that target support had already been checked by PATTERN_RECOG_FUNC.
454
   If 'TYPE_OUT' is also returned by PATTERN_RECOG_FUNC, we check that it fits
455
   to the available target pattern.
456
 
457
   This function also does some bookkeeping, as explained in the documentation
458
   for vect_recog_pattern.  */
459
 
460
static void
461
vect_pattern_recog_1 (
462
        tree (* vect_recog_func) (tree, tree *, tree *),
463
        block_stmt_iterator si)
464
{
465
  tree stmt = bsi_stmt (si);
466
  stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
467
  stmt_vec_info pattern_stmt_info;
468
  loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
469
  tree pattern_expr;
470
  tree pattern_vectype;
471
  tree type_in, type_out;
472
  tree pattern_type;
473
  enum tree_code code;
474
  tree var, var_name;
475
  stmt_ann_t ann;
476
 
477
  pattern_expr = (* vect_recog_func) (stmt, &type_in, &type_out);
478
  if (!pattern_expr)
479
    return;
480
 
481
  if (VECTOR_MODE_P (TYPE_MODE (type_in)))
482
    {
483
      /* No need to check target support (already checked by the pattern
484
         recognition function).  */
485
      pattern_vectype = type_in;
486
    }
487
  else
488
    {
489
      enum tree_code vec_mode;
490
      enum insn_code icode;
491
      optab optab;
492
 
493
      /* Check target support  */
494
      pattern_vectype = get_vectype_for_scalar_type (type_in);
495
      optab = optab_for_tree_code (TREE_CODE (pattern_expr), pattern_vectype);
496
      vec_mode = TYPE_MODE (pattern_vectype);
497
      if (!optab
498
          || (icode = optab->handlers[(int) vec_mode].insn_code) ==
499
              CODE_FOR_nothing
500
          || (type_out
501
              && (!get_vectype_for_scalar_type (type_out)
502
                  || (insn_data[icode].operand[0].mode !=
503
                      TYPE_MODE (get_vectype_for_scalar_type (type_out))))))
504
        return;
505
    }
506
 
507
  /* Found a vectorizable pattern.  */
508
  if (vect_print_dump_info (REPORT_DETAILS))
509
    {
510
      fprintf (vect_dump, "pattern recognized: ");
511
      print_generic_expr (vect_dump, pattern_expr, TDF_SLIM);
512
    }
513
 
514
  /* Mark the stmts that are involved in the pattern,
515
     create a new stmt to express the pattern and insert it.  */
516
  code = TREE_CODE (pattern_expr);
517
  pattern_type = TREE_TYPE (pattern_expr);
518
  var = create_tmp_var (pattern_type, "patt");
519
  add_referenced_var (var);
520
  var_name = make_ssa_name (var, NULL_TREE);
521
  pattern_expr = build2 (MODIFY_EXPR, void_type_node, var_name, pattern_expr);
522
  SSA_NAME_DEF_STMT (var_name) = pattern_expr;
523
  bsi_insert_before (&si, pattern_expr, BSI_SAME_STMT);
524
  ann = stmt_ann (pattern_expr);
525
  set_stmt_info (ann, new_stmt_vec_info (pattern_expr, loop_vinfo));
526
  pattern_stmt_info = vinfo_for_stmt (pattern_expr);
527
 
528
  STMT_VINFO_RELATED_STMT (pattern_stmt_info) = stmt;
529
  STMT_VINFO_DEF_TYPE (pattern_stmt_info) = STMT_VINFO_DEF_TYPE (stmt_info);
530
  STMT_VINFO_VECTYPE (pattern_stmt_info) = pattern_vectype;
531
  STMT_VINFO_IN_PATTERN_P (stmt_info) = true;
532
  STMT_VINFO_RELATED_STMT (stmt_info) = pattern_expr;
533
 
534
  return;
535
}
536
 
537
 
538
/* Function vect_pattern_recog
539
 
540
   Input:
541
   LOOP_VINFO - a struct_loop_info of a loop in which we want to look for
542
        computation idioms.
543
 
544
   Output - for each computation idiom that is detected we insert a new stmt
545
        that provides the same functionality and that can be vectorized. We
546
        also record some information in the struct_stmt_info of the relevant
547
        stmts, as explained below:
548
 
549
   At the entry to this function we have the following stmts, with the
550
   following initial value in the STMT_VINFO fields:
551
 
552
         stmt                     in_pattern_p  related_stmt    vec_stmt
553
         S1: a_i = ....                 -       -               -
554
         S2: a_2 = ..use(a_i)..         -       -               -
555
         S3: a_1 = ..use(a_2)..         -       -               -
556
         S4: a_0 = ..use(a_1)..         -       -               -
557
         S5: ... = ..use(a_0)..         -       -               -
558
 
559
   Say the sequence {S1,S2,S3,S4} was detected as a pattern that can be
560
   represented by a single stmt. We then:
561
   - create a new stmt S6 that will replace the pattern.
562
   - insert the new stmt S6 before the last stmt in the pattern
563
   - fill in the STMT_VINFO fields as follows:
564
 
565
                                  in_pattern_p  related_stmt    vec_stmt
566
         S1: a_i = ....                 -       -               -
567
         S2: a_2 = ..use(a_i)..         -       -               -
568
         S3: a_1 = ..use(a_2)..         -       -               -
569
       > S6: a_new = ....               -       S4              -
570
         S4: a_0 = ..use(a_1)..         true    S6              -
571
         S5: ... = ..use(a_0)..         -       -               -
572
 
573
   (the last stmt in the pattern (S4) and the new pattern stmt (S6) point
574
    to each other through the RELATED_STMT field).
575
 
576
   S6 will be marked as relevant in vect_mark_stmts_to_be_vectorized instead
577
   of S4 because it will replace all its uses.  Stmts {S1,S2,S3} will
578
   remain irrelevant unless used by stmts other than S4.
579
 
580
   If vectorization succeeds, vect_transform_stmt will skip over {S1,S2,S3}
581
   (because they are marked as irrelevant). It will vectorize S6, and record
582
   a pointer to the new vector stmt VS6 both from S6 (as usual), and also
583
   from S4. We do that so that when we get to vectorizing stmts that use the
584
   def of S4 (like S5 that uses a_0), we'll know where to take the relevant
585
   vector-def from. S4 will be skipped, and S5 will be vectorized as usual:
586
 
587
                                  in_pattern_p  related_stmt    vec_stmt
588
         S1: a_i = ....                 -       -               -
589
         S2: a_2 = ..use(a_i)..         -       -               -
590
         S3: a_1 = ..use(a_2)..         -       -               -
591
       > VS6: va_new = ....             -       -               -
592
         S6: a_new = ....               -       S4              VS6
593
         S4: a_0 = ..use(a_1)..         true    S6              VS6
594
       > VS5: ... = ..vuse(va_new)..    -       -               -
595
         S5: ... = ..use(a_0)..         -       -               -
596
 
597
   DCE could then get rid of {S1,S2,S3,S4,S5,S6} (if their defs are not used
598
   elsewhere), and we'll end up with:
599
 
600
        VS6: va_new = ....
601
        VS5: ... = ..vuse(va_new)..
602
 
603
   If vectorization does not succeed, DCE will clean S6 away (its def is
604
   not used), and we'll end up with the original sequence.
605
*/
606
 
607
void
608
vect_pattern_recog (loop_vec_info loop_vinfo)
609
{
610
  struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
611
  basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo);
612
  unsigned int nbbs = loop->num_nodes;
613
  block_stmt_iterator si;
614
  tree stmt;
615
  unsigned int i, j;
616
  tree (* vect_recog_func_ptr) (tree, tree *, tree *);
617
 
618
  if (vect_print_dump_info (REPORT_DETAILS))
619
    fprintf (vect_dump, "=== vect_pattern_recog ===");
620
 
621
  /* Scan through the loop stmts, applying the pattern recognition
622
     functions starting at each stmt visited:  */
623
  for (i = 0; i < nbbs; i++)
624
    {
625
      basic_block bb = bbs[i];
626
      for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
627
        {
628
          stmt = bsi_stmt (si);
629
 
630
          /* Scan over all generic vect_recog_xxx_pattern functions.  */
631
          for (j = 0; j < NUM_PATTERNS; j++)
632
            {
633
              vect_recog_func_ptr = vect_vect_recog_func_ptrs[j];
634
              vect_pattern_recog_1 (vect_recog_func_ptr, si);
635
            }
636
        }
637
    }
638
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.