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

Subversion Repositories openrisc

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

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
   The reduction is currently not vectorized becaus of the signed->unsigned->signed
39
   casts, since this patch:
40
 
41
     2005-12-26  Kazu Hirata  <kazu@codesourcery.com>
42
 
43
        PR tree-optimization/25125
44
 
45
   When the dot-product is detected, the loop should be vectorized on vect_sdot_qi
46
   targets (targets that support dot-product of signed char).
47
   This test would currently fail to vectorize on targets that support
48
   dot-product of chars when the accumulator is int.
49
 
50
   In the future could also be vectorized as widening-mult + summation,
51
   or with type-conversion support.
52
 */
53
short
54
foo2(int len) {
55
  int i;
56
  short result = 0;
57
 
58
  for (i=0; i<len; i++) {
59
    result += (X[i] * Y[i]);
60
  }
61
  return result;
62
}
63
 
64
/* char->int->int dot product.
65
   Not detected as a dot-product pattern.
66
   Currently fails to be vectorized due to presence of type conversions. */
67
int
68
foo3(int len) {
69
  int i;
70
  int result = 0;
71
 
72
  for (i=0; i<len; i++) {
73
    result += (X[i] * Y[i]);
74
  }
75
  return result;
76
}
77
 
78
int main (void)
79
{
80
  int i, dot1, dot3;
81
  short dot2;
82
 
83
  check_vect ();
84
 
85
  for (i=0; i<N; i++) {
86
    X[i] = i;
87
    Y[i] = 64-i;
88
  }
89
 
90
  dot1 = foo1 (N);
91
  if (dot1 != DOT1)
92
    abort ();
93
 
94
  dot2 = foo2 (N);
95
  if (dot2 != DOT2)
96
    abort ();
97
 
98
  dot3 = foo3 (N);
99
  if (dot3 != DOT3)
100
    abort ();
101
 
102
  return 0;
103
}
104
 
105
/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 2 "vect" { xfail *-*-* } } } */
106
/* { dg-final { scan-tree-dump-times "vect_recog_dot_prod_pattern: detected" 1 "vect" } } */
107
 
108
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail *-*-* } } } */
109
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_sdot_qi } } } */
110
 
111
/* { 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.