xref: /freebsd/lib/libc/softfloat/timesoftfloat.c (revision 559a218c9b257775fb249b67945fe4a05b7a6b9f)
1 /* $NetBSD: timesoftfloat.c,v 1.1 2000/06/06 08:15:11 bjh21 Exp $ */
2 
3 /*
4 ===============================================================================
5 
6 This C source file is part of the SoftFloat IEC/IEEE Floating-point
7 Arithmetic Package, Release 2a.
8 
9 Written by John R. Hauser.  This work was made possible in part by the
10 International Computer Science Institute, located at Suite 600, 1947 Center
11 Street, Berkeley, California 94704.  Funding was partially provided by the
12 National Science Foundation under grant MIP-9311980.  The original version
13 of this code was written as part of a project to build a fixed-point vector
14 processor in collaboration with the University of California at Berkeley,
15 overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
16 is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
17 arithmetic/SoftFloat.html'.
18 
19 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
20 has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
21 TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
22 PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
23 AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
24 
25 Derivative works are acceptable, even for commercial purposes, so long as
26 (1) they include prominent notice that the work is derivative, and (2) they
27 include prominent notice akin to these four paragraphs for those parts of
28 this code that are retained.
29 
30 ===============================================================================
31 */
32 
33 #include <stdlib.h>
34 #include <stdarg.h>
35 #include <string.h>
36 #include <stdio.h>
37 #include <time.h>
38 #include "milieu.h"
39 #include "softfloat.h"
40 
41 enum {
42     minIterations = 1000
43 };
44 
fail(const char * message,...)45 static void fail( const char *message, ... )
46 {
47     va_list varArgs;
48 
49     fputs( "timesoftfloat: ", stderr );
50     va_start( varArgs, message );
51     vfprintf( stderr, message, varArgs );
52     va_end( varArgs );
53     fputs( ".\n", stderr );
54     exit( EXIT_FAILURE );
55 
56 }
57 
58 static char *functionName;
59 static char *roundingPrecisionName, *roundingModeName, *tininessModeName;
60 
reportTime(int32 count,long clocks)61 static void reportTime( int32 count, long clocks )
62 {
63 
64     printf(
65         "%8.1f kops/s: %s",
66         ( count / ( ( (float) clocks ) / CLOCKS_PER_SEC ) ) / 1000,
67         functionName
68     );
69     if ( roundingModeName ) {
70         if ( roundingPrecisionName ) {
71             fputs( ", precision ", stdout );
72             fputs( roundingPrecisionName, stdout );
73         }
74         fputs( ", rounding ", stdout );
75         fputs( roundingModeName, stdout );
76         if ( tininessModeName ) {
77             fputs( ", tininess ", stdout );
78             fputs( tininessModeName, stdout );
79             fputs( " rounding", stdout );
80         }
81     }
82     fputc( '\n', stdout );
83 
84 }
85 
86 enum {
87     numInputs_int32 = 32
88 };
89 
90 static const int32 inputs_int32[ numInputs_int32 ] = {
91     0xFFFFBB79, 0x405CF80F, 0x00000000, 0xFFFFFD04,
92     0xFFF20002, 0x0C8EF795, 0xF00011FF, 0x000006CA,
93     0x00009BFE, 0xFF4862E3, 0x9FFFEFFE, 0xFFFFFFB7,
94     0x0BFF7FFF, 0x0000F37A, 0x0011DFFE, 0x00000006,
95     0xFFF02006, 0xFFFFF7D1, 0x10200003, 0xDE8DF765,
96     0x00003E02, 0x000019E8, 0x0008FFFE, 0xFFFFFB5C,
97     0xFFDF7FFE, 0x07C42FBF, 0x0FFFE3FF, 0x040B9F13,
98     0xBFFFFFF8, 0x0001BF56, 0x000017F6, 0x000A908A
99 };
100 
time_a_int32_z_float32(float32 function (int32))101 static void time_a_int32_z_float32( float32 function( int32 ) )
102 {
103     clock_t startClock, endClock;
104     int32 count, i;
105     int8 inputNum;
106 
107     count = 0;
108     inputNum = 0;
109     startClock = clock();
110     do {
111         for ( i = minIterations; i; --i ) {
112             function( inputs_int32[ inputNum ] );
113             inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
114         }
115         count += minIterations;
116     } while ( clock() - startClock < CLOCKS_PER_SEC );
117     inputNum = 0;
118     startClock = clock();
119     for ( i = count; i; --i ) {
120         function( inputs_int32[ inputNum ] );
121         inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
122     }
123     endClock = clock();
124     reportTime( count, endClock - startClock );
125 
126 }
127 
time_a_int32_z_float64(float64 function (int32))128 static void time_a_int32_z_float64( float64 function( int32 ) )
129 {
130     clock_t startClock, endClock;
131     int32 count, i;
132     int8 inputNum;
133 
134     count = 0;
135     inputNum = 0;
136     startClock = clock();
137     do {
138         for ( i = minIterations; i; --i ) {
139             function( inputs_int32[ inputNum ] );
140             inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
141         }
142         count += minIterations;
143     } while ( clock() - startClock < CLOCKS_PER_SEC );
144     inputNum = 0;
145     startClock = clock();
146     for ( i = count; i; --i ) {
147         function( inputs_int32[ inputNum ] );
148         inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
149     }
150     endClock = clock();
151     reportTime( count, endClock - startClock );
152 
153 }
154 
155 #ifdef FLOATX80
156 
time_a_int32_z_floatx80(floatx80 function (int32))157 static void time_a_int32_z_floatx80( floatx80 function( int32 ) )
158 {
159     clock_t startClock, endClock;
160     int32 count, i;
161     int8 inputNum;
162 
163     count = 0;
164     inputNum = 0;
165     startClock = clock();
166     do {
167         for ( i = minIterations; i; --i ) {
168             function( inputs_int32[ inputNum ] );
169             inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
170         }
171         count += minIterations;
172     } while ( clock() - startClock < CLOCKS_PER_SEC );
173     inputNum = 0;
174     startClock = clock();
175     for ( i = count; i; --i ) {
176         function( inputs_int32[ inputNum ] );
177         inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
178     }
179     endClock = clock();
180     reportTime( count, endClock - startClock );
181 
182 }
183 
184 #endif
185 
186 #ifdef FLOAT128
187 
time_a_int32_z_float128(float128 function (int32))188 static void time_a_int32_z_float128( float128 function( int32 ) )
189 {
190     clock_t startClock, endClock;
191     int32 count, i;
192     int8 inputNum;
193 
194     count = 0;
195     inputNum = 0;
196     startClock = clock();
197     do {
198         for ( i = minIterations; i; --i ) {
199             function( inputs_int32[ inputNum ] );
200             inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
201         }
202         count += minIterations;
203     } while ( clock() - startClock < CLOCKS_PER_SEC );
204     inputNum = 0;
205     startClock = clock();
206     for ( i = count; i; --i ) {
207         function( inputs_int32[ inputNum ] );
208         inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );
209     }
210     endClock = clock();
211     reportTime( count, endClock - startClock );
212 
213 }
214 
215 #endif
216 
217 enum {
218     numInputs_int64 = 32
219 };
220 
221 static const int64 inputs_int64[ numInputs_int64 ] = {
222     LIT64( 0xFBFFC3FFFFFFFFFF ),
223     LIT64( 0x0000000003C589BC ),
224     LIT64( 0x00000000400013FE ),
225     LIT64( 0x0000000000186171 ),
226     LIT64( 0xFFFFFFFFFFFEFBFA ),
227     LIT64( 0xFFFFFD79E6DFFC73 ),
228     LIT64( 0x0000000010001DFF ),
229     LIT64( 0xDD1A0F0C78513710 ),
230     LIT64( 0xFFFF83FFFFFEFFFE ),
231     LIT64( 0x00756EBD1AD0C1C7 ),
232     LIT64( 0x0003FDFFFFFFFFBE ),
233     LIT64( 0x0007D0FB2C2CA951 ),
234     LIT64( 0x0007FC0007FFFFFE ),
235     LIT64( 0x0000001F942B18BB ),
236     LIT64( 0x0000080101FFFFFE ),
237     LIT64( 0xFFFFFFFFFFFF0978 ),
238     LIT64( 0x000000000008BFFF ),
239     LIT64( 0x0000000006F5AF08 ),
240     LIT64( 0xFFDEFF7FFFFFFFFE ),
241     LIT64( 0x0000000000000003 ),
242     LIT64( 0x3FFFFFFFFF80007D ),
243     LIT64( 0x0000000000000078 ),
244     LIT64( 0xFFF80000007FDFFD ),
245     LIT64( 0x1BBC775B78016AB0 ),
246     LIT64( 0xFFF9001FFFFFFFFE ),
247     LIT64( 0xFFFD4767AB98E43F ),
248     LIT64( 0xFFFFFEFFFE00001E ),
249     LIT64( 0xFFFFFFFFFFF04EFD ),
250     LIT64( 0x07FFFFFFFFFFF7FF ),
251     LIT64( 0xFFFC9EAA38F89050 ),
252     LIT64( 0x00000020FBFFFFFE ),
253     LIT64( 0x0000099AE6455357 )
254 };
255 
time_a_int64_z_float32(float32 function (int64))256 static void time_a_int64_z_float32( float32 function( int64 ) )
257 {
258     clock_t startClock, endClock;
259     int32 count, i;
260     int8 inputNum;
261 
262     count = 0;
263     inputNum = 0;
264     startClock = clock();
265     do {
266         for ( i = minIterations; i; --i ) {
267             function( inputs_int64[ inputNum ] );
268             inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
269         }
270         count += minIterations;
271     } while ( clock() - startClock < CLOCKS_PER_SEC );
272     inputNum = 0;
273     startClock = clock();
274     for ( i = count; i; --i ) {
275         function( inputs_int64[ inputNum ] );
276         inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
277     }
278     endClock = clock();
279     reportTime( count, endClock - startClock );
280 
281 }
282 
time_a_int64_z_float64(float64 function (int64))283 static void time_a_int64_z_float64( float64 function( int64 ) )
284 {
285     clock_t startClock, endClock;
286     int32 count, i;
287     int8 inputNum;
288 
289     count = 0;
290     inputNum = 0;
291     startClock = clock();
292     do {
293         for ( i = minIterations; i; --i ) {
294             function( inputs_int64[ inputNum ] );
295             inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
296         }
297         count += minIterations;
298     } while ( clock() - startClock < CLOCKS_PER_SEC );
299     inputNum = 0;
300     startClock = clock();
301     for ( i = count; i; --i ) {
302         function( inputs_int64[ inputNum ] );
303         inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
304     }
305     endClock = clock();
306     reportTime( count, endClock - startClock );
307 
308 }
309 
310 #ifdef FLOATX80
311 
time_a_int64_z_floatx80(floatx80 function (int64))312 static void time_a_int64_z_floatx80( floatx80 function( int64 ) )
313 {
314     clock_t startClock, endClock;
315     int32 count, i;
316     int8 inputNum;
317 
318     count = 0;
319     inputNum = 0;
320     startClock = clock();
321     do {
322         for ( i = minIterations; i; --i ) {
323             function( inputs_int64[ inputNum ] );
324             inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
325         }
326         count += minIterations;
327     } while ( clock() - startClock < CLOCKS_PER_SEC );
328     inputNum = 0;
329     startClock = clock();
330     for ( i = count; i; --i ) {
331         function( inputs_int64[ inputNum ] );
332         inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
333     }
334     endClock = clock();
335     reportTime( count, endClock - startClock );
336 
337 }
338 
339 #endif
340 
341 #ifdef FLOAT128
342 
time_a_int64_z_float128(float128 function (int64))343 static void time_a_int64_z_float128( float128 function( int64 ) )
344 {
345     clock_t startClock, endClock;
346     int32 count, i;
347     int8 inputNum;
348 
349     count = 0;
350     inputNum = 0;
351     startClock = clock();
352     do {
353         for ( i = minIterations; i; --i ) {
354             function( inputs_int64[ inputNum ] );
355             inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
356         }
357         count += minIterations;
358     } while ( clock() - startClock < CLOCKS_PER_SEC );
359     inputNum = 0;
360     startClock = clock();
361     for ( i = count; i; --i ) {
362         function( inputs_int64[ inputNum ] );
363         inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );
364     }
365     endClock = clock();
366     reportTime( count, endClock - startClock );
367 
368 }
369 
370 #endif
371 
372 enum {
373     numInputs_float32 = 32
374 };
375 
376 static const float32 inputs_float32[ numInputs_float32 ] = {
377     0x4EFA0000, 0xC1D0B328, 0x80000000, 0x3E69A31E,
378     0xAF803EFF, 0x3F800000, 0x17BF8000, 0xE74A301A,
379     0x4E010003, 0x7EE3C75D, 0xBD803FE0, 0xBFFEFF00,
380     0x7981F800, 0x431FFFFC, 0xC100C000, 0x3D87EFFF,
381     0x4103FEFE, 0xBC000007, 0xBF01F7FF, 0x4E6C6B5C,
382     0xC187FFFE, 0xC58B9F13, 0x4F88007F, 0xDF004007,
383     0xB7FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000,
384     0xDB428661, 0x33F89B1F, 0xA3BFEFFF, 0x537BFFBE
385 };
386 
time_a_float32_z_int32(int32 function (float32))387 static void time_a_float32_z_int32( int32 function( float32 ) )
388 {
389     clock_t startClock, endClock;
390     int32 count, i;
391     int8 inputNum;
392 
393     count = 0;
394     inputNum = 0;
395     startClock = clock();
396     do {
397         for ( i = minIterations; i; --i ) {
398             function( inputs_float32[ inputNum ] );
399             inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
400         }
401         count += minIterations;
402     } while ( clock() - startClock < CLOCKS_PER_SEC );
403     inputNum = 0;
404     startClock = clock();
405     for ( i = count; i; --i ) {
406         function( inputs_float32[ inputNum ] );
407         inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
408     }
409     endClock = clock();
410     reportTime( count, endClock - startClock );
411 
412 }
413 
time_a_float32_z_int64(int64 function (float32))414 static void time_a_float32_z_int64( int64 function( float32 ) )
415 {
416     clock_t startClock, endClock;
417     int32 count, i;
418     int8 inputNum;
419 
420     count = 0;
421     inputNum = 0;
422     startClock = clock();
423     do {
424         for ( i = minIterations; i; --i ) {
425             function( inputs_float32[ inputNum ] );
426             inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
427         }
428         count += minIterations;
429     } while ( clock() - startClock < CLOCKS_PER_SEC );
430     inputNum = 0;
431     startClock = clock();
432     for ( i = count; i; --i ) {
433         function( inputs_float32[ inputNum ] );
434         inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
435     }
436     endClock = clock();
437     reportTime( count, endClock - startClock );
438 
439 }
440 
time_a_float32_z_float64(float64 function (float32))441 static void time_a_float32_z_float64( float64 function( float32 ) )
442 {
443     clock_t startClock, endClock;
444     int32 count, i;
445     int8 inputNum;
446 
447     count = 0;
448     inputNum = 0;
449     startClock = clock();
450     do {
451         for ( i = minIterations; i; --i ) {
452             function( inputs_float32[ inputNum ] );
453             inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
454         }
455         count += minIterations;
456     } while ( clock() - startClock < CLOCKS_PER_SEC );
457     inputNum = 0;
458     startClock = clock();
459     for ( i = count; i; --i ) {
460         function( inputs_float32[ inputNum ] );
461         inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
462     }
463     endClock = clock();
464     reportTime( count, endClock - startClock );
465 
466 }
467 
468 #ifdef FLOATX80
469 
time_a_float32_z_floatx80(floatx80 function (float32))470 static void time_a_float32_z_floatx80( floatx80 function( float32 ) )
471 {
472     clock_t startClock, endClock;
473     int32 count, i;
474     int8 inputNum;
475 
476     count = 0;
477     inputNum = 0;
478     startClock = clock();
479     do {
480         for ( i = minIterations; i; --i ) {
481             function( inputs_float32[ inputNum ] );
482             inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
483         }
484         count += minIterations;
485     } while ( clock() - startClock < CLOCKS_PER_SEC );
486     inputNum = 0;
487     startClock = clock();
488     for ( i = count; i; --i ) {
489         function( inputs_float32[ inputNum ] );
490         inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
491     }
492     endClock = clock();
493     reportTime( count, endClock - startClock );
494 
495 }
496 
497 #endif
498 
499 #ifdef FLOAT128
500 
time_a_float32_z_float128(float128 function (float32))501 static void time_a_float32_z_float128( float128 function( float32 ) )
502 {
503     clock_t startClock, endClock;
504     int32 count, i;
505     int8 inputNum;
506 
507     count = 0;
508     inputNum = 0;
509     startClock = clock();
510     do {
511         for ( i = minIterations; i; --i ) {
512             function( inputs_float32[ inputNum ] );
513             inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
514         }
515         count += minIterations;
516     } while ( clock() - startClock < CLOCKS_PER_SEC );
517     inputNum = 0;
518     startClock = clock();
519     for ( i = count; i; --i ) {
520         function( inputs_float32[ inputNum ] );
521         inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
522     }
523     endClock = clock();
524     reportTime( count, endClock - startClock );
525 
526 }
527 
528 #endif
529 
time_az_float32(float32 function (float32))530 static void time_az_float32( float32 function( float32 ) )
531 {
532     clock_t startClock, endClock;
533     int32 count, i;
534     int8 inputNum;
535 
536     count = 0;
537     inputNum = 0;
538     startClock = clock();
539     do {
540         for ( i = minIterations; i; --i ) {
541             function( inputs_float32[ inputNum ] );
542             inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
543         }
544         count += minIterations;
545     } while ( clock() - startClock < CLOCKS_PER_SEC );
546     inputNum = 0;
547     startClock = clock();
548     for ( i = count; i; --i ) {
549         function( inputs_float32[ inputNum ] );
550         inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
551     }
552     endClock = clock();
553     reportTime( count, endClock - startClock );
554 
555 }
556 
time_ab_float32_z_flag(flag function (float32,float32))557 static void time_ab_float32_z_flag( flag function( float32, float32 ) )
558 {
559     clock_t startClock, endClock;
560     int32 count, i;
561     int8 inputNumA, inputNumB;
562 
563     count = 0;
564     inputNumA = 0;
565     inputNumB = 0;
566     startClock = clock();
567     do {
568         for ( i = minIterations; i; --i ) {
569             function(
570                 inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
571             inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
572             if ( inputNumA == 0 ) ++inputNumB;
573             inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
574         }
575         count += minIterations;
576     } while ( clock() - startClock < CLOCKS_PER_SEC );
577     inputNumA = 0;
578     inputNumB = 0;
579     startClock = clock();
580     for ( i = count; i; --i ) {
581             function(
582                 inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
583         inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
584         if ( inputNumA == 0 ) ++inputNumB;
585         inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
586     }
587     endClock = clock();
588     reportTime( count, endClock - startClock );
589 
590 }
591 
time_abz_float32(float32 function (float32,float32))592 static void time_abz_float32( float32 function( float32, float32 ) )
593 {
594     clock_t startClock, endClock;
595     int32 count, i;
596     int8 inputNumA, inputNumB;
597 
598     count = 0;
599     inputNumA = 0;
600     inputNumB = 0;
601     startClock = clock();
602     do {
603         for ( i = minIterations; i; --i ) {
604             function(
605                 inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
606             inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
607             if ( inputNumA == 0 ) ++inputNumB;
608             inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
609         }
610         count += minIterations;
611     } while ( clock() - startClock < CLOCKS_PER_SEC );
612     inputNumA = 0;
613     inputNumB = 0;
614     startClock = clock();
615     for ( i = count; i; --i ) {
616             function(
617                 inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );
618         inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );
619         if ( inputNumA == 0 ) ++inputNumB;
620         inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );
621     }
622     endClock = clock();
623     reportTime( count, endClock - startClock );
624 
625 }
626 
627 static const float32 inputs_float32_pos[ numInputs_float32 ] = {
628     0x4EFA0000, 0x41D0B328, 0x00000000, 0x3E69A31E,
629     0x2F803EFF, 0x3F800000, 0x17BF8000, 0x674A301A,
630     0x4E010003, 0x7EE3C75D, 0x3D803FE0, 0x3FFEFF00,
631     0x7981F800, 0x431FFFFC, 0x4100C000, 0x3D87EFFF,
632     0x4103FEFE, 0x3C000007, 0x3F01F7FF, 0x4E6C6B5C,
633     0x4187FFFE, 0x458B9F13, 0x4F88007F, 0x5F004007,
634     0x37FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000,
635     0x5B428661, 0x33F89B1F, 0x23BFEFFF, 0x537BFFBE
636 };
637 
time_az_float32_pos(float32 function (float32))638 static void time_az_float32_pos( float32 function( float32 ) )
639 {
640     clock_t startClock, endClock;
641     int32 count, i;
642     int8 inputNum;
643 
644     count = 0;
645     inputNum = 0;
646     startClock = clock();
647     do {
648         for ( i = minIterations; i; --i ) {
649             function( inputs_float32_pos[ inputNum ] );
650             inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
651         }
652         count += minIterations;
653     } while ( clock() - startClock < CLOCKS_PER_SEC );
654     inputNum = 0;
655     startClock = clock();
656     for ( i = count; i; --i ) {
657         function( inputs_float32_pos[ inputNum ] );
658         inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );
659     }
660     endClock = clock();
661     reportTime( count, endClock - startClock );
662 
663 }
664 
665 enum {
666     numInputs_float64 = 32
667 };
668 
669 static const float64 inputs_float64[ numInputs_float64 ] = {
670     LIT64( 0x422FFFC008000000 ),
671     LIT64( 0xB7E0000480000000 ),
672     LIT64( 0xF3FD2546120B7935 ),
673     LIT64( 0x3FF0000000000000 ),
674     LIT64( 0xCE07F766F09588D6 ),
675     LIT64( 0x8000000000000000 ),
676     LIT64( 0x3FCE000400000000 ),
677     LIT64( 0x8313B60F0032BED8 ),
678     LIT64( 0xC1EFFFFFC0002000 ),
679     LIT64( 0x3FB3C75D224F2B0F ),
680     LIT64( 0x7FD00000004000FF ),
681     LIT64( 0xA12FFF8000001FFF ),
682     LIT64( 0x3EE0000000FE0000 ),
683     LIT64( 0x0010000080000004 ),
684     LIT64( 0x41CFFFFE00000020 ),
685     LIT64( 0x40303FFFFFFFFFFD ),
686     LIT64( 0x3FD000003FEFFFFF ),
687     LIT64( 0xBFD0000010000000 ),
688     LIT64( 0xB7FC6B5C16CA55CF ),
689     LIT64( 0x413EEB940B9D1301 ),
690     LIT64( 0xC7E00200001FFFFF ),
691     LIT64( 0x47F00021FFFFFFFE ),
692     LIT64( 0xBFFFFFFFF80000FF ),
693     LIT64( 0xC07FFFFFE00FFFFF ),
694     LIT64( 0x001497A63740C5E8 ),
695     LIT64( 0xC4BFFFE0001FFFFF ),
696     LIT64( 0x96FFDFFEFFFFFFFF ),
697     LIT64( 0x403FC000000001FE ),
698     LIT64( 0xFFD00000000001F6 ),
699     LIT64( 0x0640400002000000 ),
700     LIT64( 0x479CEE1E4F789FE0 ),
701     LIT64( 0xC237FFFFFFFFFDFE )
702 };
703 
time_a_float64_z_int32(int32 function (float64))704 static void time_a_float64_z_int32( int32 function( float64 ) )
705 {
706     clock_t startClock, endClock;
707     int32 count, i;
708     int8 inputNum;
709 
710     count = 0;
711     inputNum = 0;
712     startClock = clock();
713     do {
714         for ( i = minIterations; i; --i ) {
715             function( inputs_float64[ inputNum ] );
716             inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
717         }
718         count += minIterations;
719     } while ( clock() - startClock < CLOCKS_PER_SEC );
720     inputNum = 0;
721     startClock = clock();
722     for ( i = count; i; --i ) {
723         function( inputs_float64[ inputNum ] );
724         inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
725     }
726     endClock = clock();
727     reportTime( count, endClock - startClock );
728 
729 }
730 
time_a_float64_z_int64(int64 function (float64))731 static void time_a_float64_z_int64( int64 function( float64 ) )
732 {
733     clock_t startClock, endClock;
734     int32 count, i;
735     int8 inputNum;
736 
737     count = 0;
738     inputNum = 0;
739     startClock = clock();
740     do {
741         for ( i = minIterations; i; --i ) {
742             function( inputs_float64[ inputNum ] );
743             inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
744         }
745         count += minIterations;
746     } while ( clock() - startClock < CLOCKS_PER_SEC );
747     inputNum = 0;
748     startClock = clock();
749     for ( i = count; i; --i ) {
750         function( inputs_float64[ inputNum ] );
751         inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
752     }
753     endClock = clock();
754     reportTime( count, endClock - startClock );
755 
756 }
757 
time_a_float64_z_float32(float32 function (float64))758 static void time_a_float64_z_float32( float32 function( float64 ) )
759 {
760     clock_t startClock, endClock;
761     int32 count, i;
762     int8 inputNum;
763 
764     count = 0;
765     inputNum = 0;
766     startClock = clock();
767     do {
768         for ( i = minIterations; i; --i ) {
769             function( inputs_float64[ inputNum ] );
770             inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
771         }
772         count += minIterations;
773     } while ( clock() - startClock < CLOCKS_PER_SEC );
774     inputNum = 0;
775     startClock = clock();
776     for ( i = count; i; --i ) {
777         function( inputs_float64[ inputNum ] );
778         inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
779     }
780     endClock = clock();
781     reportTime( count, endClock - startClock );
782 
783 }
784 
785 #ifdef FLOATX80
786 
time_a_float64_z_floatx80(floatx80 function (float64))787 static void time_a_float64_z_floatx80( floatx80 function( float64 ) )
788 {
789     clock_t startClock, endClock;
790     int32 count, i;
791     int8 inputNum;
792 
793     count = 0;
794     inputNum = 0;
795     startClock = clock();
796     do {
797         for ( i = minIterations; i; --i ) {
798             function( inputs_float64[ inputNum ] );
799             inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
800         }
801         count += minIterations;
802     } while ( clock() - startClock < CLOCKS_PER_SEC );
803     inputNum = 0;
804     startClock = clock();
805     for ( i = count; i; --i ) {
806         function( inputs_float64[ inputNum ] );
807         inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
808     }
809     endClock = clock();
810     reportTime( count, endClock - startClock );
811 
812 }
813 
814 #endif
815 
816 #ifdef FLOAT128
817 
time_a_float64_z_float128(float128 function (float64))818 static void time_a_float64_z_float128( float128 function( float64 ) )
819 {
820     clock_t startClock, endClock;
821     int32 count, i;
822     int8 inputNum;
823 
824     count = 0;
825     inputNum = 0;
826     startClock = clock();
827     do {
828         for ( i = minIterations; i; --i ) {
829             function( inputs_float64[ inputNum ] );
830             inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
831         }
832         count += minIterations;
833     } while ( clock() - startClock < CLOCKS_PER_SEC );
834     inputNum = 0;
835     startClock = clock();
836     for ( i = count; i; --i ) {
837         function( inputs_float64[ inputNum ] );
838         inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
839     }
840     endClock = clock();
841     reportTime( count, endClock - startClock );
842 
843 }
844 
845 #endif
846 
time_az_float64(float64 function (float64))847 static void time_az_float64( float64 function( float64 ) )
848 {
849     clock_t startClock, endClock;
850     int32 count, i;
851     int8 inputNum;
852 
853     count = 0;
854     inputNum = 0;
855     startClock = clock();
856     do {
857         for ( i = minIterations; i; --i ) {
858             function( inputs_float64[ inputNum ] );
859             inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
860         }
861         count += minIterations;
862     } while ( clock() - startClock < CLOCKS_PER_SEC );
863     inputNum = 0;
864     startClock = clock();
865     for ( i = count; i; --i ) {
866         function( inputs_float64[ inputNum ] );
867         inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
868     }
869     endClock = clock();
870     reportTime( count, endClock - startClock );
871 
872 }
873 
time_ab_float64_z_flag(flag function (float64,float64))874 static void time_ab_float64_z_flag( flag function( float64, float64 ) )
875 {
876     clock_t startClock, endClock;
877     int32 count, i;
878     int8 inputNumA, inputNumB;
879 
880     count = 0;
881     inputNumA = 0;
882     inputNumB = 0;
883     startClock = clock();
884     do {
885         for ( i = minIterations; i; --i ) {
886             function(
887                 inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
888             inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
889             if ( inputNumA == 0 ) ++inputNumB;
890             inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
891         }
892         count += minIterations;
893     } while ( clock() - startClock < CLOCKS_PER_SEC );
894     inputNumA = 0;
895     inputNumB = 0;
896     startClock = clock();
897     for ( i = count; i; --i ) {
898             function(
899                 inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
900         inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
901         if ( inputNumA == 0 ) ++inputNumB;
902         inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
903     }
904     endClock = clock();
905     reportTime( count, endClock - startClock );
906 
907 }
908 
time_abz_float64(float64 function (float64,float64))909 static void time_abz_float64( float64 function( float64, float64 ) )
910 {
911     clock_t startClock, endClock;
912     int32 count, i;
913     int8 inputNumA, inputNumB;
914 
915     count = 0;
916     inputNumA = 0;
917     inputNumB = 0;
918     startClock = clock();
919     do {
920         for ( i = minIterations; i; --i ) {
921             function(
922                 inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
923             inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
924             if ( inputNumA == 0 ) ++inputNumB;
925             inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
926         }
927         count += minIterations;
928     } while ( clock() - startClock < CLOCKS_PER_SEC );
929     inputNumA = 0;
930     inputNumB = 0;
931     startClock = clock();
932     for ( i = count; i; --i ) {
933             function(
934                 inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );
935         inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );
936         if ( inputNumA == 0 ) ++inputNumB;
937         inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );
938     }
939     endClock = clock();
940     reportTime( count, endClock - startClock );
941 
942 }
943 
944 static const float64 inputs_float64_pos[ numInputs_float64 ] = {
945     LIT64( 0x422FFFC008000000 ),
946     LIT64( 0x37E0000480000000 ),
947     LIT64( 0x73FD2546120B7935 ),
948     LIT64( 0x3FF0000000000000 ),
949     LIT64( 0x4E07F766F09588D6 ),
950     LIT64( 0x0000000000000000 ),
951     LIT64( 0x3FCE000400000000 ),
952     LIT64( 0x0313B60F0032BED8 ),
953     LIT64( 0x41EFFFFFC0002000 ),
954     LIT64( 0x3FB3C75D224F2B0F ),
955     LIT64( 0x7FD00000004000FF ),
956     LIT64( 0x212FFF8000001FFF ),
957     LIT64( 0x3EE0000000FE0000 ),
958     LIT64( 0x0010000080000004 ),
959     LIT64( 0x41CFFFFE00000020 ),
960     LIT64( 0x40303FFFFFFFFFFD ),
961     LIT64( 0x3FD000003FEFFFFF ),
962     LIT64( 0x3FD0000010000000 ),
963     LIT64( 0x37FC6B5C16CA55CF ),
964     LIT64( 0x413EEB940B9D1301 ),
965     LIT64( 0x47E00200001FFFFF ),
966     LIT64( 0x47F00021FFFFFFFE ),
967     LIT64( 0x3FFFFFFFF80000FF ),
968     LIT64( 0x407FFFFFE00FFFFF ),
969     LIT64( 0x001497A63740C5E8 ),
970     LIT64( 0x44BFFFE0001FFFFF ),
971     LIT64( 0x16FFDFFEFFFFFFFF ),
972     LIT64( 0x403FC000000001FE ),
973     LIT64( 0x7FD00000000001F6 ),
974     LIT64( 0x0640400002000000 ),
975     LIT64( 0x479CEE1E4F789FE0 ),
976     LIT64( 0x4237FFFFFFFFFDFE )
977 };
978 
time_az_float64_pos(float64 function (float64))979 static void time_az_float64_pos( float64 function( float64 ) )
980 {
981     clock_t startClock, endClock;
982     int32 count, i;
983     int8 inputNum;
984 
985     count = 0;
986     inputNum = 0;
987     startClock = clock();
988     do {
989         for ( i = minIterations; i; --i ) {
990             function( inputs_float64_pos[ inputNum ] );
991             inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
992         }
993         count += minIterations;
994     } while ( clock() - startClock < CLOCKS_PER_SEC );
995     inputNum = 0;
996     startClock = clock();
997     for ( i = count; i; --i ) {
998         function( inputs_float64_pos[ inputNum ] );
999         inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );
1000     }
1001     endClock = clock();
1002     reportTime( count, endClock - startClock );
1003 
1004 }
1005 
1006 #ifdef FLOATX80
1007 
1008 enum {
1009     numInputs_floatx80 = 32
1010 };
1011 
1012 static const struct {
1013     bits16 high;
1014     bits64 low;
1015 } inputs_floatx80[ numInputs_floatx80 ] = {
1016     { 0xC03F, LIT64( 0xA9BE15A19C1E8B62 ) },
1017     { 0x8000, LIT64( 0x0000000000000000 ) },
1018     { 0x75A8, LIT64( 0xE59591E4788957A5 ) },
1019     { 0xBFFF, LIT64( 0xFFF0000000000040 ) },
1020     { 0x0CD8, LIT64( 0xFC000000000007FE ) },
1021     { 0x43BA, LIT64( 0x99A4000000000000 ) },
1022     { 0x3FFF, LIT64( 0x8000000000000000 ) },
1023     { 0x4081, LIT64( 0x94FBF1BCEB5545F0 ) },
1024     { 0x403E, LIT64( 0xFFF0000000002000 ) },
1025     { 0x3FFE, LIT64( 0xC860E3C75D224F28 ) },
1026     { 0x407E, LIT64( 0xFC00000FFFFFFFFE ) },
1027     { 0x737A, LIT64( 0x800000007FFDFFFE ) },
1028     { 0x4044, LIT64( 0xFFFFFF80000FFFFF ) },
1029     { 0xBBFE, LIT64( 0x8000040000001FFE ) },
1030     { 0xC002, LIT64( 0xFF80000000000020 ) },
1031     { 0xDE8D, LIT64( 0xFFFFFFFFFFE00004 ) },
1032     { 0xC004, LIT64( 0x8000000000003FFB ) },
1033     { 0x407F, LIT64( 0x800000000003FFFE ) },
1034     { 0xC000, LIT64( 0xA459EE6A5C16CA55 ) },
1035     { 0x8003, LIT64( 0xC42CBF7399AEEB94 ) },
1036     { 0xBF7F, LIT64( 0xF800000000000006 ) },
1037     { 0xC07F, LIT64( 0xBF56BE8871F28FEA ) },
1038     { 0xC07E, LIT64( 0xFFFF77FFFFFFFFFE ) },
1039     { 0xADC9, LIT64( 0x8000000FFFFFFFDE ) },
1040     { 0xC001, LIT64( 0xEFF7FFFFFFFFFFFF ) },
1041     { 0x4001, LIT64( 0xBE84F30125C497A6 ) },
1042     { 0xC06B, LIT64( 0xEFFFFFFFFFFFFFFF ) },
1043     { 0x4080, LIT64( 0xFFFFFFFFBFFFFFFF ) },
1044     { 0x87E9, LIT64( 0x81FFFFFFFFFFFBFF ) },
1045     { 0xA63F, LIT64( 0x801FFFFFFEFFFFFE ) },
1046     { 0x403C, LIT64( 0x801FFFFFFFF7FFFF ) },
1047     { 0x4018, LIT64( 0x8000000000080003 ) }
1048 };
1049 
time_a_floatx80_z_int32(int32 function (floatx80))1050 static void time_a_floatx80_z_int32( int32 function( floatx80 ) )
1051 {
1052     clock_t startClock, endClock;
1053     int32 count, i;
1054     int8 inputNum;
1055     floatx80 a;
1056 
1057     count = 0;
1058     inputNum = 0;
1059     startClock = clock();
1060     do {
1061         for ( i = minIterations; i; --i ) {
1062             a.low = inputs_floatx80[ inputNum ].low;
1063             a.high = inputs_floatx80[ inputNum ].high;
1064             function( a );
1065             inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1066         }
1067         count += minIterations;
1068     } while ( clock() - startClock < CLOCKS_PER_SEC );
1069     inputNum = 0;
1070     startClock = clock();
1071     for ( i = count; i; --i ) {
1072         a.low = inputs_floatx80[ inputNum ].low;
1073         a.high = inputs_floatx80[ inputNum ].high;
1074         function( a );
1075         inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1076     }
1077     endClock = clock();
1078     reportTime( count, endClock - startClock );
1079 
1080 }
1081 
time_a_floatx80_z_int64(int64 function (floatx80))1082 static void time_a_floatx80_z_int64( int64 function( floatx80 ) )
1083 {
1084     clock_t startClock, endClock;
1085     int32 count, i;
1086     int8 inputNum;
1087     floatx80 a;
1088 
1089     count = 0;
1090     inputNum = 0;
1091     startClock = clock();
1092     do {
1093         for ( i = minIterations; i; --i ) {
1094             a.low = inputs_floatx80[ inputNum ].low;
1095             a.high = inputs_floatx80[ inputNum ].high;
1096             function( a );
1097             inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1098         }
1099         count += minIterations;
1100     } while ( clock() - startClock < CLOCKS_PER_SEC );
1101     inputNum = 0;
1102     startClock = clock();
1103     for ( i = count; i; --i ) {
1104         a.low = inputs_floatx80[ inputNum ].low;
1105         a.high = inputs_floatx80[ inputNum ].high;
1106         function( a );
1107         inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1108     }
1109     endClock = clock();
1110     reportTime( count, endClock - startClock );
1111 
1112 }
1113 
time_a_floatx80_z_float32(float32 function (floatx80))1114 static void time_a_floatx80_z_float32( float32 function( floatx80 ) )
1115 {
1116     clock_t startClock, endClock;
1117     int32 count, i;
1118     int8 inputNum;
1119     floatx80 a;
1120 
1121     count = 0;
1122     inputNum = 0;
1123     startClock = clock();
1124     do {
1125         for ( i = minIterations; i; --i ) {
1126             a.low = inputs_floatx80[ inputNum ].low;
1127             a.high = inputs_floatx80[ inputNum ].high;
1128             function( a );
1129             inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1130         }
1131         count += minIterations;
1132     } while ( clock() - startClock < CLOCKS_PER_SEC );
1133     inputNum = 0;
1134     startClock = clock();
1135     for ( i = count; i; --i ) {
1136         a.low = inputs_floatx80[ inputNum ].low;
1137         a.high = inputs_floatx80[ inputNum ].high;
1138         function( a );
1139         inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1140     }
1141     endClock = clock();
1142     reportTime( count, endClock - startClock );
1143 
1144 }
1145 
time_a_floatx80_z_float64(float64 function (floatx80))1146 static void time_a_floatx80_z_float64( float64 function( floatx80 ) )
1147 {
1148     clock_t startClock, endClock;
1149     int32 count, i;
1150     int8 inputNum;
1151     floatx80 a;
1152 
1153     count = 0;
1154     inputNum = 0;
1155     startClock = clock();
1156     do {
1157         for ( i = minIterations; i; --i ) {
1158             a.low = inputs_floatx80[ inputNum ].low;
1159             a.high = inputs_floatx80[ inputNum ].high;
1160             function( a );
1161             inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1162         }
1163         count += minIterations;
1164     } while ( clock() - startClock < CLOCKS_PER_SEC );
1165     inputNum = 0;
1166     startClock = clock();
1167     for ( i = count; i; --i ) {
1168         a.low = inputs_floatx80[ inputNum ].low;
1169         a.high = inputs_floatx80[ inputNum ].high;
1170         function( a );
1171         inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1172     }
1173     endClock = clock();
1174     reportTime( count, endClock - startClock );
1175 
1176 }
1177 
1178 #ifdef FLOAT128
1179 
time_a_floatx80_z_float128(float128 function (floatx80))1180 static void time_a_floatx80_z_float128( float128 function( floatx80 ) )
1181 {
1182     clock_t startClock, endClock;
1183     int32 count, i;
1184     int8 inputNum;
1185     floatx80 a;
1186 
1187     count = 0;
1188     inputNum = 0;
1189     startClock = clock();
1190     do {
1191         for ( i = minIterations; i; --i ) {
1192             a.low = inputs_floatx80[ inputNum ].low;
1193             a.high = inputs_floatx80[ inputNum ].high;
1194             function( a );
1195             inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1196         }
1197         count += minIterations;
1198     } while ( clock() - startClock < CLOCKS_PER_SEC );
1199     inputNum = 0;
1200     startClock = clock();
1201     for ( i = count; i; --i ) {
1202         a.low = inputs_floatx80[ inputNum ].low;
1203         a.high = inputs_floatx80[ inputNum ].high;
1204         function( a );
1205         inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1206     }
1207     endClock = clock();
1208     reportTime( count, endClock - startClock );
1209 
1210 }
1211 
1212 #endif
1213 
time_az_floatx80(floatx80 function (floatx80))1214 static void time_az_floatx80( floatx80 function( floatx80 ) )
1215 {
1216     clock_t startClock, endClock;
1217     int32 count, i;
1218     int8 inputNum;
1219     floatx80 a;
1220 
1221     count = 0;
1222     inputNum = 0;
1223     startClock = clock();
1224     do {
1225         for ( i = minIterations; i; --i ) {
1226             a.low = inputs_floatx80[ inputNum ].low;
1227             a.high = inputs_floatx80[ inputNum ].high;
1228             function( a );
1229             inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1230         }
1231         count += minIterations;
1232     } while ( clock() - startClock < CLOCKS_PER_SEC );
1233     inputNum = 0;
1234     startClock = clock();
1235     for ( i = count; i; --i ) {
1236         a.low = inputs_floatx80[ inputNum ].low;
1237         a.high = inputs_floatx80[ inputNum ].high;
1238         function( a );
1239         inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1240     }
1241     endClock = clock();
1242     reportTime( count, endClock - startClock );
1243 
1244 }
1245 
time_ab_floatx80_z_flag(flag function (floatx80,floatx80))1246 static void time_ab_floatx80_z_flag( flag function( floatx80, floatx80 ) )
1247 {
1248     clock_t startClock, endClock;
1249     int32 count, i;
1250     int8 inputNumA, inputNumB;
1251     floatx80 a, b;
1252 
1253     count = 0;
1254     inputNumA = 0;
1255     inputNumB = 0;
1256     startClock = clock();
1257     do {
1258         for ( i = minIterations; i; --i ) {
1259             a.low = inputs_floatx80[ inputNumA ].low;
1260             a.high = inputs_floatx80[ inputNumA ].high;
1261             b.low = inputs_floatx80[ inputNumB ].low;
1262             b.high = inputs_floatx80[ inputNumB ].high;
1263             function( a, b );
1264             inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1265             if ( inputNumA == 0 ) ++inputNumB;
1266             inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1267         }
1268         count += minIterations;
1269     } while ( clock() - startClock < CLOCKS_PER_SEC );
1270     inputNumA = 0;
1271     inputNumB = 0;
1272     startClock = clock();
1273     for ( i = count; i; --i ) {
1274         a.low = inputs_floatx80[ inputNumA ].low;
1275         a.high = inputs_floatx80[ inputNumA ].high;
1276         b.low = inputs_floatx80[ inputNumB ].low;
1277         b.high = inputs_floatx80[ inputNumB ].high;
1278         function( a, b );
1279         inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1280         if ( inputNumA == 0 ) ++inputNumB;
1281         inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1282     }
1283     endClock = clock();
1284     reportTime( count, endClock - startClock );
1285 
1286 }
1287 
time_abz_floatx80(floatx80 function (floatx80,floatx80))1288 static void time_abz_floatx80( floatx80 function( floatx80, floatx80 ) )
1289 {
1290     clock_t startClock, endClock;
1291     int32 count, i;
1292     int8 inputNumA, inputNumB;
1293     floatx80 a, b;
1294 
1295     count = 0;
1296     inputNumA = 0;
1297     inputNumB = 0;
1298     startClock = clock();
1299     do {
1300         for ( i = minIterations; i; --i ) {
1301             a.low = inputs_floatx80[ inputNumA ].low;
1302             a.high = inputs_floatx80[ inputNumA ].high;
1303             b.low = inputs_floatx80[ inputNumB ].low;
1304             b.high = inputs_floatx80[ inputNumB ].high;
1305             function( a, b );
1306             inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1307             if ( inputNumA == 0 ) ++inputNumB;
1308             inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1309         }
1310         count += minIterations;
1311     } while ( clock() - startClock < CLOCKS_PER_SEC );
1312     inputNumA = 0;
1313     inputNumB = 0;
1314     startClock = clock();
1315     for ( i = count; i; --i ) {
1316         a.low = inputs_floatx80[ inputNumA ].low;
1317         a.high = inputs_floatx80[ inputNumA ].high;
1318         b.low = inputs_floatx80[ inputNumB ].low;
1319         b.high = inputs_floatx80[ inputNumB ].high;
1320         function( a, b );
1321         inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );
1322         if ( inputNumA == 0 ) ++inputNumB;
1323         inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );
1324     }
1325     endClock = clock();
1326     reportTime( count, endClock - startClock );
1327 
1328 }
1329 
1330 static const struct {
1331     bits16 high;
1332     bits64 low;
1333 } inputs_floatx80_pos[ numInputs_floatx80 ] = {
1334     { 0x403F, LIT64( 0xA9BE15A19C1E8B62 ) },
1335     { 0x0000, LIT64( 0x0000000000000000 ) },
1336     { 0x75A8, LIT64( 0xE59591E4788957A5 ) },
1337     { 0x3FFF, LIT64( 0xFFF0000000000040 ) },
1338     { 0x0CD8, LIT64( 0xFC000000000007FE ) },
1339     { 0x43BA, LIT64( 0x99A4000000000000 ) },
1340     { 0x3FFF, LIT64( 0x8000000000000000 ) },
1341     { 0x4081, LIT64( 0x94FBF1BCEB5545F0 ) },
1342     { 0x403E, LIT64( 0xFFF0000000002000 ) },
1343     { 0x3FFE, LIT64( 0xC860E3C75D224F28 ) },
1344     { 0x407E, LIT64( 0xFC00000FFFFFFFFE ) },
1345     { 0x737A, LIT64( 0x800000007FFDFFFE ) },
1346     { 0x4044, LIT64( 0xFFFFFF80000FFFFF ) },
1347     { 0x3BFE, LIT64( 0x8000040000001FFE ) },
1348     { 0x4002, LIT64( 0xFF80000000000020 ) },
1349     { 0x5E8D, LIT64( 0xFFFFFFFFFFE00004 ) },
1350     { 0x4004, LIT64( 0x8000000000003FFB ) },
1351     { 0x407F, LIT64( 0x800000000003FFFE ) },
1352     { 0x4000, LIT64( 0xA459EE6A5C16CA55 ) },
1353     { 0x0003, LIT64( 0xC42CBF7399AEEB94 ) },
1354     { 0x3F7F, LIT64( 0xF800000000000006 ) },
1355     { 0x407F, LIT64( 0xBF56BE8871F28FEA ) },
1356     { 0x407E, LIT64( 0xFFFF77FFFFFFFFFE ) },
1357     { 0x2DC9, LIT64( 0x8000000FFFFFFFDE ) },
1358     { 0x4001, LIT64( 0xEFF7FFFFFFFFFFFF ) },
1359     { 0x4001, LIT64( 0xBE84F30125C497A6 ) },
1360     { 0x406B, LIT64( 0xEFFFFFFFFFFFFFFF ) },
1361     { 0x4080, LIT64( 0xFFFFFFFFBFFFFFFF ) },
1362     { 0x07E9, LIT64( 0x81FFFFFFFFFFFBFF ) },
1363     { 0x263F, LIT64( 0x801FFFFFFEFFFFFE ) },
1364     { 0x403C, LIT64( 0x801FFFFFFFF7FFFF ) },
1365     { 0x4018, LIT64( 0x8000000000080003 ) }
1366 };
1367 
time_az_floatx80_pos(floatx80 function (floatx80))1368 static void time_az_floatx80_pos( floatx80 function( floatx80 ) )
1369 {
1370     clock_t startClock, endClock;
1371     int32 count, i;
1372     int8 inputNum;
1373     floatx80 a;
1374 
1375     count = 0;
1376     inputNum = 0;
1377     startClock = clock();
1378     do {
1379         for ( i = minIterations; i; --i ) {
1380             a.low = inputs_floatx80_pos[ inputNum ].low;
1381             a.high = inputs_floatx80_pos[ inputNum ].high;
1382             function( a );
1383             inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1384         }
1385         count += minIterations;
1386     } while ( clock() - startClock < CLOCKS_PER_SEC );
1387     inputNum = 0;
1388     startClock = clock();
1389     for ( i = count; i; --i ) {
1390         a.low = inputs_floatx80_pos[ inputNum ].low;
1391         a.high = inputs_floatx80_pos[ inputNum ].high;
1392         function( a );
1393         inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );
1394     }
1395     endClock = clock();
1396     reportTime( count, endClock - startClock );
1397 
1398 }
1399 
1400 #endif
1401 
1402 #ifdef FLOAT128
1403 
1404 enum {
1405     numInputs_float128 = 32
1406 };
1407 
1408 static const struct {
1409     bits64 high, low;
1410 } inputs_float128[ numInputs_float128 ] = {
1411     { LIT64( 0x3FDA200000100000 ), LIT64( 0x0000000000000000 ) },
1412     { LIT64( 0x3FFF000000000000 ), LIT64( 0x0000000000000000 ) },
1413     { LIT64( 0x85F14776190C8306 ), LIT64( 0xD8715F4E3D54BB92 ) },
1414     { LIT64( 0xF2B00000007FFFFF ), LIT64( 0xFFFFFFFFFFF7FFFF ) },
1415     { LIT64( 0x8000000000000000 ), LIT64( 0x0000000000000000 ) },
1416     { LIT64( 0xBFFFFFFFFFE00000 ), LIT64( 0x0000008000000000 ) },
1417     { LIT64( 0x407F1719CE722F3E ), LIT64( 0xDA6B3FE5FF29425B ) },
1418     { LIT64( 0x43FFFF8000000000 ), LIT64( 0x0000000000400000 ) },
1419     { LIT64( 0x401E000000000100 ), LIT64( 0x0000000000002000 ) },
1420     { LIT64( 0x3FFED71DACDA8E47 ), LIT64( 0x4860E3C75D224F28 ) },
1421     { LIT64( 0xBF7ECFC1E90647D1 ), LIT64( 0x7A124FE55623EE44 ) },
1422     { LIT64( 0x0DF7007FFFFFFFFF ), LIT64( 0xFFFFFFFFEFFFFFFF ) },
1423     { LIT64( 0x3FE5FFEFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFEFFF ) },
1424     { LIT64( 0x403FFFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFBFE ) },
1425     { LIT64( 0xBFFB2FBF7399AFEB ), LIT64( 0xA459EE6A5C16CA55 ) },
1426     { LIT64( 0xBDB8FFFFFFFFFFFC ), LIT64( 0x0000000000000400 ) },
1427     { LIT64( 0x3FC8FFDFFFFFFFFF ), LIT64( 0xFFFFFFFFF0000000 ) },
1428     { LIT64( 0x3FFBFFFFFFDFFFFF ), LIT64( 0xFFF8000000000000 ) },
1429     { LIT64( 0x407043C11737BE84 ), LIT64( 0xDDD58212ADC937F4 ) },
1430     { LIT64( 0x8001000000000000 ), LIT64( 0x0000001000000001 ) },
1431     { LIT64( 0xC036FFFFFFFFFFFF ), LIT64( 0xFE40000000000000 ) },
1432     { LIT64( 0x4002FFFFFE000002 ), LIT64( 0x0000000000000000 ) },
1433     { LIT64( 0x4000C3FEDE897773 ), LIT64( 0x326AC4FD8EFBE6DC ) },
1434     { LIT64( 0xBFFF0000000FFFFF ), LIT64( 0xFFFFFE0000000000 ) },
1435     { LIT64( 0x62C3E502146E426D ), LIT64( 0x43F3CAA0DC7DF1A0 ) },
1436     { LIT64( 0xB5CBD32E52BB570E ), LIT64( 0xBCC477CB11C6236C ) },
1437     { LIT64( 0xE228FFFFFFC00000 ), LIT64( 0x0000000000000000 ) },
1438     { LIT64( 0x3F80000000000000 ), LIT64( 0x0000000080000008 ) },
1439     { LIT64( 0xC1AFFFDFFFFFFFFF ), LIT64( 0xFFFC000000000000 ) },
1440     { LIT64( 0xC96F000000000000 ), LIT64( 0x00000001FFFBFFFF ) },
1441     { LIT64( 0x3DE09BFE7923A338 ), LIT64( 0xBCC8FBBD7CEC1F4F ) },
1442     { LIT64( 0x401CFFFFFFFFFFFF ), LIT64( 0xFFFFFFFEFFFFFF80 ) }
1443 };
1444 
time_a_float128_z_int32(int32 function (float128))1445 static void time_a_float128_z_int32( int32 function( float128 ) )
1446 {
1447     clock_t startClock, endClock;
1448     int32 count, i;
1449     int8 inputNum;
1450     float128 a;
1451 
1452     count = 0;
1453     inputNum = 0;
1454     startClock = clock();
1455     do {
1456         for ( i = minIterations; i; --i ) {
1457             a.low = inputs_float128[ inputNum ].low;
1458             a.high = inputs_float128[ inputNum ].high;
1459             function( a );
1460             inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1461         }
1462         count += minIterations;
1463     } while ( clock() - startClock < CLOCKS_PER_SEC );
1464     inputNum = 0;
1465     startClock = clock();
1466     for ( i = count; i; --i ) {
1467         a.low = inputs_float128[ inputNum ].low;
1468         a.high = inputs_float128[ inputNum ].high;
1469         function( a );
1470         inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1471     }
1472     endClock = clock();
1473     reportTime( count, endClock - startClock );
1474 
1475 }
1476 
time_a_float128_z_int64(int64 function (float128))1477 static void time_a_float128_z_int64( int64 function( float128 ) )
1478 {
1479     clock_t startClock, endClock;
1480     int32 count, i;
1481     int8 inputNum;
1482     float128 a;
1483 
1484     count = 0;
1485     inputNum = 0;
1486     startClock = clock();
1487     do {
1488         for ( i = minIterations; i; --i ) {
1489             a.low = inputs_float128[ inputNum ].low;
1490             a.high = inputs_float128[ inputNum ].high;
1491             function( a );
1492             inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1493         }
1494         count += minIterations;
1495     } while ( clock() - startClock < CLOCKS_PER_SEC );
1496     inputNum = 0;
1497     startClock = clock();
1498     for ( i = count; i; --i ) {
1499         a.low = inputs_float128[ inputNum ].low;
1500         a.high = inputs_float128[ inputNum ].high;
1501         function( a );
1502         inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1503     }
1504     endClock = clock();
1505     reportTime( count, endClock - startClock );
1506 
1507 }
1508 
time_a_float128_z_float32(float32 function (float128))1509 static void time_a_float128_z_float32( float32 function( float128 ) )
1510 {
1511     clock_t startClock, endClock;
1512     int32 count, i;
1513     int8 inputNum;
1514     float128 a;
1515 
1516     count = 0;
1517     inputNum = 0;
1518     startClock = clock();
1519     do {
1520         for ( i = minIterations; i; --i ) {
1521             a.low = inputs_float128[ inputNum ].low;
1522             a.high = inputs_float128[ inputNum ].high;
1523             function( a );
1524             inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1525         }
1526         count += minIterations;
1527     } while ( clock() - startClock < CLOCKS_PER_SEC );
1528     inputNum = 0;
1529     startClock = clock();
1530     for ( i = count; i; --i ) {
1531         a.low = inputs_float128[ inputNum ].low;
1532         a.high = inputs_float128[ inputNum ].high;
1533         function( a );
1534         inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1535     }
1536     endClock = clock();
1537     reportTime( count, endClock - startClock );
1538 
1539 }
1540 
time_a_float128_z_float64(float64 function (float128))1541 static void time_a_float128_z_float64( float64 function( float128 ) )
1542 {
1543     clock_t startClock, endClock;
1544     int32 count, i;
1545     int8 inputNum;
1546     float128 a;
1547 
1548     count = 0;
1549     inputNum = 0;
1550     startClock = clock();
1551     do {
1552         for ( i = minIterations; i; --i ) {
1553             a.low = inputs_float128[ inputNum ].low;
1554             a.high = inputs_float128[ inputNum ].high;
1555             function( a );
1556             inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1557         }
1558         count += minIterations;
1559     } while ( clock() - startClock < CLOCKS_PER_SEC );
1560     inputNum = 0;
1561     startClock = clock();
1562     for ( i = count; i; --i ) {
1563         a.low = inputs_float128[ inputNum ].low;
1564         a.high = inputs_float128[ inputNum ].high;
1565         function( a );
1566         inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1567     }
1568     endClock = clock();
1569     reportTime( count, endClock - startClock );
1570 
1571 }
1572 
1573 #ifdef FLOATX80
1574 
time_a_float128_z_floatx80(floatx80 function (float128))1575 static void time_a_float128_z_floatx80( floatx80 function( float128 ) )
1576 {
1577     clock_t startClock, endClock;
1578     int32 count, i;
1579     int8 inputNum;
1580     float128 a;
1581 
1582     count = 0;
1583     inputNum = 0;
1584     startClock = clock();
1585     do {
1586         for ( i = minIterations; i; --i ) {
1587             a.low = inputs_float128[ inputNum ].low;
1588             a.high = inputs_float128[ inputNum ].high;
1589             function( a );
1590             inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1591         }
1592         count += minIterations;
1593     } while ( clock() - startClock < CLOCKS_PER_SEC );
1594     inputNum = 0;
1595     startClock = clock();
1596     for ( i = count; i; --i ) {
1597         a.low = inputs_float128[ inputNum ].low;
1598         a.high = inputs_float128[ inputNum ].high;
1599         function( a );
1600         inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1601     }
1602     endClock = clock();
1603     reportTime( count, endClock - startClock );
1604 
1605 }
1606 
1607 #endif
1608 
time_az_float128(float128 function (float128))1609 static void time_az_float128( float128 function( float128 ) )
1610 {
1611     clock_t startClock, endClock;
1612     int32 count, i;
1613     int8 inputNum;
1614     float128 a;
1615 
1616     count = 0;
1617     inputNum = 0;
1618     startClock = clock();
1619     do {
1620         for ( i = minIterations; i; --i ) {
1621             a.low = inputs_float128[ inputNum ].low;
1622             a.high = inputs_float128[ inputNum ].high;
1623             function( a );
1624             inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1625         }
1626         count += minIterations;
1627     } while ( clock() - startClock < CLOCKS_PER_SEC );
1628     inputNum = 0;
1629     startClock = clock();
1630     for ( i = count; i; --i ) {
1631         a.low = inputs_float128[ inputNum ].low;
1632         a.high = inputs_float128[ inputNum ].high;
1633         function( a );
1634         inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1635     }
1636     endClock = clock();
1637     reportTime( count, endClock - startClock );
1638 
1639 }
1640 
time_ab_float128_z_flag(flag function (float128,float128))1641 static void time_ab_float128_z_flag( flag function( float128, float128 ) )
1642 {
1643     clock_t startClock, endClock;
1644     int32 count, i;
1645     int8 inputNumA, inputNumB;
1646     float128 a, b;
1647 
1648     count = 0;
1649     inputNumA = 0;
1650     inputNumB = 0;
1651     startClock = clock();
1652     do {
1653         for ( i = minIterations; i; --i ) {
1654             a.low = inputs_float128[ inputNumA ].low;
1655             a.high = inputs_float128[ inputNumA ].high;
1656             b.low = inputs_float128[ inputNumB ].low;
1657             b.high = inputs_float128[ inputNumB ].high;
1658             function( a, b );
1659             inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1660             if ( inputNumA == 0 ) ++inputNumB;
1661             inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1662         }
1663         count += minIterations;
1664     } while ( clock() - startClock < CLOCKS_PER_SEC );
1665     inputNumA = 0;
1666     inputNumB = 0;
1667     startClock = clock();
1668     for ( i = count; i; --i ) {
1669         a.low = inputs_float128[ inputNumA ].low;
1670         a.high = inputs_float128[ inputNumA ].high;
1671         b.low = inputs_float128[ inputNumB ].low;
1672         b.high = inputs_float128[ inputNumB ].high;
1673         function( a, b );
1674         inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1675         if ( inputNumA == 0 ) ++inputNumB;
1676         inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1677     }
1678     endClock = clock();
1679     reportTime( count, endClock - startClock );
1680 
1681 }
1682 
time_abz_float128(float128 function (float128,float128))1683 static void time_abz_float128( float128 function( float128, float128 ) )
1684 {
1685     clock_t startClock, endClock;
1686     int32 count, i;
1687     int8 inputNumA, inputNumB;
1688     float128 a, b;
1689 
1690     count = 0;
1691     inputNumA = 0;
1692     inputNumB = 0;
1693     startClock = clock();
1694     do {
1695         for ( i = minIterations; i; --i ) {
1696             a.low = inputs_float128[ inputNumA ].low;
1697             a.high = inputs_float128[ inputNumA ].high;
1698             b.low = inputs_float128[ inputNumB ].low;
1699             b.high = inputs_float128[ inputNumB ].high;
1700             function( a, b );
1701             inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1702             if ( inputNumA == 0 ) ++inputNumB;
1703             inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1704         }
1705         count += minIterations;
1706     } while ( clock() - startClock < CLOCKS_PER_SEC );
1707     inputNumA = 0;
1708     inputNumB = 0;
1709     startClock = clock();
1710     for ( i = count; i; --i ) {
1711         a.low = inputs_float128[ inputNumA ].low;
1712         a.high = inputs_float128[ inputNumA ].high;
1713         b.low = inputs_float128[ inputNumB ].low;
1714         b.high = inputs_float128[ inputNumB ].high;
1715         function( a, b );
1716         inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );
1717         if ( inputNumA == 0 ) ++inputNumB;
1718         inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );
1719     }
1720     endClock = clock();
1721     reportTime( count, endClock - startClock );
1722 
1723 }
1724 
1725 static const struct {
1726     bits64 high, low;
1727 } inputs_float128_pos[ numInputs_float128 ] = {
1728     { LIT64( 0x3FDA200000100000 ), LIT64( 0x0000000000000000 ) },
1729     { LIT64( 0x3FFF000000000000 ), LIT64( 0x0000000000000000 ) },
1730     { LIT64( 0x05F14776190C8306 ), LIT64( 0xD8715F4E3D54BB92 ) },
1731     { LIT64( 0x72B00000007FFFFF ), LIT64( 0xFFFFFFFFFFF7FFFF ) },
1732     { LIT64( 0x0000000000000000 ), LIT64( 0x0000000000000000 ) },
1733     { LIT64( 0x3FFFFFFFFFE00000 ), LIT64( 0x0000008000000000 ) },
1734     { LIT64( 0x407F1719CE722F3E ), LIT64( 0xDA6B3FE5FF29425B ) },
1735     { LIT64( 0x43FFFF8000000000 ), LIT64( 0x0000000000400000 ) },
1736     { LIT64( 0x401E000000000100 ), LIT64( 0x0000000000002000 ) },
1737     { LIT64( 0x3FFED71DACDA8E47 ), LIT64( 0x4860E3C75D224F28 ) },
1738     { LIT64( 0x3F7ECFC1E90647D1 ), LIT64( 0x7A124FE55623EE44 ) },
1739     { LIT64( 0x0DF7007FFFFFFFFF ), LIT64( 0xFFFFFFFFEFFFFFFF ) },
1740     { LIT64( 0x3FE5FFEFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFEFFF ) },
1741     { LIT64( 0x403FFFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFBFE ) },
1742     { LIT64( 0x3FFB2FBF7399AFEB ), LIT64( 0xA459EE6A5C16CA55 ) },
1743     { LIT64( 0x3DB8FFFFFFFFFFFC ), LIT64( 0x0000000000000400 ) },
1744     { LIT64( 0x3FC8FFDFFFFFFFFF ), LIT64( 0xFFFFFFFFF0000000 ) },
1745     { LIT64( 0x3FFBFFFFFFDFFFFF ), LIT64( 0xFFF8000000000000 ) },
1746     { LIT64( 0x407043C11737BE84 ), LIT64( 0xDDD58212ADC937F4 ) },
1747     { LIT64( 0x0001000000000000 ), LIT64( 0x0000001000000001 ) },
1748     { LIT64( 0x4036FFFFFFFFFFFF ), LIT64( 0xFE40000000000000 ) },
1749     { LIT64( 0x4002FFFFFE000002 ), LIT64( 0x0000000000000000 ) },
1750     { LIT64( 0x4000C3FEDE897773 ), LIT64( 0x326AC4FD8EFBE6DC ) },
1751     { LIT64( 0x3FFF0000000FFFFF ), LIT64( 0xFFFFFE0000000000 ) },
1752     { LIT64( 0x62C3E502146E426D ), LIT64( 0x43F3CAA0DC7DF1A0 ) },
1753     { LIT64( 0x35CBD32E52BB570E ), LIT64( 0xBCC477CB11C6236C ) },
1754     { LIT64( 0x6228FFFFFFC00000 ), LIT64( 0x0000000000000000 ) },
1755     { LIT64( 0x3F80000000000000 ), LIT64( 0x0000000080000008 ) },
1756     { LIT64( 0x41AFFFDFFFFFFFFF ), LIT64( 0xFFFC000000000000 ) },
1757     { LIT64( 0x496F000000000000 ), LIT64( 0x00000001FFFBFFFF ) },
1758     { LIT64( 0x3DE09BFE7923A338 ), LIT64( 0xBCC8FBBD7CEC1F4F ) },
1759     { LIT64( 0x401CFFFFFFFFFFFF ), LIT64( 0xFFFFFFFEFFFFFF80 ) }
1760 };
1761 
time_az_float128_pos(float128 function (float128))1762 static void time_az_float128_pos( float128 function( float128 ) )
1763 {
1764     clock_t startClock, endClock;
1765     int32 count, i;
1766     int8 inputNum;
1767     float128 a;
1768 
1769     count = 0;
1770     inputNum = 0;
1771     startClock = clock();
1772     do {
1773         for ( i = minIterations; i; --i ) {
1774             a.low = inputs_float128_pos[ inputNum ].low;
1775             a.high = inputs_float128_pos[ inputNum ].high;
1776             function( a );
1777             inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1778         }
1779         count += minIterations;
1780     } while ( clock() - startClock < CLOCKS_PER_SEC );
1781     inputNum = 0;
1782     startClock = clock();
1783     for ( i = count; i; --i ) {
1784         a.low = inputs_float128_pos[ inputNum ].low;
1785         a.high = inputs_float128_pos[ inputNum ].high;
1786         function( a );
1787         inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );
1788     }
1789     endClock = clock();
1790     reportTime( count, endClock - startClock );
1791 
1792 }
1793 
1794 #endif
1795 
1796 enum {
1797     INT32_TO_FLOAT32 = 1,
1798     INT32_TO_FLOAT64,
1799 #ifdef FLOATX80
1800     INT32_TO_FLOATX80,
1801 #endif
1802 #ifdef FLOAT128
1803     INT32_TO_FLOAT128,
1804 #endif
1805     INT64_TO_FLOAT32,
1806     INT64_TO_FLOAT64,
1807 #ifdef FLOATX80
1808     INT64_TO_FLOATX80,
1809 #endif
1810 #ifdef FLOAT128
1811     INT64_TO_FLOAT128,
1812 #endif
1813     FLOAT32_TO_INT32,
1814     FLOAT32_TO_INT32_ROUND_TO_ZERO,
1815     FLOAT32_TO_INT64,
1816     FLOAT32_TO_INT64_ROUND_TO_ZERO,
1817     FLOAT32_TO_FLOAT64,
1818 #ifdef FLOATX80
1819     FLOAT32_TO_FLOATX80,
1820 #endif
1821 #ifdef FLOAT128
1822     FLOAT32_TO_FLOAT128,
1823 #endif
1824     FLOAT32_ROUND_TO_INT,
1825     FLOAT32_ADD,
1826     FLOAT32_SUB,
1827     FLOAT32_MUL,
1828     FLOAT32_DIV,
1829     FLOAT32_REM,
1830     FLOAT32_SQRT,
1831     FLOAT32_EQ,
1832     FLOAT32_LE,
1833     FLOAT32_LT,
1834     FLOAT32_EQ_SIGNALING,
1835     FLOAT32_LE_QUIET,
1836     FLOAT32_LT_QUIET,
1837     FLOAT64_TO_INT32,
1838     FLOAT64_TO_INT32_ROUND_TO_ZERO,
1839     FLOAT64_TO_INT64,
1840     FLOAT64_TO_INT64_ROUND_TO_ZERO,
1841     FLOAT64_TO_FLOAT32,
1842 #ifdef FLOATX80
1843     FLOAT64_TO_FLOATX80,
1844 #endif
1845 #ifdef FLOAT128
1846     FLOAT64_TO_FLOAT128,
1847 #endif
1848     FLOAT64_ROUND_TO_INT,
1849     FLOAT64_ADD,
1850     FLOAT64_SUB,
1851     FLOAT64_MUL,
1852     FLOAT64_DIV,
1853     FLOAT64_REM,
1854     FLOAT64_SQRT,
1855     FLOAT64_EQ,
1856     FLOAT64_LE,
1857     FLOAT64_LT,
1858     FLOAT64_EQ_SIGNALING,
1859     FLOAT64_LE_QUIET,
1860     FLOAT64_LT_QUIET,
1861 #ifdef FLOATX80
1862     FLOATX80_TO_INT32,
1863     FLOATX80_TO_INT32_ROUND_TO_ZERO,
1864     FLOATX80_TO_INT64,
1865     FLOATX80_TO_INT64_ROUND_TO_ZERO,
1866     FLOATX80_TO_FLOAT32,
1867     FLOATX80_TO_FLOAT64,
1868 #ifdef FLOAT128
1869     FLOATX80_TO_FLOAT128,
1870 #endif
1871     FLOATX80_ROUND_TO_INT,
1872     FLOATX80_ADD,
1873     FLOATX80_SUB,
1874     FLOATX80_MUL,
1875     FLOATX80_DIV,
1876     FLOATX80_REM,
1877     FLOATX80_SQRT,
1878     FLOATX80_EQ,
1879     FLOATX80_LE,
1880     FLOATX80_LT,
1881     FLOATX80_EQ_SIGNALING,
1882     FLOATX80_LE_QUIET,
1883     FLOATX80_LT_QUIET,
1884 #endif
1885 #ifdef FLOAT128
1886     FLOAT128_TO_INT32,
1887     FLOAT128_TO_INT32_ROUND_TO_ZERO,
1888     FLOAT128_TO_INT64,
1889     FLOAT128_TO_INT64_ROUND_TO_ZERO,
1890     FLOAT128_TO_FLOAT32,
1891     FLOAT128_TO_FLOAT64,
1892 #ifdef FLOATX80
1893     FLOAT128_TO_FLOATX80,
1894 #endif
1895     FLOAT128_ROUND_TO_INT,
1896     FLOAT128_ADD,
1897     FLOAT128_SUB,
1898     FLOAT128_MUL,
1899     FLOAT128_DIV,
1900     FLOAT128_REM,
1901     FLOAT128_SQRT,
1902     FLOAT128_EQ,
1903     FLOAT128_LE,
1904     FLOAT128_LT,
1905     FLOAT128_EQ_SIGNALING,
1906     FLOAT128_LE_QUIET,
1907     FLOAT128_LT_QUIET,
1908 #endif
1909     NUM_FUNCTIONS
1910 };
1911 
1912 static struct {
1913     char *name;
1914     int8 numInputs;
1915     flag roundingPrecision, roundingMode;
1916     flag tininessMode, tininessModeAtReducedPrecision;
1917 } functions[ NUM_FUNCTIONS ] = {
1918     { 0, 0, 0, 0, 0, 0 },
1919     { "int32_to_float32",                1, FALSE, TRUE,  FALSE, FALSE },
1920     { "int32_to_float64",                1, FALSE, FALSE, FALSE, FALSE },
1921 #ifdef FLOATX80
1922     { "int32_to_floatx80",               1, FALSE, FALSE, FALSE, FALSE },
1923 #endif
1924 #ifdef FLOAT128
1925     { "int32_to_float128",               1, FALSE, FALSE, FALSE, FALSE },
1926 #endif
1927     { "int64_to_float32",                1, FALSE, TRUE,  FALSE, FALSE },
1928     { "int64_to_float64",                1, FALSE, TRUE,  FALSE, FALSE },
1929 #ifdef FLOATX80
1930     { "int64_to_floatx80",               1, FALSE, FALSE, FALSE, FALSE },
1931 #endif
1932 #ifdef FLOAT128
1933     { "int64_to_float128",               1, FALSE, FALSE, FALSE, FALSE },
1934 #endif
1935     { "float32_to_int32",                1, FALSE, TRUE,  FALSE, FALSE },
1936     { "float32_to_int32_round_to_zero",  1, FALSE, FALSE, FALSE, FALSE },
1937     { "float32_to_int64",                1, FALSE, TRUE,  FALSE, FALSE },
1938     { "float32_to_int64_round_to_zero",  1, FALSE, FALSE, FALSE, FALSE },
1939     { "float32_to_float64",              1, FALSE, FALSE, FALSE, FALSE },
1940 #ifdef FLOATX80
1941     { "float32_to_floatx80",             1, FALSE, FALSE, FALSE, FALSE },
1942 #endif
1943 #ifdef FLOAT128
1944     { "float32_to_float128",             1, FALSE, FALSE, FALSE, FALSE },
1945 #endif
1946     { "float32_round_to_int",            1, FALSE, TRUE,  FALSE, FALSE },
1947     { "float32_add",                     2, FALSE, TRUE,  FALSE, FALSE },
1948     { "float32_sub",                     2, FALSE, TRUE,  FALSE, FALSE },
1949     { "float32_mul",                     2, FALSE, TRUE,  TRUE,  FALSE },
1950     { "float32_div",                     2, FALSE, TRUE,  FALSE, FALSE },
1951     { "float32_rem",                     2, FALSE, FALSE, FALSE, FALSE },
1952     { "float32_sqrt",                    1, FALSE, TRUE,  FALSE, FALSE },
1953     { "float32_eq",                      2, FALSE, FALSE, FALSE, FALSE },
1954     { "float32_le",                      2, FALSE, FALSE, FALSE, FALSE },
1955     { "float32_lt",                      2, FALSE, FALSE, FALSE, FALSE },
1956     { "float32_eq_signaling",            2, FALSE, FALSE, FALSE, FALSE },
1957     { "float32_le_quiet",                2, FALSE, FALSE, FALSE, FALSE },
1958     { "float32_lt_quiet",                2, FALSE, FALSE, FALSE, FALSE },
1959     { "float64_to_int32",                1, FALSE, TRUE,  FALSE, FALSE },
1960     { "float64_to_int32_round_to_zero",  1, FALSE, FALSE, FALSE, FALSE },
1961     { "float64_to_int64",                1, FALSE, TRUE,  FALSE, FALSE },
1962     { "float64_to_int64_round_to_zero",  1, FALSE, FALSE, FALSE, FALSE },
1963     { "float64_to_float32",              1, FALSE, TRUE,  TRUE,  FALSE },
1964 #ifdef FLOATX80
1965     { "float64_to_floatx80",             1, FALSE, FALSE, FALSE, FALSE },
1966 #endif
1967 #ifdef FLOAT128
1968     { "float64_to_float128",             1, FALSE, FALSE, FALSE, FALSE },
1969 #endif
1970     { "float64_round_to_int",            1, FALSE, TRUE,  FALSE, FALSE },
1971     { "float64_add",                     2, FALSE, TRUE,  FALSE, FALSE },
1972     { "float64_sub",                     2, FALSE, TRUE,  FALSE, FALSE },
1973     { "float64_mul",                     2, FALSE, TRUE,  TRUE,  FALSE },
1974     { "float64_div",                     2, FALSE, TRUE,  FALSE, FALSE },
1975     { "float64_rem",                     2, FALSE, FALSE, FALSE, FALSE },
1976     { "float64_sqrt",                    1, FALSE, TRUE,  FALSE, FALSE },
1977     { "float64_eq",                      2, FALSE, FALSE, FALSE, FALSE },
1978     { "float64_le",                      2, FALSE, FALSE, FALSE, FALSE },
1979     { "float64_lt",                      2, FALSE, FALSE, FALSE, FALSE },
1980     { "float64_eq_signaling",            2, FALSE, FALSE, FALSE, FALSE },
1981     { "float64_le_quiet",                2, FALSE, FALSE, FALSE, FALSE },
1982     { "float64_lt_quiet",                2, FALSE, FALSE, FALSE, FALSE },
1983 #ifdef FLOATX80
1984     { "floatx80_to_int32",               1, FALSE, TRUE,  FALSE, FALSE },
1985     { "floatx80_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1986     { "floatx80_to_int64",               1, FALSE, TRUE,  FALSE, FALSE },
1987     { "floatx80_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
1988     { "floatx80_to_float32",             1, FALSE, TRUE,  TRUE,  FALSE },
1989     { "floatx80_to_float64",             1, FALSE, TRUE,  TRUE,  FALSE },
1990 #ifdef FLOAT128
1991     { "floatx80_to_float128",            1, FALSE, FALSE, FALSE, FALSE },
1992 #endif
1993     { "floatx80_round_to_int",           1, FALSE, TRUE,  FALSE, FALSE },
1994     { "floatx80_add",                    2, TRUE,  TRUE,  FALSE, TRUE  },
1995     { "floatx80_sub",                    2, TRUE,  TRUE,  FALSE, TRUE  },
1996     { "floatx80_mul",                    2, TRUE,  TRUE,  TRUE,  TRUE  },
1997     { "floatx80_div",                    2, TRUE,  TRUE,  FALSE, TRUE  },
1998     { "floatx80_rem",                    2, FALSE, FALSE, FALSE, FALSE },
1999     { "floatx80_sqrt",                   1, TRUE,  TRUE,  FALSE, FALSE },
2000     { "floatx80_eq",                     2, FALSE, FALSE, FALSE, FALSE },
2001     { "floatx80_le",                     2, FALSE, FALSE, FALSE, FALSE },
2002     { "floatx80_lt",                     2, FALSE, FALSE, FALSE, FALSE },
2003     { "floatx80_eq_signaling",           2, FALSE, FALSE, FALSE, FALSE },
2004     { "floatx80_le_quiet",               2, FALSE, FALSE, FALSE, FALSE },
2005     { "floatx80_lt_quiet",               2, FALSE, FALSE, FALSE, FALSE },
2006 #endif
2007 #ifdef FLOAT128
2008     { "float128_to_int32",               1, FALSE, TRUE,  FALSE, FALSE },
2009     { "float128_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
2010     { "float128_to_int64",               1, FALSE, TRUE,  FALSE, FALSE },
2011     { "float128_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },
2012     { "float128_to_float32",             1, FALSE, TRUE,  TRUE,  FALSE },
2013     { "float128_to_float64",             1, FALSE, TRUE,  TRUE,  FALSE },
2014 #ifdef FLOATX80
2015     { "float128_to_floatx80",            1, FALSE, TRUE,  TRUE,  FALSE },
2016 #endif
2017     { "float128_round_to_int",           1, FALSE, TRUE,  FALSE, FALSE },
2018     { "float128_add",                    2, FALSE, TRUE,  FALSE, FALSE },
2019     { "float128_sub",                    2, FALSE, TRUE,  FALSE, FALSE },
2020     { "float128_mul",                    2, FALSE, TRUE,  TRUE,  FALSE },
2021     { "float128_div",                    2, FALSE, TRUE,  FALSE, FALSE },
2022     { "float128_rem",                    2, FALSE, FALSE, FALSE, FALSE },
2023     { "float128_sqrt",                   1, FALSE, TRUE,  FALSE, FALSE },
2024     { "float128_eq",                     2, FALSE, FALSE, FALSE, FALSE },
2025     { "float128_le",                     2, FALSE, FALSE, FALSE, FALSE },
2026     { "float128_lt",                     2, FALSE, FALSE, FALSE, FALSE },
2027     { "float128_eq_signaling",           2, FALSE, FALSE, FALSE, FALSE },
2028     { "float128_le_quiet",               2, FALSE, FALSE, FALSE, FALSE },
2029     { "float128_lt_quiet",               2, FALSE, FALSE, FALSE, FALSE },
2030 #endif
2031 };
2032 
2033 enum {
2034     ROUND_NEAREST_EVEN = 1,
2035     ROUND_TO_ZERO,
2036     ROUND_DOWN,
2037     ROUND_UP,
2038     NUM_ROUNDINGMODES
2039 };
2040 enum {
2041     TININESS_BEFORE_ROUNDING = 1,
2042     TININESS_AFTER_ROUNDING,
2043     NUM_TININESSMODES
2044 };
2045 
2046 static void
timeFunctionVariety(uint8 functionCode,int8 roundingPrecision,int8 roundingMode,int8 tininessMode)2047  timeFunctionVariety(
2048      uint8 functionCode,
2049      int8 roundingPrecision,
2050      int8 roundingMode,
2051      int8 tininessMode
2052  )
2053 {
2054     uint8 roundingCode;
2055     int8 tininessCode;
2056 
2057     functionName = functions[ functionCode ].name;
2058     if ( roundingPrecision == 32 ) {
2059         roundingPrecisionName = "32";
2060     }
2061     else if ( roundingPrecision == 64 ) {
2062         roundingPrecisionName = "64";
2063     }
2064     else if ( roundingPrecision == 80 ) {
2065         roundingPrecisionName = "80";
2066     }
2067     else {
2068         roundingPrecisionName = NULL;
2069     }
2070 #ifdef FLOATX80
2071     floatx80_rounding_precision = roundingPrecision;
2072 #endif
2073     switch ( roundingMode ) {
2074      case 0:
2075         roundingModeName = NULL;
2076         roundingCode = float_round_nearest_even;
2077         break;
2078      case ROUND_NEAREST_EVEN:
2079         roundingModeName = "nearest_even";
2080         roundingCode = float_round_nearest_even;
2081         break;
2082      case ROUND_TO_ZERO:
2083         roundingModeName = "to_zero";
2084         roundingCode = float_round_to_zero;
2085         break;
2086      case ROUND_DOWN:
2087         roundingModeName = "down";
2088         roundingCode = float_round_down;
2089         break;
2090      case ROUND_UP:
2091         roundingModeName = "up";
2092         roundingCode = float_round_up;
2093         break;
2094     }
2095     float_rounding_mode = roundingCode;
2096     switch ( tininessMode ) {
2097      case 0:
2098         tininessModeName = NULL;
2099         tininessCode = float_tininess_after_rounding;
2100         break;
2101      case TININESS_BEFORE_ROUNDING:
2102         tininessModeName = "before";
2103         tininessCode = float_tininess_before_rounding;
2104         break;
2105      case TININESS_AFTER_ROUNDING:
2106         tininessModeName = "after";
2107         tininessCode = float_tininess_after_rounding;
2108         break;
2109     }
2110     float_detect_tininess = tininessCode;
2111     switch ( functionCode ) {
2112      case INT32_TO_FLOAT32:
2113         time_a_int32_z_float32( int32_to_float32 );
2114         break;
2115      case INT32_TO_FLOAT64:
2116         time_a_int32_z_float64( int32_to_float64 );
2117         break;
2118 #ifdef FLOATX80
2119      case INT32_TO_FLOATX80:
2120         time_a_int32_z_floatx80( int32_to_floatx80 );
2121         break;
2122 #endif
2123 #ifdef FLOAT128
2124      case INT32_TO_FLOAT128:
2125         time_a_int32_z_float128( int32_to_float128 );
2126         break;
2127 #endif
2128      case INT64_TO_FLOAT32:
2129         time_a_int64_z_float32( int64_to_float32 );
2130         break;
2131      case INT64_TO_FLOAT64:
2132         time_a_int64_z_float64( int64_to_float64 );
2133         break;
2134 #ifdef FLOATX80
2135      case INT64_TO_FLOATX80:
2136         time_a_int64_z_floatx80( int64_to_floatx80 );
2137         break;
2138 #endif
2139 #ifdef FLOAT128
2140      case INT64_TO_FLOAT128:
2141         time_a_int64_z_float128( int64_to_float128 );
2142         break;
2143 #endif
2144      case FLOAT32_TO_INT32:
2145         time_a_float32_z_int32( float32_to_int32 );
2146         break;
2147      case FLOAT32_TO_INT32_ROUND_TO_ZERO:
2148         time_a_float32_z_int32( float32_to_int32_round_to_zero );
2149         break;
2150      case FLOAT32_TO_INT64:
2151         time_a_float32_z_int64( float32_to_int64 );
2152         break;
2153      case FLOAT32_TO_INT64_ROUND_TO_ZERO:
2154         time_a_float32_z_int64( float32_to_int64_round_to_zero );
2155         break;
2156      case FLOAT32_TO_FLOAT64:
2157         time_a_float32_z_float64( float32_to_float64 );
2158         break;
2159 #ifdef FLOATX80
2160      case FLOAT32_TO_FLOATX80:
2161         time_a_float32_z_floatx80( float32_to_floatx80 );
2162         break;
2163 #endif
2164 #ifdef FLOAT128
2165      case FLOAT32_TO_FLOAT128:
2166         time_a_float32_z_float128( float32_to_float128 );
2167         break;
2168 #endif
2169      case FLOAT32_ROUND_TO_INT:
2170         time_az_float32( float32_round_to_int );
2171         break;
2172      case FLOAT32_ADD:
2173         time_abz_float32( float32_add );
2174         break;
2175      case FLOAT32_SUB:
2176         time_abz_float32( float32_sub );
2177         break;
2178      case FLOAT32_MUL:
2179         time_abz_float32( float32_mul );
2180         break;
2181      case FLOAT32_DIV:
2182         time_abz_float32( float32_div );
2183         break;
2184      case FLOAT32_REM:
2185         time_abz_float32( float32_rem );
2186         break;
2187      case FLOAT32_SQRT:
2188         time_az_float32_pos( float32_sqrt );
2189         break;
2190      case FLOAT32_EQ:
2191         time_ab_float32_z_flag( float32_eq );
2192         break;
2193      case FLOAT32_LE:
2194         time_ab_float32_z_flag( float32_le );
2195         break;
2196      case FLOAT32_LT:
2197         time_ab_float32_z_flag( float32_lt );
2198         break;
2199      case FLOAT32_EQ_SIGNALING:
2200         time_ab_float32_z_flag( float32_eq_signaling );
2201         break;
2202      case FLOAT32_LE_QUIET:
2203         time_ab_float32_z_flag( float32_le_quiet );
2204         break;
2205      case FLOAT32_LT_QUIET:
2206         time_ab_float32_z_flag( float32_lt_quiet );
2207         break;
2208      case FLOAT64_TO_INT32:
2209         time_a_float64_z_int32( float64_to_int32 );
2210         break;
2211      case FLOAT64_TO_INT32_ROUND_TO_ZERO:
2212         time_a_float64_z_int32( float64_to_int32_round_to_zero );
2213         break;
2214      case FLOAT64_TO_INT64:
2215         time_a_float64_z_int64( float64_to_int64 );
2216         break;
2217      case FLOAT64_TO_INT64_ROUND_TO_ZERO:
2218         time_a_float64_z_int64( float64_to_int64_round_to_zero );
2219         break;
2220      case FLOAT64_TO_FLOAT32:
2221         time_a_float64_z_float32( float64_to_float32 );
2222         break;
2223 #ifdef FLOATX80
2224      case FLOAT64_TO_FLOATX80:
2225         time_a_float64_z_floatx80( float64_to_floatx80 );
2226         break;
2227 #endif
2228 #ifdef FLOAT128
2229      case FLOAT64_TO_FLOAT128:
2230         time_a_float64_z_float128( float64_to_float128 );
2231         break;
2232 #endif
2233      case FLOAT64_ROUND_TO_INT:
2234         time_az_float64( float64_round_to_int );
2235         break;
2236      case FLOAT64_ADD:
2237         time_abz_float64( float64_add );
2238         break;
2239      case FLOAT64_SUB:
2240         time_abz_float64( float64_sub );
2241         break;
2242      case FLOAT64_MUL:
2243         time_abz_float64( float64_mul );
2244         break;
2245      case FLOAT64_DIV:
2246         time_abz_float64( float64_div );
2247         break;
2248      case FLOAT64_REM:
2249         time_abz_float64( float64_rem );
2250         break;
2251      case FLOAT64_SQRT:
2252         time_az_float64_pos( float64_sqrt );
2253         break;
2254      case FLOAT64_EQ:
2255         time_ab_float64_z_flag( float64_eq );
2256         break;
2257      case FLOAT64_LE:
2258         time_ab_float64_z_flag( float64_le );
2259         break;
2260      case FLOAT64_LT:
2261         time_ab_float64_z_flag( float64_lt );
2262         break;
2263      case FLOAT64_EQ_SIGNALING:
2264         time_ab_float64_z_flag( float64_eq_signaling );
2265         break;
2266      case FLOAT64_LE_QUIET:
2267         time_ab_float64_z_flag( float64_le_quiet );
2268         break;
2269      case FLOAT64_LT_QUIET:
2270         time_ab_float64_z_flag( float64_lt_quiet );
2271         break;
2272 #ifdef FLOATX80
2273      case FLOATX80_TO_INT32:
2274         time_a_floatx80_z_int32( floatx80_to_int32 );
2275         break;
2276      case FLOATX80_TO_INT32_ROUND_TO_ZERO:
2277         time_a_floatx80_z_int32( floatx80_to_int32_round_to_zero );
2278         break;
2279      case FLOATX80_TO_INT64:
2280         time_a_floatx80_z_int64( floatx80_to_int64 );
2281         break;
2282      case FLOATX80_TO_INT64_ROUND_TO_ZERO:
2283         time_a_floatx80_z_int64( floatx80_to_int64_round_to_zero );
2284         break;
2285      case FLOATX80_TO_FLOAT32:
2286         time_a_floatx80_z_float32( floatx80_to_float32 );
2287         break;
2288      case FLOATX80_TO_FLOAT64:
2289         time_a_floatx80_z_float64( floatx80_to_float64 );
2290         break;
2291 #ifdef FLOAT128
2292      case FLOATX80_TO_FLOAT128:
2293         time_a_floatx80_z_float128( floatx80_to_float128 );
2294         break;
2295 #endif
2296      case FLOATX80_ROUND_TO_INT:
2297         time_az_floatx80( floatx80_round_to_int );
2298         break;
2299      case FLOATX80_ADD:
2300         time_abz_floatx80( floatx80_add );
2301         break;
2302      case FLOATX80_SUB:
2303         time_abz_floatx80( floatx80_sub );
2304         break;
2305      case FLOATX80_MUL:
2306         time_abz_floatx80( floatx80_mul );
2307         break;
2308      case FLOATX80_DIV:
2309         time_abz_floatx80( floatx80_div );
2310         break;
2311      case FLOATX80_REM:
2312         time_abz_floatx80( floatx80_rem );
2313         break;
2314      case FLOATX80_SQRT:
2315         time_az_floatx80_pos( floatx80_sqrt );
2316         break;
2317      case FLOATX80_EQ:
2318         time_ab_floatx80_z_flag( floatx80_eq );
2319         break;
2320      case FLOATX80_LE:
2321         time_ab_floatx80_z_flag( floatx80_le );
2322         break;
2323      case FLOATX80_LT:
2324         time_ab_floatx80_z_flag( floatx80_lt );
2325         break;
2326      case FLOATX80_EQ_SIGNALING:
2327         time_ab_floatx80_z_flag( floatx80_eq_signaling );
2328         break;
2329      case FLOATX80_LE_QUIET:
2330         time_ab_floatx80_z_flag( floatx80_le_quiet );
2331         break;
2332      case FLOATX80_LT_QUIET:
2333         time_ab_floatx80_z_flag( floatx80_lt_quiet );
2334         break;
2335 #endif
2336 #ifdef FLOAT128
2337      case FLOAT128_TO_INT32:
2338         time_a_float128_z_int32( float128_to_int32 );
2339         break;
2340      case FLOAT128_TO_INT32_ROUND_TO_ZERO:
2341         time_a_float128_z_int32( float128_to_int32_round_to_zero );
2342         break;
2343      case FLOAT128_TO_INT64:
2344         time_a_float128_z_int64( float128_to_int64 );
2345         break;
2346      case FLOAT128_TO_INT64_ROUND_TO_ZERO:
2347         time_a_float128_z_int64( float128_to_int64_round_to_zero );
2348         break;
2349      case FLOAT128_TO_FLOAT32:
2350         time_a_float128_z_float32( float128_to_float32 );
2351         break;
2352      case FLOAT128_TO_FLOAT64:
2353         time_a_float128_z_float64( float128_to_float64 );
2354         break;
2355 #ifdef FLOATX80
2356      case FLOAT128_TO_FLOATX80:
2357         time_a_float128_z_floatx80( float128_to_floatx80 );
2358         break;
2359 #endif
2360      case FLOAT128_ROUND_TO_INT:
2361         time_az_float128( float128_round_to_int );
2362         break;
2363      case FLOAT128_ADD:
2364         time_abz_float128( float128_add );
2365         break;
2366      case FLOAT128_SUB:
2367         time_abz_float128( float128_sub );
2368         break;
2369      case FLOAT128_MUL:
2370         time_abz_float128( float128_mul );
2371         break;
2372      case FLOAT128_DIV:
2373         time_abz_float128( float128_div );
2374         break;
2375      case FLOAT128_REM:
2376         time_abz_float128( float128_rem );
2377         break;
2378      case FLOAT128_SQRT:
2379         time_az_float128_pos( float128_sqrt );
2380         break;
2381      case FLOAT128_EQ:
2382         time_ab_float128_z_flag( float128_eq );
2383         break;
2384      case FLOAT128_LE:
2385         time_ab_float128_z_flag( float128_le );
2386         break;
2387      case FLOAT128_LT:
2388         time_ab_float128_z_flag( float128_lt );
2389         break;
2390      case FLOAT128_EQ_SIGNALING:
2391         time_ab_float128_z_flag( float128_eq_signaling );
2392         break;
2393      case FLOAT128_LE_QUIET:
2394         time_ab_float128_z_flag( float128_le_quiet );
2395         break;
2396      case FLOAT128_LT_QUIET:
2397         time_ab_float128_z_flag( float128_lt_quiet );
2398         break;
2399 #endif
2400     }
2401 
2402 }
2403 
2404 static void
timeFunction(uint8 functionCode,int8 roundingPrecisionIn,int8 roundingModeIn,int8 tininessModeIn)2405  timeFunction(
2406      uint8 functionCode,
2407      int8 roundingPrecisionIn,
2408      int8 roundingModeIn,
2409      int8 tininessModeIn
2410  )
2411 {
2412     int8 roundingPrecision, roundingMode, tininessMode;
2413 
2414     roundingPrecision = 32;
2415     for (;;) {
2416         if ( ! functions[ functionCode ].roundingPrecision ) {
2417             roundingPrecision = 0;
2418         }
2419         else if ( roundingPrecisionIn ) {
2420             roundingPrecision = roundingPrecisionIn;
2421         }
2422         for ( roundingMode = 1;
2423               roundingMode < NUM_ROUNDINGMODES;
2424               ++roundingMode
2425             ) {
2426             if ( ! functions[ functionCode ].roundingMode ) {
2427                 roundingMode = 0;
2428             }
2429             else if ( roundingModeIn ) {
2430                 roundingMode = roundingModeIn;
2431             }
2432             for ( tininessMode = 1;
2433                   tininessMode < NUM_TININESSMODES;
2434                   ++tininessMode
2435                 ) {
2436                 if (    ( roundingPrecision == 32 )
2437                      || ( roundingPrecision == 64 ) ) {
2438                     if ( ! functions[ functionCode ]
2439                                .tininessModeAtReducedPrecision
2440                        ) {
2441                         tininessMode = 0;
2442                     }
2443                     else if ( tininessModeIn ) {
2444                         tininessMode = tininessModeIn;
2445                     }
2446                 }
2447                 else {
2448                     if ( ! functions[ functionCode ].tininessMode ) {
2449                         tininessMode = 0;
2450                     }
2451                     else if ( tininessModeIn ) {
2452                         tininessMode = tininessModeIn;
2453                     }
2454                 }
2455                 timeFunctionVariety(
2456                     functionCode, roundingPrecision, roundingMode, tininessMode
2457                 );
2458                 if ( tininessModeIn || ! tininessMode ) break;
2459             }
2460             if ( roundingModeIn || ! roundingMode ) break;
2461         }
2462         if ( roundingPrecisionIn || ! roundingPrecision ) break;
2463         if ( roundingPrecision == 80 ) {
2464             break;
2465         }
2466         else if ( roundingPrecision == 64 ) {
2467             roundingPrecision = 80;
2468         }
2469         else if ( roundingPrecision == 32 ) {
2470             roundingPrecision = 64;
2471         }
2472     }
2473 
2474 }
2475 
main(int argc,char ** argv)2476 main( int argc, char **argv )
2477 {
2478     char *argPtr;
2479     flag functionArgument;
2480     uint8 functionCode;
2481     int8 operands, roundingPrecision, roundingMode, tininessMode;
2482 
2483     if ( argc <= 1 ) goto writeHelpMessage;
2484     functionArgument = FALSE;
2485     functionCode = 0;
2486     operands = 0;
2487     roundingPrecision = 0;
2488     roundingMode = 0;
2489     tininessMode = 0;
2490     --argc;
2491     ++argv;
2492     while ( argc && ( argPtr = argv[ 0 ] ) ) {
2493         if ( argPtr[ 0 ] == '-' ) ++argPtr;
2494         if ( strcmp( argPtr, "help" ) == 0 ) {
2495  writeHelpMessage:
2496             fputs(
2497 "timesoftfloat [<option>...] <function>\n"
2498 "  <option>:  (* is default)\n"
2499 "    -help            --Write this message and exit.\n"
2500 #ifdef FLOATX80
2501 "    -precision32     --Only time rounding precision equivalent to float32.\n"
2502 "    -precision64     --Only time rounding precision equivalent to float64.\n"
2503 "    -precision80     --Only time maximum rounding precision.\n"
2504 #endif
2505 "    -nearesteven     --Only time rounding to nearest/even.\n"
2506 "    -tozero          --Only time rounding to zero.\n"
2507 "    -down            --Only time rounding down.\n"
2508 "    -up              --Only time rounding up.\n"
2509 "    -tininessbefore  --Only time underflow tininess before rounding.\n"
2510 "    -tininessafter   --Only time underflow tininess after rounding.\n"
2511 "  <function>:\n"
2512 "    int32_to_<float>                 <float>_add   <float>_eq\n"
2513 "    <float>_to_int32                 <float>_sub   <float>_le\n"
2514 "    <float>_to_int32_round_to_zero   <float>_mul   <float>_lt\n"
2515 "    int64_to_<float>                 <float>_div   <float>_eq_signaling\n"
2516 "    <float>_to_int64                 <float>_rem   <float>_le_quiet\n"
2517 "    <float>_to_int64_round_to_zero                 <float>_lt_quiet\n"
2518 "    <float>_to_<float>\n"
2519 "    <float>_round_to_int\n"
2520 "    <float>_sqrt\n"
2521 "    -all1            --All 1-operand functions.\n"
2522 "    -all2            --All 2-operand functions.\n"
2523 "    -all             --All functions.\n"
2524 "  <float>:\n"
2525 "    float32          --Single precision.\n"
2526 "    float64          --Double precision.\n"
2527 #ifdef FLOATX80
2528 "    floatx80         --Extended double precision.\n"
2529 #endif
2530 #ifdef FLOAT128
2531 "    float128         --Quadruple precision.\n"
2532 #endif
2533                 ,
2534                 stdout
2535             );
2536             return EXIT_SUCCESS;
2537         }
2538 #ifdef FLOATX80
2539         else if ( strcmp( argPtr, "precision32" ) == 0 ) {
2540             roundingPrecision = 32;
2541         }
2542         else if ( strcmp( argPtr, "precision64" ) == 0 ) {
2543             roundingPrecision = 64;
2544         }
2545         else if ( strcmp( argPtr, "precision80" ) == 0 ) {
2546             roundingPrecision = 80;
2547         }
2548 #endif
2549         else if (    ( strcmp( argPtr, "nearesteven" ) == 0 )
2550                   || ( strcmp( argPtr, "nearest_even" ) == 0 ) ) {
2551             roundingMode = ROUND_NEAREST_EVEN;
2552         }
2553         else if (    ( strcmp( argPtr, "tozero" ) == 0 )
2554                   || ( strcmp( argPtr, "to_zero" ) == 0 ) ) {
2555             roundingMode = ROUND_TO_ZERO;
2556         }
2557         else if ( strcmp( argPtr, "down" ) == 0 ) {
2558             roundingMode = ROUND_DOWN;
2559         }
2560         else if ( strcmp( argPtr, "up" ) == 0 ) {
2561             roundingMode = ROUND_UP;
2562         }
2563         else if ( strcmp( argPtr, "tininessbefore" ) == 0 ) {
2564             tininessMode = TININESS_BEFORE_ROUNDING;
2565         }
2566         else if ( strcmp( argPtr, "tininessafter" ) == 0 ) {
2567             tininessMode = TININESS_AFTER_ROUNDING;
2568         }
2569         else if ( strcmp( argPtr, "all1" ) == 0 ) {
2570             functionArgument = TRUE;
2571             functionCode = 0;
2572             operands = 1;
2573         }
2574         else if ( strcmp( argPtr, "all2" ) == 0 ) {
2575             functionArgument = TRUE;
2576             functionCode = 0;
2577             operands = 2;
2578         }
2579         else if ( strcmp( argPtr, "all" ) == 0 ) {
2580             functionArgument = TRUE;
2581             functionCode = 0;
2582             operands = 0;
2583         }
2584         else {
2585             for ( functionCode = 1;
2586                   functionCode < NUM_FUNCTIONS;
2587                   ++functionCode
2588                 ) {
2589                 if ( strcmp( argPtr, functions[ functionCode ].name ) == 0 ) {
2590                     break;
2591                 }
2592             }
2593             if ( functionCode == NUM_FUNCTIONS ) {
2594                 fail( "Invalid option or function `%s'", argv[ 0 ] );
2595             }
2596             functionArgument = TRUE;
2597         }
2598         --argc;
2599         ++argv;
2600     }
2601     if ( ! functionArgument ) fail( "Function argument required" );
2602     if ( functionCode ) {
2603         timeFunction(
2604             functionCode, roundingPrecision, roundingMode, tininessMode );
2605     }
2606     else if ( operands == 1 ) {
2607         for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode
2608             ) {
2609             if ( functions[ functionCode ].numInputs == 1 ) {
2610                 timeFunction(
2611                     functionCode, roundingPrecision, roundingMode, tininessMode
2612                 );
2613             }
2614         }
2615     }
2616     else if ( operands == 2 ) {
2617         for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode
2618             ) {
2619             if ( functions[ functionCode ].numInputs == 2 ) {
2620                 timeFunction(
2621                     functionCode, roundingPrecision, roundingMode, tininessMode
2622                 );
2623             }
2624         }
2625     }
2626     else {
2627         for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode
2628             ) {
2629             timeFunction(
2630                 functionCode, roundingPrecision, roundingMode, tininessMode );
2631         }
2632     }
2633     return EXIT_SUCCESS;
2634 
2635 }
2636 
2637