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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [ieee/] [compare-fp-4.c] - Blame information for rev 801

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

Line No. Rev Author Line
1 688 jeremybenn
/* Copyright (C) 2004 Free Software Foundation.
2
 
3
   Test for correctness of composite floating-point comparisons.
4
 
5
   Written by Paolo Bonzini, 26th May 2004.  */
6
 
7
extern void abort (void);
8
 
9
#define TEST(c) if ((c) != ok) abort ();
10
#define ORD(a, b) (((a) < (b)) || (a) >= (b))
11
#define UNORD(a, b) (!ORD ((a), (b)))
12
#define UNEQ(a, b) (!LTGT ((a), (b)))
13
#define UNLT(a, b) (((a) < (b)) || __builtin_isunordered ((a), (b)))
14
#define UNLE(a, b) (((a) <= (b)) || __builtin_isunordered ((a), (b)))
15
#define UNGT(a, b) (((a) > (b)) || __builtin_isunordered ((a), (b)))
16
#define UNGE(a, b) (((a) >= (b)) || __builtin_isunordered ((a), (b)))
17
#define LTGT(a, b) (((a) < (b)) || (a) > (b))
18
 
19
float pinf;
20
float ninf;
21
float NaN;
22
 
23
int iuneq (float x, float y, int ok)
24
{
25
  TEST (UNEQ (x, y));
26
  TEST (!LTGT (x, y));
27
  TEST (UNLE (x, y) && UNGE (x,y));
28
}
29
 
30
int ieq (float x, float y, int ok)
31
{
32
  TEST (ORD (x, y) && UNEQ (x, y));
33
}
34
 
35
int iltgt (float x, float y, int ok)
36
{
37
  TEST (!UNEQ (x, y));
38
  TEST (LTGT (x, y));
39
  TEST (ORD (x, y) && (UNLT (x, y) || UNGT (x,y)));
40
}
41
 
42
int ine (float x, float y, int ok)
43
{
44
  TEST (UNLT (x, y) || UNGT (x, y));
45
  TEST ((x < y) || (x > y) || UNORD (x, y));
46
}
47
 
48
int iunlt (float x, float y, int ok)
49
{
50
  TEST (UNLT (x, y));
51
  TEST (UNORD (x, y) || (x < y));
52
}
53
 
54
int ilt (float x, float y, int ok)
55
{
56
  TEST (ORD (x, y) && UNLT (x, y));
57
  TEST ((x <= y) && (x != y));
58
  TEST ((x <= y) && (y != x));
59
  TEST ((x != y) && (x <= y));
60
  TEST ((y != x) && (x <= y));
61
}
62
 
63
int iunle (float x, float y, int ok)
64
{
65
  TEST (UNLE (x, y));
66
  TEST (UNORD (x, y) || (x <= y));
67
}
68
 
69
int ile (float x, float y, int ok)
70
{
71
  TEST (ORD (x, y) && UNLE (x, y));
72
  TEST ((x < y) || (x == y));
73
  TEST ((y > x) || (x == y));
74
  TEST ((x == y) || (x < y));
75
  TEST ((y == x) || (x < y));
76
}
77
 
78
int iungt (float x, float y, int ok)
79
{
80
  TEST (UNGT (x, y));
81
  TEST (UNORD (x, y) || (x > y));
82
}
83
 
84
int igt (float x, float y, int ok)
85
{
86
  TEST (ORD (x, y) && UNGT (x, y));
87
  TEST ((x >= y) && (x != y));
88
  TEST ((x >= y) && (y != x));
89
  TEST ((x != y) && (x >= y));
90
  TEST ((y != x) && (x >= y));
91
}
92
 
93
int iunge (float x, float y, int ok)
94
{
95
  TEST (UNGE (x, y));
96
  TEST (UNORD (x, y) || (x >= y));
97
}
98
 
99
int ige (float x, float y, int ok)
100
{
101
  TEST (ORD (x, y) && UNGE (x, y));
102
  TEST ((x > y) || (x == y));
103
  TEST ((y < x) || (x == y));
104
  TEST ((x == y) || (x > y));
105
  TEST ((y == x) || (x > y));
106
}
107
 
108
int
109
main ()
110
{
111
  pinf = __builtin_inf ();
112
  ninf = -__builtin_inf ();
113
  NaN = __builtin_nan ("");
114
 
115
  iuneq (ninf, pinf, 0);
116
  iuneq (NaN, NaN, 1);
117
  iuneq (pinf, ninf, 0);
118
  iuneq (1, 4, 0);
119
  iuneq (3, 3, 1);
120
  iuneq (5, 2, 0);
121
 
122
  ieq (1, 4, 0);
123
  ieq (3, 3, 1);
124
  ieq (5, 2, 0);
125
 
126
  iltgt (ninf, pinf, 1);
127
  iltgt (NaN, NaN, 0);
128
  iltgt (pinf, ninf, 1);
129
  iltgt (1, 4, 1);
130
  iltgt (3, 3, 0);
131
  iltgt (5, 2, 1);
132
 
133
  ine (1, 4, 1);
134
  ine (3, 3, 0);
135
  ine (5, 2, 1);
136
 
137
  iunlt (NaN, ninf, 1);
138
  iunlt (pinf, NaN, 1);
139
  iunlt (pinf, ninf, 0);
140
  iunlt (pinf, pinf, 0);
141
  iunlt (ninf, ninf, 0);
142
  iunlt (1, 4, 1);
143
  iunlt (3, 3, 0);
144
  iunlt (5, 2, 0);
145
 
146
  ilt (1, 4, 1);
147
  ilt (3, 3, 0);
148
  ilt (5, 2, 0);
149
 
150
  iunle (NaN, ninf, 1);
151
  iunle (pinf, NaN, 1);
152
  iunle (pinf, ninf, 0);
153
  iunle (pinf, pinf, 1);
154
  iunle (ninf, ninf, 1);
155
  iunle (1, 4, 1);
156
  iunle (3, 3, 1);
157
  iunle (5, 2, 0);
158
 
159
  ile (1, 4, 1);
160
  ile (3, 3, 1);
161
  ile (5, 2, 0);
162
 
163
  iungt (NaN, ninf, 1);
164
  iungt (pinf, NaN, 1);
165
  iungt (pinf, ninf, 1);
166
  iungt (pinf, pinf, 0);
167
  iungt (ninf, ninf, 0);
168
  iungt (1, 4, 0);
169
  iungt (3, 3, 0);
170
  iungt (5, 2, 1);
171
 
172
  igt (1, 4, 0);
173
  igt (3, 3, 0);
174
  igt (5, 2, 1);
175
 
176
  iunge (NaN, ninf, 1);
177
  iunge (pinf, NaN, 1);
178
  iunge (ninf, pinf, 0);
179
  iunge (pinf, pinf, 1);
180
  iunge (ninf, ninf, 1);
181
  iunge (1, 4, 0);
182
  iunge (3, 3, 1);
183
  iunge (5, 2, 1);
184
 
185
  ige (1, 4, 0);
186
  ige (3, 3, 1);
187
  ige (5, 2, 1);
188
 
189
  return 0;
190
}

powered by: WebSVN 2.1.0

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