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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [ieee/] [compare-fp-1.c] - Blame information for rev 825

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

Line No. Rev Author Line
1 149 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) (!__builtin_isunordered ((a), (b)))
11
#define UNORD(a, b) (__builtin_isunordered ((a), (b)))
12
#define UNEQ(a, b) (__builtin_isunordered ((a), (b)) || ((a) == (b)))
13
#define UNLT(a, b) (__builtin_isunordered ((a), (b)) || ((a) < (b)))
14
#define UNLE(a, b) (__builtin_isunordered ((a), (b)) || ((a) <= (b)))
15
#define UNGT(a, b) (__builtin_isunordered ((a), (b)) || ((a) > (b)))
16
#define UNGE(a, b) (__builtin_isunordered ((a), (b)) || ((a) >= (b)))
17
#define LTGT(a, b) (__builtin_islessgreater ((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)); /* Not optimizable. */
38
  TEST (LTGT (x, y)); /* Same, __builtin_islessgreater does not trap. */
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
}
46
 
47
int iunlt (float x, float y, int ok)
48
{
49
  TEST (UNLT (x, y));
50
  TEST (UNORD (x, y) || (x < y));
51
}
52
 
53
int ilt (float x, float y, int ok)
54
{
55
  TEST (ORD (x, y) && UNLT (x, y)); /* Not optimized */
56
  TEST ((x <= y) && (x != y));
57
  TEST ((x <= y) && (y != x));
58
  TEST ((x != y) && (x <= y)); /* Not optimized */
59
  TEST ((y != x) && (x <= y)); /* Not optimized */
60
}
61
 
62
int iunle (float x, float y, int ok)
63
{
64
  TEST (UNLE (x, y));
65
  TEST (UNORD (x, y) || (x <= y));
66
}
67
 
68
int ile (float x, float y, int ok)
69
{
70
  TEST (ORD (x, y) && UNLE (x, y)); /* Not optimized */
71
  TEST ((x < y) || (x == y));
72
  TEST ((y > x) || (x == y));
73
  TEST ((x == y) || (x < y)); /* Not optimized */
74
  TEST ((y == x) || (x < y)); /* Not optimized */
75
}
76
 
77
int iungt (float x, float y, int ok)
78
{
79
  TEST (UNGT (x, y));
80
  TEST (UNORD (x, y) || (x > y));
81
}
82
 
83
int igt (float x, float y, int ok)
84
{
85
  TEST (ORD (x, y) && UNGT (x, y)); /* Not optimized */
86
  TEST ((x >= y) && (x != y));
87
  TEST ((x >= y) && (y != x));
88
  TEST ((x != y) && (x >= y)); /* Not optimized */
89
  TEST ((y != x) && (x >= y)); /* Not optimized */
90
}
91
 
92
int iunge (float x, float y, int ok)
93
{
94
  TEST (UNGE (x, y));
95
  TEST (UNORD (x, y) || (x >= y));
96
}
97
 
98
int ige (float x, float y, int ok)
99
{
100
  TEST (ORD (x, y) && UNGE (x, y)); /* Not optimized */
101
  TEST ((x > y) || (x == y));
102
  TEST ((y < x) || (x == y));
103
  TEST ((x == y) || (x > y)); /* Not optimized */
104
  TEST ((y == x) || (x > y)); /* Not optimized */
105
}
106
 
107
int
108
main ()
109
{
110
  pinf = __builtin_inf ();
111
  ninf = -__builtin_inf ();
112
  NaN = __builtin_nan ("");
113
 
114
  iuneq (ninf, pinf, 0);
115
  iuneq (NaN, NaN, 1);
116
  iuneq (pinf, ninf, 0);
117
  iuneq (1, 4, 0);
118
  iuneq (3, 3, 1);
119
  iuneq (5, 2, 0);
120
 
121
  ieq (1, 4, 0);
122
  ieq (3, 3, 1);
123
  ieq (5, 2, 0);
124
 
125
  iltgt (ninf, pinf, 1);
126
  iltgt (NaN, NaN, 0);
127
  iltgt (pinf, ninf, 1);
128
  iltgt (1, 4, 1);
129
  iltgt (3, 3, 0);
130
  iltgt (5, 2, 1);
131
 
132
  ine (1, 4, 1);
133
  ine (3, 3, 0);
134
  ine (5, 2, 1);
135
 
136
  iunlt (NaN, ninf, 1);
137
  iunlt (pinf, NaN, 1);
138
  iunlt (pinf, ninf, 0);
139
  iunlt (pinf, pinf, 0);
140
  iunlt (ninf, ninf, 0);
141
  iunlt (1, 4, 1);
142
  iunlt (3, 3, 0);
143
  iunlt (5, 2, 0);
144
 
145
  ilt (1, 4, 1);
146
  ilt (3, 3, 0);
147
  ilt (5, 2, 0);
148
 
149
  iunle (NaN, ninf, 1);
150
  iunle (pinf, NaN, 1);
151
  iunle (pinf, ninf, 0);
152
  iunle (pinf, pinf, 1);
153
  iunle (ninf, ninf, 1);
154
  iunle (1, 4, 1);
155
  iunle (3, 3, 1);
156
  iunle (5, 2, 0);
157
 
158
  ile (1, 4, 1);
159
  ile (3, 3, 1);
160
  ile (5, 2, 0);
161
 
162
  iungt (NaN, ninf, 1);
163
  iungt (pinf, NaN, 1);
164
  iungt (pinf, ninf, 1);
165
  iungt (pinf, pinf, 0);
166
  iungt (ninf, ninf, 0);
167
  iungt (1, 4, 0);
168
  iungt (3, 3, 0);
169
  iungt (5, 2, 1);
170
 
171
  igt (1, 4, 0);
172
  igt (3, 3, 0);
173
  igt (5, 2, 1);
174
 
175
  iunge (NaN, ninf, 1);
176
  iunge (pinf, NaN, 1);
177
  iunge (ninf, pinf, 0);
178
  iunge (pinf, pinf, 1);
179
  iunge (ninf, ninf, 1);
180
  iunge (1, 4, 0);
181
  iunge (3, 3, 1);
182
  iunge (5, 2, 1);
183
 
184
  ige (1, 4, 0);
185
  ige (3, 3, 1);
186
  ige (5, 2, 1);
187
 
188
  return 0;
189
}

powered by: WebSVN 2.1.0

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