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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [gcc.target/] [mips/] [mips-ps-1.c] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 321 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-O2 -mpaired-single" } */
3
 
4
/* Test v2sf calculations */
5
#include <stdlib.h>
6
#include <stdio.h>
7
 
8
typedef float v2sf __attribute__ ((vector_size (8)));
9
 
10
v2sf A = {100, 200};
11
 
12
/* Init from float */
13
v2sf init (float a, float b)
14
{
15
  return (v2sf) {a, b};
16
}
17
 
18
/* Move between registers */
19
v2sf move (v2sf a)
20
{
21
  return a;
22
}
23
 
24
/* Load from memory */
25
v2sf load ()
26
{
27
  return A;
28
}
29
 
30
/* Store to memory */
31
void store (v2sf a)
32
{
33
  A = a;
34
}
35
 
36
/* Add */
37
v2sf add (v2sf a, v2sf b)
38
{
39
  return a + b;
40
}
41
 
42
/* Subtract */
43
v2sf sub (v2sf a, v2sf b)
44
{
45
  return a - b;
46
}
47
 
48
/* Negate */
49
v2sf neg (v2sf a)
50
{
51
  return - a;
52
}
53
 
54
/* Multiply */
55
v2sf mul (v2sf a, v2sf b)
56
{
57
  return a * b;
58
}
59
 
60
/* Multiply and add */
61
v2sf madd (v2sf a, v2sf b, v2sf c)
62
{
63
  return a * b + c;
64
}
65
 
66
/* Multiply and subtract */
67
v2sf msub (v2sf a, v2sf b, v2sf c)
68
{
69
  return a * b - c;
70
}
71
 
72
/* Negate Multiply and add */
73
v2sf nmadd (v2sf a, v2sf b, v2sf c)
74
{
75
  return - (a * b + c);
76
}
77
 
78
/* Negate Multiply and subtract */
79
v2sf nmsub (v2sf a, v2sf b, v2sf c)
80
{
81
  return - (a * b - c);
82
}
83
 
84
/* Conditional Move */
85
v2sf cond_move1 (v2sf a, v2sf b, long i)
86
{
87
  if (i > 0)
88
    return a;
89
  else
90
    return b;
91
}
92
 
93
/* Conditional Move */
94
v2sf cond_move2 (v2sf a, v2sf b, int i)
95
{
96
  if (i > 0)
97
    return a;
98
  else
99
    return b;
100
}
101
 
102
/* Conditional Move */
103
v2sf cond_move3 (v2sf a, v2sf b, float i)
104
{
105
  if (i > 0.0)
106
    return a;
107
  else
108
    return b;
109
}
110
 
111
/* Conditional Move */
112
v2sf cond_move4 (v2sf a, v2sf b, double i)
113
{
114
  if (i > 0.0)
115
    return a;
116
  else
117
    return b;
118
}
119
 
