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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [20040409-1.c] - Blame information for rev 774

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

Line No. Rev Author Line
1 688 jeremybenn
#include <limits.h>
2
 
3
extern void abort ();
4
 
5
int test1(int x)
6
{
7
  return x ^ INT_MIN;
8
}
9
 
10
unsigned int test1u(unsigned int x)
11
{
12
  return x ^ (unsigned int)INT_MIN;
13
}
14
 
15
int test2(int x)
16
{
17
  return x + INT_MIN;
18
}
19
 
20
unsigned int test2u(unsigned int x)
21
{
22
  return x + (unsigned int)INT_MIN;
23
}
24
 
25
int test3(int x)
26
{
27
  return x - INT_MIN;
28
}
29
 
30
unsigned int test3u(unsigned int x)
31
{
32
  return x - (unsigned int)INT_MIN;
33
}
34
 
35
int test4(int x)
36
{
37
  int y = INT_MIN;
38
  return x ^ y;
39
}
40
 
41
unsigned int test4u(unsigned int x)
42
{
43
  unsigned int y = (unsigned int)INT_MIN;
44
  return x ^ y;
45
}
46
 
47
int test5(int x)
48
{
49
  int y = INT_MIN;
50
  return x + y;
51
}
52
 
53
unsigned int test5u(unsigned int x)
54
{
55
  unsigned int y = (unsigned int)INT_MIN;
56
  return x + y;
57
}
58
 
59
int test6(int x)
60
{
61
  int y = INT_MIN;
62
  return x - y;
63
}
64
 
65
unsigned int test6u(unsigned int x)
66
{
67
  unsigned int y = (unsigned int)INT_MIN;
68
  return x - y;
69
}
70
 
71
 
72
 
73
void test(int a, int b)
74
{
75
  if (test1(a) != b)
76
    abort();
77
  if (test2(a) != b)
78
    abort();
79
  if (test3(a) != b)
80
    abort();
81
  if (test4(a) != b)
82
    abort();
83
  if (test5(a) != b)
84
    abort();
85
  if (test6(a) != b)
86
    abort();
87
}
88
 
89
void testu(unsigned int a, unsigned int b)
90
{
91
  if (test1u(a) != b)
92
    abort();
93
  if (test2u(a) != b)
94
    abort();
95
  if (test3u(a) != b)
96
    abort();
97
  if (test4u(a) != b)
98
    abort();
99
  if (test5u(a) != b)
100
    abort();
101
  if (test6u(a) != b)
102
    abort();
103
}
104
 
105
 
106
int main()
107
{
108
#if INT_MAX == 2147483647
109
  test(0x00000000,0x80000000);
110
  test(0x80000000,0x00000000);
111
  test(0x12345678,0x92345678);
112
  test(0x92345678,0x12345678);
113
  test(0x7fffffff,0xffffffff);
114
  test(0xffffffff,0x7fffffff);
115
 
116
  testu(0x00000000,0x80000000);
117
  testu(0x80000000,0x00000000);
118
  testu(0x12345678,0x92345678);
119
  testu(0x92345678,0x12345678);
120
  testu(0x7fffffff,0xffffffff);
121
  testu(0xffffffff,0x7fffffff);
122
#endif
123
 
124
#if INT_MAX == 32767
125
  test(0x0000,0x8000);
126
  test(0x8000,0x0000);
127
  test(0x1234,0x9234);
128
  test(0x9234,0x1234);
129
  test(0x7fff,0xffff);
130
  test(0xffff,0x7fff);
131
 
132
  testu(0x0000,0x8000);
133
  testu(0x8000,0x0000);
134
  testu(0x1234,0x9234);
135
  testu(0x9234,0x1234);
136
  testu(0x7fff,0xffff);
137
  testu(0xffff,0x7fff);
138
#endif
139
 
140
  return 0;
141
}
142
 

powered by: WebSVN 2.1.0

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