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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [20040409-2.c] - Blame information for rev 297

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 297 jeremybenn
#include <limits.h>
2
 
3
extern void abort ();
4
 
5
int test1(int x)
6
{
7
  return (x ^ INT_MIN) ^ 0x1234;
8
}
9
 
10
unsigned int test1u(unsigned int x)
11
{
12
  return (x ^ (unsigned int)INT_MIN) ^ 0x1234;
13
}
14
 
15
int test2(int x)
16
{
17
  return (x ^ 0x1234) ^ INT_MIN;
18
}
19
 
20
unsigned int test2u(unsigned int x)
21
{
22
  return (x ^ 0x1234) ^ (unsigned int)INT_MIN;
23
}
24
 
25
int test3(int x)
26
{
27
  return (x + INT_MIN) ^ 0x1234;
28
}
29
 
30
unsigned int test3u(unsigned int x)
31
{
32
  return (x + (unsigned int)INT_MIN) ^ 0x1234;
33
}
34
 
35
int test4(int x)
36
{
37
  return (x ^ 0x1234) + INT_MIN;
38
}
39
 
40
unsigned int test4u(unsigned int x)
41
{
42
  return (x ^ 0x1234) + (unsigned int)INT_MIN;
43
}
44
 
45
int test5(int x)
46
{
47
  return (x - INT_MIN) ^ 0x1234;
48
}
49
 
50
unsigned int test5u(unsigned int x)
51
{
52
  return (x - (unsigned int)INT_MIN) ^ 0x1234;
53
}
54
 
55
int test6(int x)
56
{
57
  return (x ^ 0x1234) - INT_MIN;
58
}
59
 
60
unsigned int test6u(unsigned int x)
61
{
62
  return (x ^ 0x1234) - (unsigned int)INT_MIN;
63
}
64
 
65
int test7(int x)
66
{
67
  int y = INT_MIN;
68
  int z = 0x1234;
69
  return (x ^ y) ^ z;
70
}
71
 
72
unsigned int test7u(unsigned int x)
73
{
74
  unsigned int y = (unsigned int)INT_MIN;
75
  unsigned int z = 0x1234;
76
  return (x ^ y) ^ z;
77
}
78
 
79
int test8(int x)
80
{
81
  int y = 0x1234;
82
  int z = INT_MIN;
83
  return (x ^ y) ^ z;
84
}
85
 
86
unsigned int test8u(unsigned int x)
87
{
88
  unsigned int y = 0x1234;
89
  unsigned int z = (unsigned int)INT_MIN;
90
  return (x ^ y) ^ z;
91
}
92
 
93
int test9(int x)
94
{
95
  int y = INT_MIN;
96
  int z = 0x1234;
97
  return (x + y) ^ z;
98
}
99
 
100
unsigned int test9u(unsigned int x)
101
{
102
  unsigned int y = (unsigned int)INT_MIN;
103
  unsigned int z = 0x1234;
104
  return (x + y) ^ z;
105
}
106
 
107
int test10(int x)
108
{
109
  int y = 0x1234;
110
  int z = INT_MIN;
111
  return (x ^ y) + z;
112
}
113
 
114
unsigned int test10u(unsigned int x)
115
{
116
  unsigned int y = 0x1234;
117
  unsigned int z = (unsigned int)INT_MIN;
118
  return (x ^ y) + z;
119
}
120
 
121
int test11(int x)
122
{
123
  int y = INT_MIN;
124
  int z = 0x1234;
125
  return (x - y) ^ z;
126
}
127
 
128
unsigned int test11u(unsigned int x)
129
{
130
  unsigned int y = (unsigned int)INT_MIN;
131
  unsigned int z = 0x1234;
132
  return (x - y) ^ z;
133
}
134
 
135
int test12(int x)
136
{
137
  int y = 0x1234;
138
  int z = INT_MIN;
139
  return (x ^ y) - z;
140
}
141
 
142
unsigned int test12u(unsigned int x)
143
{
144
  unsigned int y = 0x1234;
145
  unsigned int z = (unsigned int)INT_MIN;
146
  return (x ^ y) - z;
147
}
148
 
149
 
150
void test(int a, int b)
151
{
152
  if (test1(a) != b)
153
    abort();
154
  if (test2(a) != b)
155
    abort();
156
  if (test3(a) != b)
157
    abort();
158
  if (test4(a) != b)
159
    abort();
160
  if (test5(a) != b)
161
    abort();
162
  if (test6(a) != b)
163
    abort();
164
  if (test7(a) != b)
165
    abort();
166
  if (test8(a) != b)
167
    abort();
168
  if (test9(a) != b)
169
    abort();
170
  if (test10(a) != b)
171
    abort();
172
  if (test11(a) != b)
173
    abort();
174
  if (test12(a) != b)
175
    abort();
176
}
177
 
178
void testu(unsigned int a, unsigned int b)
179
{
180
  if (test1u(a) != b)
181
    abort();
182
  if (test2u(a) != b)
183
    abort();
184
  if (test3u(a) != b)
185
    abort();
186
  if (test4u(a) != b)
187
    abort();
188
  if (test5u(a) != b)
189
    abort();
190
  if (test6u(a) != b)
191
    abort();
192
  if (test7u(a) != b)
193
    abort();
194
  if (test8u(a) != b)
195
    abort();
196
  if (test9u(a) != b)
197
    abort();
198
  if (test10u(a) != b)
199
    abort();
200
  if (test11u(a) != b)
201
    abort();
202
  if (test12u(a) != b)
203
    abort();
204
}
205
 
206
 
207
int main()
208
{
209
#if INT_MAX == 2147483647
210
  test(0x00000000,0x80001234);
211
  test(0x00001234,0x80000000);
212
  test(0x80000000,0x00001234);
213
  test(0x80001234,0x00000000);
214
  test(0x7fffffff,0xffffedcb);
215
  test(0xffffffff,0x7fffedcb);
216
 
217
  testu(0x00000000,0x80001234);
218
  testu(0x00001234,0x80000000);
219
  testu(0x80000000,0x00001234);
220
  testu(0x80001234,0x00000000);
221
  testu(0x7fffffff,0xffffedcb);
222
  testu(0xffffffff,0x7fffedcb);
223
#endif
224
 
225
#if INT_MAX == 32767
226
  test(0x0000,0x9234);
227
  test(0x1234,0x8000);
228
  test(0x8000,0x1234);
229
  test(0x9234,0x0000);
230
  test(0x7fff,0xedcb);
231
  test(0xffff,0x6dcb);
232
 
233
  testu(0x0000,0x9234);
234
  testu(0x8000,0x1234);
235
  testu(0x1234,0x8000);
236
  testu(0x9234,0x0000);
237
  testu(0x7fff,0xedcb);
238
  testu(0xffff,0x6dcb);
239
#endif
240
 
241
  return 0;
242
}
243
 

powered by: WebSVN 2.1.0

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