OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [vect/] [wrapv-vect-reduc-dot-s8.c] - Blame information for rev 405

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

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-require-effective-target vect_int } */
2
 
3
#include <stdarg.h>
4
#include "tree-vect.h"
5
 
6
#define N 64
7
 
8
#define DOT1 43680
9
#define DOT2 -21856
10
#define DOT3 43680
11
 
12
signed char X[N] __attribute__ ((__aligned__(16)));
13
signed char Y[N] __attribute__ ((__aligned__(16)));
14
 
15
/* char->short->int dot product.
16
   The dot-product pattern should be detected.
17
   Vectorizable on vect_sdot_qi targets (targets that support dot-product of
18
   signed chars).
19
 
20
   In the future could also be vectorized as widening-mult + widening-summation,
21
   or with type-conversion support.
22
 */
23
int
24
foo1(int len) {
25
  int i;
26
  int result = 0;
27
  short prod;
28
 
29
  for (i=0; i<len; i++) {
30
    prod = X[i] * Y[i];
31
    result += prod;
32
  }
33
  return result;
34
}
35
 
36
/* char->short->short dot product.
37
   The dot-product pattern should be detected.
38
   Should be vectorized on vect_sdot_qi targets (targets that support
39
   dot-product of signed char).
40
   This test currently fails to vectorize on targets that support
41
   dot-product of chars when the accumulator is int.
42
 
43
   In the future could also be vectorized as widening-mult + summation,
44
   or with type-conversion support.
45
 */
46
short
47
foo2(int len) {
48
  int i;
49
  short result = 0;
50
 
51
  for (i=0; i<len; i++) {
52
    result += (X[i] * Y[i]);
53
  }
54
  return result;
55
}
56
 
57
/* char->int->int dot product.
58
   Not detected as a dot-product pattern.
59
   Currently fails to be vectorized due to presence of type conversions. */
60
int
61
foo3(int len) {
62
  int i;
63
  int result = 0;
64
 
65
  for (i=0; i<len; i++) {
66
    result += (X[i] * Y[i]);
67
  }
68
  return result;
69
}
70
 
71
int main (void)
72
{
73
  int i, dot1, dot3;
74
  short dot2;
75
 
76
  check_vect ();
77
 
78
  for (i=0; i<N; i++) {
79
    X[i] = i;
80
    Y[i] = 64-i;
81
  }
82
 
83
  dot1 = foo1 (N);
84
  if (dot1 != DOT1)
85
    abort ();
86
 
87
  dot2 = foo2 (N);
88
  if (dot2 != DOT2)
89
    abort ();
90
 
91
  dot3 = foo3 (N);
92
  if (dot3 != DOT3)
93
    abort ();
94
 
95
  return 0;
96
}
97
 
98
/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 2 "vect" } } */
99
 
100
/* When vectorizer is enhanced to vectorize foo2 (accumulation into short) for targets
101
   that support accumulation into int (ia64) we'd have:
102
dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_sdot_qi } }
103
*/
104
/* In the meantime expect: */
105
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail *-*-* } } } */
106
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_qi } } } */
107
 
108
/* { dg-final { cleanup-tree-dump "vect" } } */

powered by: WebSVN 2.1.0

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