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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [vec-cvt-1.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run } */
2
 
3
#include <stdlib.h>
4
 
5
#define N 1024
6
signed char sc[N];
7
short ss[N];
8
int si[N];
9
long long sl[N];
10
unsigned char uc[N];
11
unsigned short us[N];
12
unsigned int ui[N];
13
unsigned long long ul[N];
14
float f[N];
15
double d[N];
16
 
17
#define FN1(from, to) \
18
__attribute__((noinline, noclone)) void         \
19
from##2##to (void)                              \
20
{                                               \
21
  int i;                                        \
22
  for (i = 0; i < N; i++)                        \
23
    to[i] = from[i];                            \
24
}
25
#define FN(intt, fltt) FN1 (intt, fltt) FN1 (fltt, intt)
26
 
27
FN (sc, f)
28
FN (ss, f)
29
FN (si, f)
30
FN (sl, f)
31
FN (uc, f)
32
FN (us, f)
33
FN (ui, f)
34
FN (ul, f)
35
FN (sc, d)
36
FN (ss, d)
37
FN (si, d)
38
FN (sl, d)
39
FN (uc, d)
40
FN (us, d)
41
FN (ui, d)
42
FN (ul, d)
43
 
44
#define FLTTEST(min, max, intt) \
45
__attribute__((noinline, noclone)) void                                 \
46
flttointtest##intt (void)                                               \
47
{                                                                       \
48
  int i;                                                                \
49
  volatile float fltmin, fltmax, vf, vf2;                               \
50
  volatile double dblmin, dblmax, vd, vd2;                              \
51
  if (min == 0)                                                          \
52
    fltmin = 0.0f;                                                      \
53
  else                                                                  \
54
    {                                                                   \
55
      vf2 = fltmin = min - 1.0f;                                        \
56
      for (vf = 1.0f; (fltmin = vf2 + vf) == vf2; vf = vf * 2.0f)       \
57
        ;                                                               \
58
    }                                                                   \
59
  vf2 = fltmax = max + 1.0f;                                            \
60
  for (vf = 1.0f; (fltmax = vf2 - vf) == vf2; vf = vf * 2.0f)           \
61
    ;                                                                   \
62
  if (min == 0)                                                          \
63
    dblmin = 0.0;                                                       \
64
  else                                                                  \
65
    {                                                                   \
66
      vd2 = dblmin = min - 1.0;                                         \
67
      for (vd = 1.0; (dblmin = vd2 + vd) == vd2; vd = vd * 2.0)         \
68
        ;                                                               \
69
    }                                                                   \
70
  vd2 = dblmax = max + 1.0;                                             \
71
  for (vd = 1.0; (dblmax = vd2 - vd) == vd2; vd = vd * 2.0)             \
72
    ;                                                                   \
73
  for (i = 0; i < N; i++)                                                \
74
    {                                                                   \
75
      asm ("");                                                         \
76
      if (i == 0)                                                        \
77
        f[i] = fltmin;                                                  \
78
      else if (i < N / 4)                                               \
79
        f[i] = fltmin + i + 0.25f;                                      \
80
      else if (i < 3 * N / 4)                                           \
81
        f[i] = (fltmax + fltmin) / 2.0 - N * 8 + 16.0f * i;             \
82
      else                                                              \
83
        f[i] = fltmax - N + 1 + i;                                      \
84
      if (f[i] < fltmin) f[i] = fltmin;                                 \
85
      if (f[i] > fltmax) f[i] = fltmax;                                 \
86
      if (i == 0)                                                        \
87
        d[i] = dblmin;                                                  \
88
      else if (i < N / 4)                                               \
89
        d[i] = dblmin + i + 0.25f;                                      \
90
      else if (i < 3 * N / 4)                                           \
91
        d[i] = (dblmax + dblmin) / 2.0 - N * 8 + 16.0f * i;             \
92
      else                                                              \
93
        d[i] = dblmax - N + 1 + i;                                      \
94
      if (d[i] < dblmin) d[i] = dblmin;                                 \
95
      if (d[i] > dblmax) d[i] = dblmax;                                 \
96
    }                                                                   \
97
  f2##intt ();                                                          \
98
  for (i = 0; i < N; i++)                                                \
99
    if (intt[i] != (__typeof (intt[0])) f[i])                            \
100
      abort ();                                                         \
101
  d2##intt ();                                                          \
102
  for (i = 0; i < N; i++)                                                \
103
    if (intt[i] != (__typeof (intt[0])) d[i])                            \
104
      abort ();                                                         \
105
  for (i = 0; i < N; i++)                                                \
106
    {                                                                   \
107
      unsigned long long r = rand ();                                   \
108
      r = (r << 21) ^ (unsigned) rand ();                               \
109
      r = (r << 21) ^ (unsigned) rand ();                               \
110
      asm ("");                                                         \
111
      f[i] = (r >> 59) / 32.0f + (__typeof (intt[0])) r;         \
112
      if (f[i] < fltmin) f[i] = fltmin;                                 \
113
      if (f[i] > fltmax) f[i] = fltmax;                                 \
114
      d[i] = (r >> 59) / 32.0 + (__typeof (intt[0])) r;                  \
115
      if (d[i] < dblmin) f[i] = dblmin;                                 \
116
      if (d[i] > dblmax) f[i] = dblmax;                                 \
117
    }                                                                   \
118
  f2##intt ();                                                          \
119
  for (i = 0; i < N; i++)                                                \
120
    if (intt[i] != (__typeof (intt[0])) f[i])                            \
121
      abort ();                                                         \
122
  d2##intt ();                                                          \
123
  for (i = 0; i < N; i++)                                                \
124
    if (intt[i] != (__typeof (intt[0])) d[i])                            \
125
      abort ();                                                         \
126
}                                                                       \
127
                                                                        \
