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.5.1/] [gcc/] [testsuite/] [gcc.dg/] [vect/] [vect-all.c] - Blame information for rev 307

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

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-require-effective-target vect_int } */
2
/* { dg-require-effective-target vect_float } */
3
 
4
#include <stdarg.h>
5
#include "tree-vect.h"
6
 
7
#define N 16
8
 
9
int iadd_results[N] = {0,6,12,18,24,30,36,42,48,54,60,66,72,78,84,90};
10
float fadd_results[N] = {0.0,6.0,12.0,18.0,24.0,30.0,36.0,42.0,48.0,54.0,60.0,66.0,72.0,78.0,84.0,90.0};
11
float fmul_results[N] = {0.0,3.0,12.0,27.0,48.0,75.0,108.0,147.0,192.0,243.0,300.0,363.0,432.0,507.0,588.0,675.0};
12
float fresults1[N] = {192.00,240.00,288.00,336.00,384.00,432.00,480.00,528.00,48.00,54.00,60.00,66.00,72.00,78.00,84.00,90.00};
13
float fresults2[N] = {0.00,6.00,12.00,18.00,24.00,30.00,36.00,42.00,0.00,54.00,120.00,198.00,288.00,390.00,504.00,630.00};
14
 
15
/****************************************************/
16
__attribute__ ((noinline))
17
void icheck_results (int *a, int *results)
18
{
19
  int i;
20
  for (i = 0; i < N; i++)
21
    {
22
      if (a[i] != results[i])
23
        abort ();
24
    }
25
}
26
 
27
__attribute__ ((noinline))
28
void fcheck_results (float *a, float *results)
29
{
30
  int i;
31
  for (i = 0; i < N; i++)
32
    {
33
      if (a[i] != results[i])
34
        abort ();
35
    }
36
}
37
 
38
__attribute__ ((noinline)) void
39
fbar_mul (float *a)
40
{
41
  fcheck_results (a, fmul_results);
42
}
43
 
44
__attribute__ ((noinline)) void
45
fbar_add (float *a)
46
{
47
  fcheck_results (a, fadd_results);
48
}
49
 
50
__attribute__ ((noinline)) void
51
ibar_add (int *a)
52
{
53
  icheck_results (a, iadd_results);
54
}
55
 
56
__attribute__ ((noinline)) void
57
fbar1 (float *a)
58
{
59
  fcheck_results (a, fresults1);
60
}
61
 
62
__attribute__ ((noinline)) void
63
fbar2 (float *a)
64
{
65
  fcheck_results (a, fresults2);
66
}
67
 
68
float a[N];
69
float e[N];
70
float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
71
float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
72
float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30};
73
int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
74
int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
75
int ia[N];
76
char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45};
77
char ca[N];
78
short sa[N];
79
 
80
/* All of the loops below are currently vectorizable.  */
81
 
82
__attribute__ ((noinline)) int
83
main1 ()
84
{
85
  int i,j;
86
 
87
  /* Test 1: copy chars.  */
88
  for (i = 0; i < N; i++)
89
    {
90
      ca[i] = cb[i];
91
    }
92
  /* check results:  */
93
  for (i = 0; i < N; i++)
94
    {
95
      if (ca[i] != cb[i])
96
        abort ();
97
    }
98
 
99
 
100
  /* Test 2: fp mult.  */
101
  for (i = 0; i < N; i++)
102
    {
103
      a[i] = b[i] * c[i];
104
    }
105
  fbar_mul (a);
106
 
107
 
108
  /* Test 3: mixed types (int, fp), same nunits in vector.  */
109
  for (i = 0; i < N; i++)
110
    {
111
      a[i] = b[i] + c[i] + d[i];
112
      e[i] = b[i] + c[i] + d[i];
113
      ia[i] = ib[i] + ic[i];
114
    }
115
  ibar_add (ia);
116
  fbar_add (a);
117
  fbar_add (e);
118
 
119
 
120
  /* Test 4: access with offset.  */
121
  for (i = 0; i < N/2; i++)
122
    {
123
      a[i] = b[i+N/2] * c[i+N/2] - b[i] * c[i];
124
      e[i+N/2] = b[i] * c[i+N/2] + b[i+N/2] * c[i];
125
    }
126
  fbar1 (a);
127
  fbar2 (e);
128
 
129
 
130
  /* Test 5: access with offset */
131
  for (i = 1; i <=N-4; i++)
132
    {
133
      a[i+3] = b[i-1];
134
    }
135
  /* check results:  */
136
  for (i = 1; i <=N-4; i++)
137
    {
138
      if (a[i+3] != b[i-1])
139
        abort ();
140
    }
141
 
142
 
143
  /* Test 6 - loop induction with stride != 1.  */
144
  i = 0;
145
  j = 0;
146
  while (i < 5*N)
147
    {
148
      a[j] = c[j];
149
      i += 5;
150
      j++;
151
    }
152
  /* check results:  */
153
  for (i = 0; i <N; i++)
154
    {
155
      if (a[i] != c[i])
156
        abort ();
157
    }
158
 
159
 
160
  /* Test 7 - reverse access.  */
161
  for (i = N; i > 0; i--)
162
    {
163
      a[N-i] = d[N-i];
164
    }
165
  /* check results:  */
166
  for (i = 0; i <N; i++)
167
    {
168
      if (a[i] != d[i])
169
        abort ();
170
    }
171
 
172
 
173
  /* Tests 8,9,10 - constants.  */
174
  for (i = 0; i < N; i++)
175
    {
176
      a[i] = 5.0;
177
    }
178
  /* check results:  */
179
  for (i = 0; i < N; i++)
180
    {
181
      if (a[i] != 5.0)
182
        abort ();
183
    }
184
 
185
  for (i = 0; i < N; i++)
186
    {
187
      sa[i] = 5;
188
    }
189
  /* check results:  */
190
  for (i = 0; i < N; i++)
191
    {
192
      if (sa[i] != 5)
193
        abort ();
194
    }
195
 
196
  for (i = 0; i < N; i++)
197
    {
198
      ia[i] = ib[i] + 5;
199
    }
200
  /* check results:  */
201
  for (i = 0; i < N; i++)
202
    {
203
      if (ia[i] != ib[i] + 5)
204
        abort ();
205
    }
206
 
207
  return 0;
208
}
209
 
210
int main (void)
211
{
212
  check_vect ();
213
 
214
  return main1 ();
215
}
216
 
217
/* { dg-final { scan-tree-dump-times "vectorized 10 loops" 1 "vect" } } */
218
/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
219
/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */
220
/* { 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.