Skip to content

Commit 7661d3b

Browse files
committed
Speculatively fix build bots
This should address the issues found by: https://lab.llvm.org/buildbot/#/builders/105/builds/24292
1 parent 4f843f9 commit 7661d3b

File tree

4 files changed

+147
-143
lines changed

4 files changed

+147
-143
lines changed

compiler-rt/test/builtins/Unit/ppc/qadd_test.c

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
#include "DD.h"
55

66
long double __gcc_qadd(long double x, long double y);
7+
int memcmp(const void *, const void *, __typeof__(sizeof(0)));
78

89
double testAccuracy();
910
int testEdgeCases();
1011

1112
int main(int argc, char *argv[]) {
1213
if (testEdgeCases())
1314
return 1;
14-
15+
1516
if (testAccuracy() > 1.0)
1617
return 1;
17-
18+
1819
return 0;
1920
}
2021

@@ -114,11 +115,11 @@ int testEdgeCases() {
114115
b.lo = edgeCases[i].ylo;
115116
r.hi = edgeCases[i].rhi;
116117
r.lo = edgeCases[i].rlo;
117-
118+
118119
int error;
119-
120+
120121
DD c = { .ld = __gcc_qadd(a.ld, b.ld) };
121-
122+
122123
if (r.hi != r.hi) {
123124
if (c.hi == c.hi)
124125
error = 1;
@@ -130,134 +131,134 @@ int testEdgeCases() {
130131

131132
else if (r.hi == 0.0)
132133
error = memcmp(&c, &r, sizeof(DD));
133-
134+
134135
else
135136
error = ((c.hi != r.hi) || (c.lo != r.lo));
136-
137+
137138
if (error) {
138139
printf("Error on edge case %a + %a: expected (%a, %a), got (%a, %a).\n", a.hi, b.hi, r.hi, r.lo, c.hi, c.lo);
139140
return 1;
140141
}
141142
}
142-
143+
143144
return 0;
144145
}
145146

146147

147148
/*
148149
149150
Code for generating the test cases, requires the mpfr package to run.
150-
151+
151152
#include <stdio.h>
152153
#include <stdlib.h>
153154
#include <mpfr.h>
154-
155+
155156
#ifdef __x86_64__
156157
#define randlength 2
157158
#else
158159
#define randlength 4
159160
#endif
160-
161-
161+
162+
162163
int main(int argc, char *argv[]) {
163-
164+
164165
MPFR_DECL_INIT(a, 106);
165166
MPFR_DECL_INIT(b, 106);
166167
MPFR_DECL_INIT(c, 106);
167-
168+
168169
MPFR_DECL_INIT(tmp, 53);
169-
170+
170171
int exponent_range = atoi(argv[1]);
171-
172+
172173
int i;
173174
for (i=0; i<128; ++i) {
174175
mpfr_random2(a, randlength, exponent_range);
175176
mpfr_random2(b, randlength, exponent_range);
176177
mpfr_add(c, a, b, GMP_RNDN);
177-
178+
178179
double ahi = mpfr_get_d(a, GMP_RNDN);
179180
mpfr_set_d(tmp, ahi, GMP_RNDN);
180181
mpfr_sub(tmp, a, tmp, GMP_RNDN);
181182
double alo = mpfr_get_d(tmp, GMP_RNDN);
182183
printf("{%0.13a, %0.13a, ", ahi, alo);
183-
184+
184185
double bhi = mpfr_get_d(b, GMP_RNDN);
185186
mpfr_set_d(tmp, bhi, GMP_RNDN);
186187
mpfr_sub(tmp, b, tmp, GMP_RNDN);
187188
double blo = mpfr_get_d(tmp, GMP_RNDN);
188189
printf("%0.13a, %0.13a, ", bhi, blo);
189-
190+
190191
double chi = mpfr_get_d(c, GMP_RNDN);
191192
mpfr_set_d(tmp, chi, GMP_RNDN);
192193
mpfr_sub(tmp, c, tmp, GMP_RNDN);
193194
double clo = mpfr_get_d(tmp, GMP_RNDN);
194195
printf("%0.13a, %0.13a},\n", chi, clo);
195-
196+
196197
mpfr_neg(b, b, GMP_RNDN);
197198
mpfr_add(c, a, b, GMP_RNDN);
198-
199+
199200
ahi = mpfr_get_d(a, GMP_RNDN);
200201
mpfr_set_d(tmp, ahi, GMP_RNDN);
201202
mpfr_sub(tmp, a, tmp, GMP_RNDN);
202203
alo = mpfr_get_d(tmp, GMP_RNDN);
203204
printf("{%0.13a, %0.13a, ", ahi, alo);
204-
205+
205206
bhi = mpfr_get_d(b, GMP_RNDN);
206207
mpfr_set_d(tmp, bhi, GMP_RNDN);
207208
mpfr_sub(tmp, b, tmp, GMP_RNDN);
208209
blo = mpfr_get_d(tmp, GMP_RNDN);
209210
printf("%0.13a, %0.13a, ", bhi, blo);
210-
211+
211212
chi = mpfr_get_d(c, GMP_RNDN);
212213
mpfr_set_d(tmp, chi, GMP_RNDN);
213214
mpfr_sub(tmp, c, tmp, GMP_RNDN);
214215
clo = mpfr_get_d(tmp, GMP_RNDN);
215216
printf("%0.13a, %0.13a},\n", chi, clo);
216-
217+
217218
mpfr_neg(a, a, GMP_RNDN);
218219
mpfr_neg(b, b, GMP_RNDN);
219220
mpfr_add(c, a, b, GMP_RNDN);
220-
221+
221222
ahi = mpfr_get_d(a, GMP_RNDN);
222223
mpfr_set_d(tmp, ahi, GMP_RNDN);
223224
mpfr_sub(tmp, a, tmp, GMP_RNDN);
224225
alo = mpfr_get_d(tmp, GMP_RNDN);
225226
printf("{%0.13a, %0.13a, ", ahi, alo);
226-
227+
227228
bhi = mpfr_get_d(b, GMP_RNDN);
228229
mpfr_set_d(tmp, bhi, GMP_RNDN);
229230
mpfr_sub(tmp, b, tmp, GMP_RNDN);
230231
blo = mpfr_get_d(tmp, GMP_RNDN);
231232
printf("%0.13a, %0.13a, ", bhi, blo);
232-
233+
233234
chi = mpfr_get_d(c, GMP_RNDN);
234235
mpfr_set_d(tmp, chi, GMP_RNDN);
235236
mpfr_sub(tmp, c, tmp, GMP_RNDN);
236237
clo = mpfr_get_d(tmp, GMP_RNDN);
237238
printf("%0.13a, %0.13a},\n", chi, clo);
238-
239+
239240
mpfr_neg(b, b, GMP_RNDN);
240241
mpfr_add(c, a, b, GMP_RNDN);
241-
242+
242243
ahi = mpfr_get_d(a, GMP_RNDN);
243244
mpfr_set_d(tmp, ahi, GMP_RNDN);
244245
mpfr_sub(tmp, a, tmp, GMP_RNDN);
245246
alo = mpfr_get_d(tmp, GMP_RNDN);
246247
printf("{%0.13a, %0.13a, ", ahi, alo);
247-
248+
248249
bhi = mpfr_get_d(b, GMP_RNDN);
249250
mpfr_set_d(tmp, bhi, GMP_RNDN);
250251
mpfr_sub(tmp, b, tmp, GMP_RNDN);
251252
blo = mpfr_get_d(tmp, GMP_RNDN);
252253
printf("%0.13a, %0.13a, ", bhi, blo);
253-
254+
254255
chi = mpfr_get_d(c, GMP_RNDN);
255256
mpfr_set_d(tmp, chi, GMP_RNDN);
256257
mpfr_sub(tmp, c, tmp, GMP_RNDN);
257258
clo = mpfr_get_d(tmp, GMP_RNDN);
258259
printf("%0.13a, %0.13a},\n", chi, clo);
259260
}
260-
261+
261262
return 0;
262263
}
263264
@@ -1813,27 +1814,27 @@ const int numAccuracyTests = sizeof(accuracyTests) / sizeof(struct testVector);
18131814
double testAccuracy() {
18141815
int i;
18151816
DD a, b, c, r;
1816-
1817+
18171818
double worstUlps = 0.5;
1818-
1819+
18191820
for (i=0; i<numAccuracyTests; ++i) {
18201821
a.hi = accuracyTests[i].xhi;
18211822
a.lo = accuracyTests[i].xlo;
18221823
b.hi = accuracyTests[i].yhi;
18231824
b.lo = accuracyTests[i].ylo;
18241825
r.hi = accuracyTests[i].rhi;
18251826
r.lo = accuracyTests[i].rlo;
1826-
1827+
18271828
DD c = { .ld = __gcc_qadd(a.ld, b.ld) };
1828-
1829+
18291830
double error = __builtin_fabs(((r.hi - c.hi) + r.lo) - c.lo);
1830-
1831+
18311832
if (error != 0.0) {
1832-
1833+
18331834
int exponent = ilogb(r.hi);
18341835
exponent = (exponent < -1022 ? -1022 : exponent);
18351836
double ulpError = scalbn(error, 106 - exponent);
1836-
1837+
18371838
if (ulpError > worstUlps) {
18381839
#ifdef PRINT_ACCURACY_INFORMATION
18391840
printf("New worst rounding error for (%a,%a) + (%a,%a):\n", a.hi, a.lo, b.hi, b.lo);
@@ -1845,7 +1846,7 @@ double testAccuracy() {
18451846
}
18461847
}
18471848
}
1848-
1849+
18491850
return worstUlps;
18501851
}
18511852

0 commit comments

Comments
 (0)