128
__attribute__((noinline, noclone)) void                                 \
129
inttoflttest##intt (void)                                               \
130
{                                                                       \
131
  int i;                                                                \
132
  volatile float vf;                                                    \
133
  volatile double vd;                                                   \
134
  for (i = 0; i < N; i++)                                                \
135
    {                                                                   \
136
      asm ("");                                                         \
137
      if (i < N / 4)                                                    \
138
        intt[i] = min + i;                                              \
139
      else if (i < 3 * N / 4)                                           \
140
        intt[i] = (max + min) / 2 - N * 8 + 16 * i;                     \
141
      else                                                              \
142
        intt[i] = max - N + 1 + i;                                      \
143
    }                                                                   \
144
  intt##2f ();                                                          \
145
  for (i = 0; i < N; i++)                                                \
146
    {                                                                   \
147
      vf = intt[i];                                                     \
148
      if (f[i] != vf)                                                   \
149
        abort ();                                                       \
150
    }                                                                   \
151
  intt##2d ();                                                          \
152
  for (i = 0; i < N; i++)                                                \
153
    {                                                                   \
154
      vd = intt[i];                                                     \
155
      if (d[i] != vd)                                                   \
156
        abort ();                                                       \
157
    }                                                                   \
158
  for (i = 0; i < N; i++)                                                \
159
    {                                                                   \
160
      unsigned long long r = rand ();                                   \
161
      r = (r << 21) ^ (unsigned) rand ();                               \
162
      r = (r << 21) ^ (unsigned) rand ();                               \
163
      asm ("");                                                         \
164
      intt[i] = r;                                                      \
165
    }                                                                   \
166
  intt##2f ();                                                          \
167
  for (i = 0; i < N; i++)                                                \
168
    {                                                                   \
169
      vf = intt[i];                                                     \
170
      if (f[i] != vf)                                                   \
171
        abort ();                                                       \
172
    }                                                                   \
173
  intt##2d ();                                                          \
174
  for (i = 0; i < N; i++)                                                \
175
    {                                                                   \
176
      vd = intt[i];                                                     \
177
      if (d[i] != vd)                                                   \
178
        abort ();                                                       \
179
    }                                                                   \
180
}
181
 
182
FLTTEST (- __SCHAR_MAX__ - 1, __SCHAR_MAX__, sc)
183
FLTTEST (- __SHRT_MAX__ - 1, __SHRT_MAX__, ss)
184
FLTTEST (- __INT_MAX__ - 1, __INT_MAX__, si)
185
FLTTEST (- __LONG_LONG_MAX__ - 1LL, __LONG_LONG_MAX__, sl)
186
FLTTEST (0, 2U * __SCHAR_MAX__ + 1, uc)
187
FLTTEST (0, 2U * __SHRT_MAX__ + 1, us)
188
FLTTEST (0, 2U * __INT_MAX__ + 1, ui)
189
FLTTEST (0, 2ULL * __LONG_LONG_MAX__ + 1, ul)
190
 
191
int
192
main ()
193
{
194
  flttointtestsc ();
195
  flttointtestss ();
196
  flttointtestsi ();
197
  flttointtestsl ();
198
  flttointtestuc ();
199
  flttointtestus ();
200
  flttointtestui ();
201
  flttointtestul ();
202
  inttoflttestsc ();
203
  inttoflttestss ();
204
  inttoflttestsi ();
205
  inttoflttestsl ();
206
  inttoflttestuc ();
207
  inttoflttestus ();
208
  inttoflttestui ();
209
  inttoflttestul ();
210
  return 0;
211
}

powered by: WebSVN 2.1.0

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