120
NOMIPS16 int main()
121
{
122
  v2sf a, b, c, d, e, f;
123
  float f1, f2;
124
 
125
  f1 = 1.2;
126
  f2 = 3.4;
127
  a = init (f1, f2);
128
  b = (v2sf) {1.2, 3.4};
129
  if (!__builtin_mips_upper_c_eq_ps (a, b) ||
130
      !__builtin_mips_lower_c_eq_ps (a, b))
131
    abort ();
132
 
133
  a = (v2sf) {1.2, 2.3};
134
  b = (v2sf) {5.3, 6.1};
135
  b = move (a);
136
 
137
  if (!__builtin_mips_upper_c_eq_ps (a, b) ||
138
      !__builtin_mips_lower_c_eq_ps (a, b))
139
    abort ();
140
 
141
  a = (v2sf) {1.2, 2.3};
142
  b = (v2sf) {5.3, 6.1};
143
  c = add (a, b);
144
  d = (v2sf) {6.5, 8.4};
145
  if (!__builtin_mips_upper_c_eq_ps (c, d) ||
146
      !__builtin_mips_lower_c_eq_ps (c, d))
147
    abort ();
148
 
149
  a = (v2sf) {1, 12};
150
  b = (v2sf) {5, 6};
151
  c = sub (a, b);
152
  d = (v2sf) {-4, 6};
153
  if (!__builtin_mips_upper_c_eq_ps (c, d) ||
154
      !__builtin_mips_lower_c_eq_ps (c, d))
155
    abort ();
156
 
157
  a = (v2sf) {1, 12};
158
  b = (v2sf) {5, 6};
159
  c = mul (a, b);
160
  d = (v2sf) {5, 72};
161
  if (!__builtin_mips_upper_c_eq_ps (c, d) ||
162
      !__builtin_mips_lower_c_eq_ps (c, d))
163
    abort ();
164
 
165
  a = (v2sf) {1, 12};
166
  b = (v2sf) {5, 6};
167
  c = (v2sf) {5, 6};
168
  d = madd (a, b, c);
169
  e = (v2sf) {10, 78};
170
  if (!__builtin_mips_upper_c_eq_ps (d, e) ||
171
      !__builtin_mips_lower_c_eq_ps (d, e))
172
    abort ();
173
 
174
  a = (v2sf) {1, 12};
175
  b = (v2sf) {5, 6};
176
  c = (v2sf) {5, 6};
177
  d = msub (a, b, c);
178
  e = (v2sf) {0, 66};
179
  if (!__builtin_mips_upper_c_eq_ps (d, e) ||
180
      !__builtin_mips_lower_c_eq_ps (d, e))
181
    abort ();
182
 
183
  a = (v2sf) {1, 12};
184
  b = (v2sf) {5, 6};
185
  c = (v2sf) {5, 6};
186
  d = nmadd (a, b, c);
187
  e = (v2sf) {-10, -78};
188
  if (!__builtin_mips_upper_c_eq_ps (d, e) ||
189
      !__builtin_mips_lower_c_eq_ps (d, e))
190
    abort ();
191
 
192
  a = (v2sf) {1, 12};
193
  b = (v2sf) {5, 6};
194
  c = (v2sf) {5, 6};
195
  d = nmsub (a, b, c);
196
  e = (v2sf) {0, -66};
197
  if (!__builtin_mips_upper_c_eq_ps (d, e) ||
198
      !__builtin_mips_lower_c_eq_ps (d, e))
199
    abort ();
200
 
201
  a = (v2sf) {98, 12};
202
  b = neg (a);
203
  c = (v2sf) {-98, -12};
204
  if (!__builtin_mips_upper_c_eq_ps (b, c) ||
205
      !__builtin_mips_lower_c_eq_ps (b, c))
206
    abort ();
207
 
208
  a = (v2sf) {1, 12};
209
  b = (v2sf) {5, 6};
210
  c = cond_move1 (a, b, 1000);
211
  if (!__builtin_mips_upper_c_eq_ps (c, a) ||
212
      !__builtin_mips_lower_c_eq_ps (c, a))
213
    abort ();
214
 
215
  a = (v2sf) {1, 12};
216
  b = (v2sf) {5, 6};
217
  c = cond_move2 (a, b, -1000);
218
  if (!__builtin_mips_upper_c_eq_ps (c, b) ||
219
      !__builtin_mips_lower_c_eq_ps (c, b))
220
    abort ();
221
 
222
  a = (v2sf) {1, 12};
223
  b = (v2sf) {5, 6};
224
  c = cond_move3 (a, b, 9.0);
225
  if (!__builtin_mips_upper_c_eq_ps (c, a) ||
226
      !__builtin_mips_lower_c_eq_ps (c, a))
227
    abort ();
228
 
229
  a = (v2sf) {1, 12};
230
  b = (v2sf) {5, 6};
231
  c = cond_move4 (a, b, -10.0);
232
  if (!__builtin_mips_upper_c_eq_ps (c, b) ||
233
      !__builtin_mips_lower_c_eq_ps (c, b))
234
    abort ();
235
 
236
  a = (v2sf) {5, 12};
237
  b = (v2sf) {5, 6};
238
  c = (v2sf) {33, 123};
239
  d = (v2sf) {8, 78};
240
  e = __builtin_mips_movt_c_eq_ps (a, b, c, d);
241
  f = (v2sf) {8, 123};
242
  if (!__builtin_mips_upper_c_eq_ps (e, f) ||
243
      !__builtin_mips_lower_c_eq_ps (e, f))
244
    abort ();
245
 
246
  a = (v2sf) {5, 12};
247
  b = (v2sf) {5, 6};
248
  c = (v2sf) {33, 123};
249
  d = (v2sf) {8, 78};
250
  e = __builtin_mips_movf_c_eq_ps (a, b, c, d);
251
  f = (v2sf) {33, 78};
252
  if (!__builtin_mips_upper_c_eq_ps (e, f) ||
253
      !__builtin_mips_lower_c_eq_ps (e, f))
254
    abort ();
255
 
256
  a = load();
257
  b = (v2sf) {100, 200};
258
  if (!__builtin_mips_upper_c_eq_ps (a, b) ||
259
      !__builtin_mips_lower_c_eq_ps (a, b))
260
    abort ();
261
 
262
  a = (v2sf) {123, 321};
263
  store (a);
264
  b = load();
265
  if (!__builtin_mips_upper_c_eq_ps (a, b) ||
266
      !__builtin_mips_lower_c_eq_ps (a, b))
267
    abort ();
268
 
269
  printf ("Test Passes\n");
270
  exit (0);
271
}

powered by: WebSVN 2.1.0

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