Path: blob/main/lib/libc/softfloat/timesoftfloat.c
39476 views
/* $NetBSD: timesoftfloat.c,v 1.1 2000/06/06 08:15:11 bjh21 Exp $ */12/*3===============================================================================45This C source file is part of the SoftFloat IEC/IEEE Floating-point6Arithmetic Package, Release 2a.78Written by John R. Hauser. This work was made possible in part by the9International Computer Science Institute, located at Suite 600, 1947 Center10Street, Berkeley, California 94704. Funding was partially provided by the11National Science Foundation under grant MIP-9311980. The original version12of this code was written as part of a project to build a fixed-point vector13processor in collaboration with the University of California at Berkeley,14overseen by Profs. Nelson Morgan and John Wawrzynek. More information15is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/16arithmetic/SoftFloat.html'.1718THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort19has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT20TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO21PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY22AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.2324Derivative works are acceptable, even for commercial purposes, so long as25(1) they include prominent notice that the work is derivative, and (2) they26include prominent notice akin to these four paragraphs for those parts of27this code that are retained.2829===============================================================================30*/3132#include <stdlib.h>33#include <stdarg.h>34#include <string.h>35#include <stdio.h>36#include <time.h>37#include "milieu.h"38#include "softfloat.h"3940enum {41minIterations = 100042};4344static void fail( const char *message, ... )45{46va_list varArgs;4748fputs( "timesoftfloat: ", stderr );49va_start( varArgs, message );50vfprintf( stderr, message, varArgs );51va_end( varArgs );52fputs( ".\n", stderr );53exit( EXIT_FAILURE );5455}5657static char *functionName;58static char *roundingPrecisionName, *roundingModeName, *tininessModeName;5960static void reportTime( int32 count, long clocks )61{6263printf(64"%8.1f kops/s: %s",65( count / ( ( (float) clocks ) / CLOCKS_PER_SEC ) ) / 1000,66functionName67);68if ( roundingModeName ) {69if ( roundingPrecisionName ) {70fputs( ", precision ", stdout );71fputs( roundingPrecisionName, stdout );72}73fputs( ", rounding ", stdout );74fputs( roundingModeName, stdout );75if ( tininessModeName ) {76fputs( ", tininess ", stdout );77fputs( tininessModeName, stdout );78fputs( " rounding", stdout );79}80}81fputc( '\n', stdout );8283}8485enum {86numInputs_int32 = 3287};8889static const int32 inputs_int32[ numInputs_int32 ] = {900xFFFFBB79, 0x405CF80F, 0x00000000, 0xFFFFFD04,910xFFF20002, 0x0C8EF795, 0xF00011FF, 0x000006CA,920x00009BFE, 0xFF4862E3, 0x9FFFEFFE, 0xFFFFFFB7,930x0BFF7FFF, 0x0000F37A, 0x0011DFFE, 0x00000006,940xFFF02006, 0xFFFFF7D1, 0x10200003, 0xDE8DF765,950x00003E02, 0x000019E8, 0x0008FFFE, 0xFFFFFB5C,960xFFDF7FFE, 0x07C42FBF, 0x0FFFE3FF, 0x040B9F13,970xBFFFFFF8, 0x0001BF56, 0x000017F6, 0x000A908A98};99100static void time_a_int32_z_float32( float32 function( int32 ) )101{102clock_t startClock, endClock;103int32 count, i;104int8 inputNum;105106count = 0;107inputNum = 0;108startClock = clock();109do {110for ( i = minIterations; i; --i ) {111function( inputs_int32[ inputNum ] );112inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );113}114count += minIterations;115} while ( clock() - startClock < CLOCKS_PER_SEC );116inputNum = 0;117startClock = clock();118for ( i = count; i; --i ) {119function( inputs_int32[ inputNum ] );120inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );121}122endClock = clock();123reportTime( count, endClock - startClock );124125}126127static void time_a_int32_z_float64( float64 function( int32 ) )128{129clock_t startClock, endClock;130int32 count, i;131int8 inputNum;132133count = 0;134inputNum = 0;135startClock = clock();136do {137for ( i = minIterations; i; --i ) {138function( inputs_int32[ inputNum ] );139inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );140}141count += minIterations;142} while ( clock() - startClock < CLOCKS_PER_SEC );143inputNum = 0;144startClock = clock();145for ( i = count; i; --i ) {146function( inputs_int32[ inputNum ] );147inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );148}149endClock = clock();150reportTime( count, endClock - startClock );151152}153154#ifdef FLOATX80155156static void time_a_int32_z_floatx80( floatx80 function( int32 ) )157{158clock_t startClock, endClock;159int32 count, i;160int8 inputNum;161162count = 0;163inputNum = 0;164startClock = clock();165do {166for ( i = minIterations; i; --i ) {167function( inputs_int32[ inputNum ] );168inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );169}170count += minIterations;171} while ( clock() - startClock < CLOCKS_PER_SEC );172inputNum = 0;173startClock = clock();174for ( i = count; i; --i ) {175function( inputs_int32[ inputNum ] );176inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );177}178endClock = clock();179reportTime( count, endClock - startClock );180181}182183#endif184185#ifdef FLOAT128186187static void time_a_int32_z_float128( float128 function( int32 ) )188{189clock_t startClock, endClock;190int32 count, i;191int8 inputNum;192193count = 0;194inputNum = 0;195startClock = clock();196do {197for ( i = minIterations; i; --i ) {198function( inputs_int32[ inputNum ] );199inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );200}201count += minIterations;202} while ( clock() - startClock < CLOCKS_PER_SEC );203inputNum = 0;204startClock = clock();205for ( i = count; i; --i ) {206function( inputs_int32[ inputNum ] );207inputNum = ( inputNum + 1 ) & ( numInputs_int32 - 1 );208}209endClock = clock();210reportTime( count, endClock - startClock );211212}213214#endif215216enum {217numInputs_int64 = 32218};219220static const int64 inputs_int64[ numInputs_int64 ] = {221LIT64( 0xFBFFC3FFFFFFFFFF ),222LIT64( 0x0000000003C589BC ),223LIT64( 0x00000000400013FE ),224LIT64( 0x0000000000186171 ),225LIT64( 0xFFFFFFFFFFFEFBFA ),226LIT64( 0xFFFFFD79E6DFFC73 ),227LIT64( 0x0000000010001DFF ),228LIT64( 0xDD1A0F0C78513710 ),229LIT64( 0xFFFF83FFFFFEFFFE ),230LIT64( 0x00756EBD1AD0C1C7 ),231LIT64( 0x0003FDFFFFFFFFBE ),232LIT64( 0x0007D0FB2C2CA951 ),233LIT64( 0x0007FC0007FFFFFE ),234LIT64( 0x0000001F942B18BB ),235LIT64( 0x0000080101FFFFFE ),236LIT64( 0xFFFFFFFFFFFF0978 ),237LIT64( 0x000000000008BFFF ),238LIT64( 0x0000000006F5AF08 ),239LIT64( 0xFFDEFF7FFFFFFFFE ),240LIT64( 0x0000000000000003 ),241LIT64( 0x3FFFFFFFFF80007D ),242LIT64( 0x0000000000000078 ),243LIT64( 0xFFF80000007FDFFD ),244LIT64( 0x1BBC775B78016AB0 ),245LIT64( 0xFFF9001FFFFFFFFE ),246LIT64( 0xFFFD4767AB98E43F ),247LIT64( 0xFFFFFEFFFE00001E ),248LIT64( 0xFFFFFFFFFFF04EFD ),249LIT64( 0x07FFFFFFFFFFF7FF ),250LIT64( 0xFFFC9EAA38F89050 ),251LIT64( 0x00000020FBFFFFFE ),252LIT64( 0x0000099AE6455357 )253};254255static void time_a_int64_z_float32( float32 function( int64 ) )256{257clock_t startClock, endClock;258int32 count, i;259int8 inputNum;260261count = 0;262inputNum = 0;263startClock = clock();264do {265for ( i = minIterations; i; --i ) {266function( inputs_int64[ inputNum ] );267inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );268}269count += minIterations;270} while ( clock() - startClock < CLOCKS_PER_SEC );271inputNum = 0;272startClock = clock();273for ( i = count; i; --i ) {274function( inputs_int64[ inputNum ] );275inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );276}277endClock = clock();278reportTime( count, endClock - startClock );279280}281282static void time_a_int64_z_float64( float64 function( int64 ) )283{284clock_t startClock, endClock;285int32 count, i;286int8 inputNum;287288count = 0;289inputNum = 0;290startClock = clock();291do {292for ( i = minIterations; i; --i ) {293function( inputs_int64[ inputNum ] );294inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );295}296count += minIterations;297} while ( clock() - startClock < CLOCKS_PER_SEC );298inputNum = 0;299startClock = clock();300for ( i = count; i; --i ) {301function( inputs_int64[ inputNum ] );302inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );303}304endClock = clock();305reportTime( count, endClock - startClock );306307}308309#ifdef FLOATX80310311static void time_a_int64_z_floatx80( floatx80 function( int64 ) )312{313clock_t startClock, endClock;314int32 count, i;315int8 inputNum;316317count = 0;318inputNum = 0;319startClock = clock();320do {321for ( i = minIterations; i; --i ) {322function( inputs_int64[ inputNum ] );323inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );324}325count += minIterations;326} while ( clock() - startClock < CLOCKS_PER_SEC );327inputNum = 0;328startClock = clock();329for ( i = count; i; --i ) {330function( inputs_int64[ inputNum ] );331inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );332}333endClock = clock();334reportTime( count, endClock - startClock );335336}337338#endif339340#ifdef FLOAT128341342static void time_a_int64_z_float128( float128 function( int64 ) )343{344clock_t startClock, endClock;345int32 count, i;346int8 inputNum;347348count = 0;349inputNum = 0;350startClock = clock();351do {352for ( i = minIterations; i; --i ) {353function( inputs_int64[ inputNum ] );354inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );355}356count += minIterations;357} while ( clock() - startClock < CLOCKS_PER_SEC );358inputNum = 0;359startClock = clock();360for ( i = count; i; --i ) {361function( inputs_int64[ inputNum ] );362inputNum = ( inputNum + 1 ) & ( numInputs_int64 - 1 );363}364endClock = clock();365reportTime( count, endClock - startClock );366367}368369#endif370371enum {372numInputs_float32 = 32373};374375static const float32 inputs_float32[ numInputs_float32 ] = {3760x4EFA0000, 0xC1D0B328, 0x80000000, 0x3E69A31E,3770xAF803EFF, 0x3F800000, 0x17BF8000, 0xE74A301A,3780x4E010003, 0x7EE3C75D, 0xBD803FE0, 0xBFFEFF00,3790x7981F800, 0x431FFFFC, 0xC100C000, 0x3D87EFFF,3800x4103FEFE, 0xBC000007, 0xBF01F7FF, 0x4E6C6B5C,3810xC187FFFE, 0xC58B9F13, 0x4F88007F, 0xDF004007,3820xB7FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000,3830xDB428661, 0x33F89B1F, 0xA3BFEFFF, 0x537BFFBE384};385386static void time_a_float32_z_int32( int32 function( float32 ) )387{388clock_t startClock, endClock;389int32 count, i;390int8 inputNum;391392count = 0;393inputNum = 0;394startClock = clock();395do {396for ( i = minIterations; i; --i ) {397function( inputs_float32[ inputNum ] );398inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );399}400count += minIterations;401} while ( clock() - startClock < CLOCKS_PER_SEC );402inputNum = 0;403startClock = clock();404for ( i = count; i; --i ) {405function( inputs_float32[ inputNum ] );406inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );407}408endClock = clock();409reportTime( count, endClock - startClock );410411}412413static void time_a_float32_z_int64( int64 function( float32 ) )414{415clock_t startClock, endClock;416int32 count, i;417int8 inputNum;418419count = 0;420inputNum = 0;421startClock = clock();422do {423for ( i = minIterations; i; --i ) {424function( inputs_float32[ inputNum ] );425inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );426}427count += minIterations;428} while ( clock() - startClock < CLOCKS_PER_SEC );429inputNum = 0;430startClock = clock();431for ( i = count; i; --i ) {432function( inputs_float32[ inputNum ] );433inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );434}435endClock = clock();436reportTime( count, endClock - startClock );437438}439440static void time_a_float32_z_float64( float64 function( float32 ) )441{442clock_t startClock, endClock;443int32 count, i;444int8 inputNum;445446count = 0;447inputNum = 0;448startClock = clock();449do {450for ( i = minIterations; i; --i ) {451function( inputs_float32[ inputNum ] );452inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );453}454count += minIterations;455} while ( clock() - startClock < CLOCKS_PER_SEC );456inputNum = 0;457startClock = clock();458for ( i = count; i; --i ) {459function( inputs_float32[ inputNum ] );460inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );461}462endClock = clock();463reportTime( count, endClock - startClock );464465}466467#ifdef FLOATX80468469static void time_a_float32_z_floatx80( floatx80 function( float32 ) )470{471clock_t startClock, endClock;472int32 count, i;473int8 inputNum;474475count = 0;476inputNum = 0;477startClock = clock();478do {479for ( i = minIterations; i; --i ) {480function( inputs_float32[ inputNum ] );481inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );482}483count += minIterations;484} while ( clock() - startClock < CLOCKS_PER_SEC );485inputNum = 0;486startClock = clock();487for ( i = count; i; --i ) {488function( inputs_float32[ inputNum ] );489inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );490}491endClock = clock();492reportTime( count, endClock - startClock );493494}495496#endif497498#ifdef FLOAT128499500static void time_a_float32_z_float128( float128 function( float32 ) )501{502clock_t startClock, endClock;503int32 count, i;504int8 inputNum;505506count = 0;507inputNum = 0;508startClock = clock();509do {510for ( i = minIterations; i; --i ) {511function( inputs_float32[ inputNum ] );512inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );513}514count += minIterations;515} while ( clock() - startClock < CLOCKS_PER_SEC );516inputNum = 0;517startClock = clock();518for ( i = count; i; --i ) {519function( inputs_float32[ inputNum ] );520inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );521}522endClock = clock();523reportTime( count, endClock - startClock );524525}526527#endif528529static void time_az_float32( float32 function( float32 ) )530{531clock_t startClock, endClock;532int32 count, i;533int8 inputNum;534535count = 0;536inputNum = 0;537startClock = clock();538do {539for ( i = minIterations; i; --i ) {540function( inputs_float32[ inputNum ] );541inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );542}543count += minIterations;544} while ( clock() - startClock < CLOCKS_PER_SEC );545inputNum = 0;546startClock = clock();547for ( i = count; i; --i ) {548function( inputs_float32[ inputNum ] );549inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );550}551endClock = clock();552reportTime( count, endClock - startClock );553554}555556static void time_ab_float32_z_flag( flag function( float32, float32 ) )557{558clock_t startClock, endClock;559int32 count, i;560int8 inputNumA, inputNumB;561562count = 0;563inputNumA = 0;564inputNumB = 0;565startClock = clock();566do {567for ( i = minIterations; i; --i ) {568function(569inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );570inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );571if ( inputNumA == 0 ) ++inputNumB;572inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );573}574count += minIterations;575} while ( clock() - startClock < CLOCKS_PER_SEC );576inputNumA = 0;577inputNumB = 0;578startClock = clock();579for ( i = count; i; --i ) {580function(581inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );582inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );583if ( inputNumA == 0 ) ++inputNumB;584inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );585}586endClock = clock();587reportTime( count, endClock - startClock );588589}590591static void time_abz_float32( float32 function( float32, float32 ) )592{593clock_t startClock, endClock;594int32 count, i;595int8 inputNumA, inputNumB;596597count = 0;598inputNumA = 0;599inputNumB = 0;600startClock = clock();601do {602for ( i = minIterations; i; --i ) {603function(604inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );605inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );606if ( inputNumA == 0 ) ++inputNumB;607inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );608}609count += minIterations;610} while ( clock() - startClock < CLOCKS_PER_SEC );611inputNumA = 0;612inputNumB = 0;613startClock = clock();614for ( i = count; i; --i ) {615function(616inputs_float32[ inputNumA ], inputs_float32[ inputNumB ] );617inputNumA = ( inputNumA + 1 ) & ( numInputs_float32 - 1 );618if ( inputNumA == 0 ) ++inputNumB;619inputNumB = ( inputNumB + 1 ) & ( numInputs_float32 - 1 );620}621endClock = clock();622reportTime( count, endClock - startClock );623624}625626static const float32 inputs_float32_pos[ numInputs_float32 ] = {6270x4EFA0000, 0x41D0B328, 0x00000000, 0x3E69A31E,6280x2F803EFF, 0x3F800000, 0x17BF8000, 0x674A301A,6290x4E010003, 0x7EE3C75D, 0x3D803FE0, 0x3FFEFF00,6300x7981F800, 0x431FFFFC, 0x4100C000, 0x3D87EFFF,6310x4103FEFE, 0x3C000007, 0x3F01F7FF, 0x4E6C6B5C,6320x4187FFFE, 0x458B9F13, 0x4F88007F, 0x5F004007,6330x37FFD7FE, 0x7E8001FB, 0x46EFFBFF, 0x31C10000,6340x5B428661, 0x33F89B1F, 0x23BFEFFF, 0x537BFFBE635};636637static void time_az_float32_pos( float32 function( float32 ) )638{639clock_t startClock, endClock;640int32 count, i;641int8 inputNum;642643count = 0;644inputNum = 0;645startClock = clock();646do {647for ( i = minIterations; i; --i ) {648function( inputs_float32_pos[ inputNum ] );649inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );650}651count += minIterations;652} while ( clock() - startClock < CLOCKS_PER_SEC );653inputNum = 0;654startClock = clock();655for ( i = count; i; --i ) {656function( inputs_float32_pos[ inputNum ] );657inputNum = ( inputNum + 1 ) & ( numInputs_float32 - 1 );658}659endClock = clock();660reportTime( count, endClock - startClock );661662}663664enum {665numInputs_float64 = 32666};667668static const float64 inputs_float64[ numInputs_float64 ] = {669LIT64( 0x422FFFC008000000 ),670LIT64( 0xB7E0000480000000 ),671LIT64( 0xF3FD2546120B7935 ),672LIT64( 0x3FF0000000000000 ),673LIT64( 0xCE07F766F09588D6 ),674LIT64( 0x8000000000000000 ),675LIT64( 0x3FCE000400000000 ),676LIT64( 0x8313B60F0032BED8 ),677LIT64( 0xC1EFFFFFC0002000 ),678LIT64( 0x3FB3C75D224F2B0F ),679LIT64( 0x7FD00000004000FF ),680LIT64( 0xA12FFF8000001FFF ),681LIT64( 0x3EE0000000FE0000 ),682LIT64( 0x0010000080000004 ),683LIT64( 0x41CFFFFE00000020 ),684LIT64( 0x40303FFFFFFFFFFD ),685LIT64( 0x3FD000003FEFFFFF ),686LIT64( 0xBFD0000010000000 ),687LIT64( 0xB7FC6B5C16CA55CF ),688LIT64( 0x413EEB940B9D1301 ),689LIT64( 0xC7E00200001FFFFF ),690LIT64( 0x47F00021FFFFFFFE ),691LIT64( 0xBFFFFFFFF80000FF ),692LIT64( 0xC07FFFFFE00FFFFF ),693LIT64( 0x001497A63740C5E8 ),694LIT64( 0xC4BFFFE0001FFFFF ),695LIT64( 0x96FFDFFEFFFFFFFF ),696LIT64( 0x403FC000000001FE ),697LIT64( 0xFFD00000000001F6 ),698LIT64( 0x0640400002000000 ),699LIT64( 0x479CEE1E4F789FE0 ),700LIT64( 0xC237FFFFFFFFFDFE )701};702703static void time_a_float64_z_int32( int32 function( float64 ) )704{705clock_t startClock, endClock;706int32 count, i;707int8 inputNum;708709count = 0;710inputNum = 0;711startClock = clock();712do {713for ( i = minIterations; i; --i ) {714function( inputs_float64[ inputNum ] );715inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );716}717count += minIterations;718} while ( clock() - startClock < CLOCKS_PER_SEC );719inputNum = 0;720startClock = clock();721for ( i = count; i; --i ) {722function( inputs_float64[ inputNum ] );723inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );724}725endClock = clock();726reportTime( count, endClock - startClock );727728}729730static void time_a_float64_z_int64( int64 function( float64 ) )731{732clock_t startClock, endClock;733int32 count, i;734int8 inputNum;735736count = 0;737inputNum = 0;738startClock = clock();739do {740for ( i = minIterations; i; --i ) {741function( inputs_float64[ inputNum ] );742inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );743}744count += minIterations;745} while ( clock() - startClock < CLOCKS_PER_SEC );746inputNum = 0;747startClock = clock();748for ( i = count; i; --i ) {749function( inputs_float64[ inputNum ] );750inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );751}752endClock = clock();753reportTime( count, endClock - startClock );754755}756757static void time_a_float64_z_float32( float32 function( float64 ) )758{759clock_t startClock, endClock;760int32 count, i;761int8 inputNum;762763count = 0;764inputNum = 0;765startClock = clock();766do {767for ( i = minIterations; i; --i ) {768function( inputs_float64[ inputNum ] );769inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );770}771count += minIterations;772} while ( clock() - startClock < CLOCKS_PER_SEC );773inputNum = 0;774startClock = clock();775for ( i = count; i; --i ) {776function( inputs_float64[ inputNum ] );777inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );778}779endClock = clock();780reportTime( count, endClock - startClock );781782}783784#ifdef FLOATX80785786static void time_a_float64_z_floatx80( floatx80 function( float64 ) )787{788clock_t startClock, endClock;789int32 count, i;790int8 inputNum;791792count = 0;793inputNum = 0;794startClock = clock();795do {796for ( i = minIterations; i; --i ) {797function( inputs_float64[ inputNum ] );798inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );799}800count += minIterations;801} while ( clock() - startClock < CLOCKS_PER_SEC );802inputNum = 0;803startClock = clock();804for ( i = count; i; --i ) {805function( inputs_float64[ inputNum ] );806inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );807}808endClock = clock();809reportTime( count, endClock - startClock );810811}812813#endif814815#ifdef FLOAT128816817static void time_a_float64_z_float128( float128 function( float64 ) )818{819clock_t startClock, endClock;820int32 count, i;821int8 inputNum;822823count = 0;824inputNum = 0;825startClock = clock();826do {827for ( i = minIterations; i; --i ) {828function( inputs_float64[ inputNum ] );829inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );830}831count += minIterations;832} while ( clock() - startClock < CLOCKS_PER_SEC );833inputNum = 0;834startClock = clock();835for ( i = count; i; --i ) {836function( inputs_float64[ inputNum ] );837inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );838}839endClock = clock();840reportTime( count, endClock - startClock );841842}843844#endif845846static void time_az_float64( float64 function( float64 ) )847{848clock_t startClock, endClock;849int32 count, i;850int8 inputNum;851852count = 0;853inputNum = 0;854startClock = clock();855do {856for ( i = minIterations; i; --i ) {857function( inputs_float64[ inputNum ] );858inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );859}860count += minIterations;861} while ( clock() - startClock < CLOCKS_PER_SEC );862inputNum = 0;863startClock = clock();864for ( i = count; i; --i ) {865function( inputs_float64[ inputNum ] );866inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );867}868endClock = clock();869reportTime( count, endClock - startClock );870871}872873static void time_ab_float64_z_flag( flag function( float64, float64 ) )874{875clock_t startClock, endClock;876int32 count, i;877int8 inputNumA, inputNumB;878879count = 0;880inputNumA = 0;881inputNumB = 0;882startClock = clock();883do {884for ( i = minIterations; i; --i ) {885function(886inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );887inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );888if ( inputNumA == 0 ) ++inputNumB;889inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );890}891count += minIterations;892} while ( clock() - startClock < CLOCKS_PER_SEC );893inputNumA = 0;894inputNumB = 0;895startClock = clock();896for ( i = count; i; --i ) {897function(898inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );899inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );900if ( inputNumA == 0 ) ++inputNumB;901inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );902}903endClock = clock();904reportTime( count, endClock - startClock );905906}907908static void time_abz_float64( float64 function( float64, float64 ) )909{910clock_t startClock, endClock;911int32 count, i;912int8 inputNumA, inputNumB;913914count = 0;915inputNumA = 0;916inputNumB = 0;917startClock = clock();918do {919for ( i = minIterations; i; --i ) {920function(921inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );922inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );923if ( inputNumA == 0 ) ++inputNumB;924inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );925}926count += minIterations;927} while ( clock() - startClock < CLOCKS_PER_SEC );928inputNumA = 0;929inputNumB = 0;930startClock = clock();931for ( i = count; i; --i ) {932function(933inputs_float64[ inputNumA ], inputs_float64[ inputNumB ] );934inputNumA = ( inputNumA + 1 ) & ( numInputs_float64 - 1 );935if ( inputNumA == 0 ) ++inputNumB;936inputNumB = ( inputNumB + 1 ) & ( numInputs_float64 - 1 );937}938endClock = clock();939reportTime( count, endClock - startClock );940941}942943static const float64 inputs_float64_pos[ numInputs_float64 ] = {944LIT64( 0x422FFFC008000000 ),945LIT64( 0x37E0000480000000 ),946LIT64( 0x73FD2546120B7935 ),947LIT64( 0x3FF0000000000000 ),948LIT64( 0x4E07F766F09588D6 ),949LIT64( 0x0000000000000000 ),950LIT64( 0x3FCE000400000000 ),951LIT64( 0x0313B60F0032BED8 ),952LIT64( 0x41EFFFFFC0002000 ),953LIT64( 0x3FB3C75D224F2B0F ),954LIT64( 0x7FD00000004000FF ),955LIT64( 0x212FFF8000001FFF ),956LIT64( 0x3EE0000000FE0000 ),957LIT64( 0x0010000080000004 ),958LIT64( 0x41CFFFFE00000020 ),959LIT64( 0x40303FFFFFFFFFFD ),960LIT64( 0x3FD000003FEFFFFF ),961LIT64( 0x3FD0000010000000 ),962LIT64( 0x37FC6B5C16CA55CF ),963LIT64( 0x413EEB940B9D1301 ),964LIT64( 0x47E00200001FFFFF ),965LIT64( 0x47F00021FFFFFFFE ),966LIT64( 0x3FFFFFFFF80000FF ),967LIT64( 0x407FFFFFE00FFFFF ),968LIT64( 0x001497A63740C5E8 ),969LIT64( 0x44BFFFE0001FFFFF ),970LIT64( 0x16FFDFFEFFFFFFFF ),971LIT64( 0x403FC000000001FE ),972LIT64( 0x7FD00000000001F6 ),973LIT64( 0x0640400002000000 ),974LIT64( 0x479CEE1E4F789FE0 ),975LIT64( 0x4237FFFFFFFFFDFE )976};977978static void time_az_float64_pos( float64 function( float64 ) )979{980clock_t startClock, endClock;981int32 count, i;982int8 inputNum;983984count = 0;985inputNum = 0;986startClock = clock();987do {988for ( i = minIterations; i; --i ) {989function( inputs_float64_pos[ inputNum ] );990inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );991}992count += minIterations;993} while ( clock() - startClock < CLOCKS_PER_SEC );994inputNum = 0;995startClock = clock();996for ( i = count; i; --i ) {997function( inputs_float64_pos[ inputNum ] );998inputNum = ( inputNum + 1 ) & ( numInputs_float64 - 1 );999}1000endClock = clock();1001reportTime( count, endClock - startClock );10021003}10041005#ifdef FLOATX8010061007enum {1008numInputs_floatx80 = 321009};10101011static const struct {1012bits16 high;1013bits64 low;1014} inputs_floatx80[ numInputs_floatx80 ] = {1015{ 0xC03F, LIT64( 0xA9BE15A19C1E8B62 ) },1016{ 0x8000, LIT64( 0x0000000000000000 ) },1017{ 0x75A8, LIT64( 0xE59591E4788957A5 ) },1018{ 0xBFFF, LIT64( 0xFFF0000000000040 ) },1019{ 0x0CD8, LIT64( 0xFC000000000007FE ) },1020{ 0x43BA, LIT64( 0x99A4000000000000 ) },1021{ 0x3FFF, LIT64( 0x8000000000000000 ) },1022{ 0x4081, LIT64( 0x94FBF1BCEB5545F0 ) },1023{ 0x403E, LIT64( 0xFFF0000000002000 ) },1024{ 0x3FFE, LIT64( 0xC860E3C75D224F28 ) },1025{ 0x407E, LIT64( 0xFC00000FFFFFFFFE ) },1026{ 0x737A, LIT64( 0x800000007FFDFFFE ) },1027{ 0x4044, LIT64( 0xFFFFFF80000FFFFF ) },1028{ 0xBBFE, LIT64( 0x8000040000001FFE ) },1029{ 0xC002, LIT64( 0xFF80000000000020 ) },1030{ 0xDE8D, LIT64( 0xFFFFFFFFFFE00004 ) },1031{ 0xC004, LIT64( 0x8000000000003FFB ) },1032{ 0x407F, LIT64( 0x800000000003FFFE ) },1033{ 0xC000, LIT64( 0xA459EE6A5C16CA55 ) },1034{ 0x8003, LIT64( 0xC42CBF7399AEEB94 ) },1035{ 0xBF7F, LIT64( 0xF800000000000006 ) },1036{ 0xC07F, LIT64( 0xBF56BE8871F28FEA ) },1037{ 0xC07E, LIT64( 0xFFFF77FFFFFFFFFE ) },1038{ 0xADC9, LIT64( 0x8000000FFFFFFFDE ) },1039{ 0xC001, LIT64( 0xEFF7FFFFFFFFFFFF ) },1040{ 0x4001, LIT64( 0xBE84F30125C497A6 ) },1041{ 0xC06B, LIT64( 0xEFFFFFFFFFFFFFFF ) },1042{ 0x4080, LIT64( 0xFFFFFFFFBFFFFFFF ) },1043{ 0x87E9, LIT64( 0x81FFFFFFFFFFFBFF ) },1044{ 0xA63F, LIT64( 0x801FFFFFFEFFFFFE ) },1045{ 0x403C, LIT64( 0x801FFFFFFFF7FFFF ) },1046{ 0x4018, LIT64( 0x8000000000080003 ) }1047};10481049static void time_a_floatx80_z_int32( int32 function( floatx80 ) )1050{1051clock_t startClock, endClock;1052int32 count, i;1053int8 inputNum;1054floatx80 a;10551056count = 0;1057inputNum = 0;1058startClock = clock();1059do {1060for ( i = minIterations; i; --i ) {1061a.low = inputs_floatx80[ inputNum ].low;1062a.high = inputs_floatx80[ inputNum ].high;1063function( a );1064inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1065}1066count += minIterations;1067} while ( clock() - startClock < CLOCKS_PER_SEC );1068inputNum = 0;1069startClock = clock();1070for ( i = count; i; --i ) {1071a.low = inputs_floatx80[ inputNum ].low;1072a.high = inputs_floatx80[ inputNum ].high;1073function( a );1074inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1075}1076endClock = clock();1077reportTime( count, endClock - startClock );10781079}10801081static void time_a_floatx80_z_int64( int64 function( floatx80 ) )1082{1083clock_t startClock, endClock;1084int32 count, i;1085int8 inputNum;1086floatx80 a;10871088count = 0;1089inputNum = 0;1090startClock = clock();1091do {1092for ( i = minIterations; i; --i ) {1093a.low = inputs_floatx80[ inputNum ].low;1094a.high = inputs_floatx80[ inputNum ].high;1095function( a );1096inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1097}1098count += minIterations;1099} while ( clock() - startClock < CLOCKS_PER_SEC );1100inputNum = 0;1101startClock = clock();1102for ( i = count; i; --i ) {1103a.low = inputs_floatx80[ inputNum ].low;1104a.high = inputs_floatx80[ inputNum ].high;1105function( a );1106inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1107}1108endClock = clock();1109reportTime( count, endClock - startClock );11101111}11121113static void time_a_floatx80_z_float32( float32 function( floatx80 ) )1114{1115clock_t startClock, endClock;1116int32 count, i;1117int8 inputNum;1118floatx80 a;11191120count = 0;1121inputNum = 0;1122startClock = clock();1123do {1124for ( i = minIterations; i; --i ) {1125a.low = inputs_floatx80[ inputNum ].low;1126a.high = inputs_floatx80[ inputNum ].high;1127function( a );1128inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1129}1130count += minIterations;1131} while ( clock() - startClock < CLOCKS_PER_SEC );1132inputNum = 0;1133startClock = clock();1134for ( i = count; i; --i ) {1135a.low = inputs_floatx80[ inputNum ].low;1136a.high = inputs_floatx80[ inputNum ].high;1137function( a );1138inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1139}1140endClock = clock();1141reportTime( count, endClock - startClock );11421143}11441145static void time_a_floatx80_z_float64( float64 function( floatx80 ) )1146{1147clock_t startClock, endClock;1148int32 count, i;1149int8 inputNum;1150floatx80 a;11511152count = 0;1153inputNum = 0;1154startClock = clock();1155do {1156for ( i = minIterations; i; --i ) {1157a.low = inputs_floatx80[ inputNum ].low;1158a.high = inputs_floatx80[ inputNum ].high;1159function( a );1160inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1161}1162count += minIterations;1163} while ( clock() - startClock < CLOCKS_PER_SEC );1164inputNum = 0;1165startClock = clock();1166for ( i = count; i; --i ) {1167a.low = inputs_floatx80[ inputNum ].low;1168a.high = inputs_floatx80[ inputNum ].high;1169function( a );1170inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1171}1172endClock = clock();1173reportTime( count, endClock - startClock );11741175}11761177#ifdef FLOAT12811781179static void time_a_floatx80_z_float128( float128 function( floatx80 ) )1180{1181clock_t startClock, endClock;1182int32 count, i;1183int8 inputNum;1184floatx80 a;11851186count = 0;1187inputNum = 0;1188startClock = clock();1189do {1190for ( i = minIterations; i; --i ) {1191a.low = inputs_floatx80[ inputNum ].low;1192a.high = inputs_floatx80[ inputNum ].high;1193function( a );1194inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1195}1196count += minIterations;1197} while ( clock() - startClock < CLOCKS_PER_SEC );1198inputNum = 0;1199startClock = clock();1200for ( i = count; i; --i ) {1201a.low = inputs_floatx80[ inputNum ].low;1202a.high = inputs_floatx80[ inputNum ].high;1203function( a );1204inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1205}1206endClock = clock();1207reportTime( count, endClock - startClock );12081209}12101211#endif12121213static void time_az_floatx80( floatx80 function( floatx80 ) )1214{1215clock_t startClock, endClock;1216int32 count, i;1217int8 inputNum;1218floatx80 a;12191220count = 0;1221inputNum = 0;1222startClock = clock();1223do {1224for ( i = minIterations; i; --i ) {1225a.low = inputs_floatx80[ inputNum ].low;1226a.high = inputs_floatx80[ inputNum ].high;1227function( a );1228inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1229}1230count += minIterations;1231} while ( clock() - startClock < CLOCKS_PER_SEC );1232inputNum = 0;1233startClock = clock();1234for ( i = count; i; --i ) {1235a.low = inputs_floatx80[ inputNum ].low;1236a.high = inputs_floatx80[ inputNum ].high;1237function( a );1238inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1239}1240endClock = clock();1241reportTime( count, endClock - startClock );12421243}12441245static void time_ab_floatx80_z_flag( flag function( floatx80, floatx80 ) )1246{1247clock_t startClock, endClock;1248int32 count, i;1249int8 inputNumA, inputNumB;1250floatx80 a, b;12511252count = 0;1253inputNumA = 0;1254inputNumB = 0;1255startClock = clock();1256do {1257for ( i = minIterations; i; --i ) {1258a.low = inputs_floatx80[ inputNumA ].low;1259a.high = inputs_floatx80[ inputNumA ].high;1260b.low = inputs_floatx80[ inputNumB ].low;1261b.high = inputs_floatx80[ inputNumB ].high;1262function( a, b );1263inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );1264if ( inputNumA == 0 ) ++inputNumB;1265inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );1266}1267count += minIterations;1268} while ( clock() - startClock < CLOCKS_PER_SEC );1269inputNumA = 0;1270inputNumB = 0;1271startClock = clock();1272for ( i = count; i; --i ) {1273a.low = inputs_floatx80[ inputNumA ].low;1274a.high = inputs_floatx80[ inputNumA ].high;1275b.low = inputs_floatx80[ inputNumB ].low;1276b.high = inputs_floatx80[ inputNumB ].high;1277function( a, b );1278inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );1279if ( inputNumA == 0 ) ++inputNumB;1280inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );1281}1282endClock = clock();1283reportTime( count, endClock - startClock );12841285}12861287static void time_abz_floatx80( floatx80 function( floatx80, floatx80 ) )1288{1289clock_t startClock, endClock;1290int32 count, i;1291int8 inputNumA, inputNumB;1292floatx80 a, b;12931294count = 0;1295inputNumA = 0;1296inputNumB = 0;1297startClock = clock();1298do {1299for ( i = minIterations; i; --i ) {1300a.low = inputs_floatx80[ inputNumA ].low;1301a.high = inputs_floatx80[ inputNumA ].high;1302b.low = inputs_floatx80[ inputNumB ].low;1303b.high = inputs_floatx80[ inputNumB ].high;1304function( a, b );1305inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );1306if ( inputNumA == 0 ) ++inputNumB;1307inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );1308}1309count += minIterations;1310} while ( clock() - startClock < CLOCKS_PER_SEC );1311inputNumA = 0;1312inputNumB = 0;1313startClock = clock();1314for ( i = count; i; --i ) {1315a.low = inputs_floatx80[ inputNumA ].low;1316a.high = inputs_floatx80[ inputNumA ].high;1317b.low = inputs_floatx80[ inputNumB ].low;1318b.high = inputs_floatx80[ inputNumB ].high;1319function( a, b );1320inputNumA = ( inputNumA + 1 ) & ( numInputs_floatx80 - 1 );1321if ( inputNumA == 0 ) ++inputNumB;1322inputNumB = ( inputNumB + 1 ) & ( numInputs_floatx80 - 1 );1323}1324endClock = clock();1325reportTime( count, endClock - startClock );13261327}13281329static const struct {1330bits16 high;1331bits64 low;1332} inputs_floatx80_pos[ numInputs_floatx80 ] = {1333{ 0x403F, LIT64( 0xA9BE15A19C1E8B62 ) },1334{ 0x0000, LIT64( 0x0000000000000000 ) },1335{ 0x75A8, LIT64( 0xE59591E4788957A5 ) },1336{ 0x3FFF, LIT64( 0xFFF0000000000040 ) },1337{ 0x0CD8, LIT64( 0xFC000000000007FE ) },1338{ 0x43BA, LIT64( 0x99A4000000000000 ) },1339{ 0x3FFF, LIT64( 0x8000000000000000 ) },1340{ 0x4081, LIT64( 0x94FBF1BCEB5545F0 ) },1341{ 0x403E, LIT64( 0xFFF0000000002000 ) },1342{ 0x3FFE, LIT64( 0xC860E3C75D224F28 ) },1343{ 0x407E, LIT64( 0xFC00000FFFFFFFFE ) },1344{ 0x737A, LIT64( 0x800000007FFDFFFE ) },1345{ 0x4044, LIT64( 0xFFFFFF80000FFFFF ) },1346{ 0x3BFE, LIT64( 0x8000040000001FFE ) },1347{ 0x4002, LIT64( 0xFF80000000000020 ) },1348{ 0x5E8D, LIT64( 0xFFFFFFFFFFE00004 ) },1349{ 0x4004, LIT64( 0x8000000000003FFB ) },1350{ 0x407F, LIT64( 0x800000000003FFFE ) },1351{ 0x4000, LIT64( 0xA459EE6A5C16CA55 ) },1352{ 0x0003, LIT64( 0xC42CBF7399AEEB94 ) },1353{ 0x3F7F, LIT64( 0xF800000000000006 ) },1354{ 0x407F, LIT64( 0xBF56BE8871F28FEA ) },1355{ 0x407E, LIT64( 0xFFFF77FFFFFFFFFE ) },1356{ 0x2DC9, LIT64( 0x8000000FFFFFFFDE ) },1357{ 0x4001, LIT64( 0xEFF7FFFFFFFFFFFF ) },1358{ 0x4001, LIT64( 0xBE84F30125C497A6 ) },1359{ 0x406B, LIT64( 0xEFFFFFFFFFFFFFFF ) },1360{ 0x4080, LIT64( 0xFFFFFFFFBFFFFFFF ) },1361{ 0x07E9, LIT64( 0x81FFFFFFFFFFFBFF ) },1362{ 0x263F, LIT64( 0x801FFFFFFEFFFFFE ) },1363{ 0x403C, LIT64( 0x801FFFFFFFF7FFFF ) },1364{ 0x4018, LIT64( 0x8000000000080003 ) }1365};13661367static void time_az_floatx80_pos( floatx80 function( floatx80 ) )1368{1369clock_t startClock, endClock;1370int32 count, i;1371int8 inputNum;1372floatx80 a;13731374count = 0;1375inputNum = 0;1376startClock = clock();1377do {1378for ( i = minIterations; i; --i ) {1379a.low = inputs_floatx80_pos[ inputNum ].low;1380a.high = inputs_floatx80_pos[ inputNum ].high;1381function( a );1382inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1383}1384count += minIterations;1385} while ( clock() - startClock < CLOCKS_PER_SEC );1386inputNum = 0;1387startClock = clock();1388for ( i = count; i; --i ) {1389a.low = inputs_floatx80_pos[ inputNum ].low;1390a.high = inputs_floatx80_pos[ inputNum ].high;1391function( a );1392inputNum = ( inputNum + 1 ) & ( numInputs_floatx80 - 1 );1393}1394endClock = clock();1395reportTime( count, endClock - startClock );13961397}13981399#endif14001401#ifdef FLOAT12814021403enum {1404numInputs_float128 = 321405};14061407static const struct {1408bits64 high, low;1409} inputs_float128[ numInputs_float128 ] = {1410{ LIT64( 0x3FDA200000100000 ), LIT64( 0x0000000000000000 ) },1411{ LIT64( 0x3FFF000000000000 ), LIT64( 0x0000000000000000 ) },1412{ LIT64( 0x85F14776190C8306 ), LIT64( 0xD8715F4E3D54BB92 ) },1413{ LIT64( 0xF2B00000007FFFFF ), LIT64( 0xFFFFFFFFFFF7FFFF ) },1414{ LIT64( 0x8000000000000000 ), LIT64( 0x0000000000000000 ) },1415{ LIT64( 0xBFFFFFFFFFE00000 ), LIT64( 0x0000008000000000 ) },1416{ LIT64( 0x407F1719CE722F3E ), LIT64( 0xDA6B3FE5FF29425B ) },1417{ LIT64( 0x43FFFF8000000000 ), LIT64( 0x0000000000400000 ) },1418{ LIT64( 0x401E000000000100 ), LIT64( 0x0000000000002000 ) },1419{ LIT64( 0x3FFED71DACDA8E47 ), LIT64( 0x4860E3C75D224F28 ) },1420{ LIT64( 0xBF7ECFC1E90647D1 ), LIT64( 0x7A124FE55623EE44 ) },1421{ LIT64( 0x0DF7007FFFFFFFFF ), LIT64( 0xFFFFFFFFEFFFFFFF ) },1422{ LIT64( 0x3FE5FFEFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFEFFF ) },1423{ LIT64( 0x403FFFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFBFE ) },1424{ LIT64( 0xBFFB2FBF7399AFEB ), LIT64( 0xA459EE6A5C16CA55 ) },1425{ LIT64( 0xBDB8FFFFFFFFFFFC ), LIT64( 0x0000000000000400 ) },1426{ LIT64( 0x3FC8FFDFFFFFFFFF ), LIT64( 0xFFFFFFFFF0000000 ) },1427{ LIT64( 0x3FFBFFFFFFDFFFFF ), LIT64( 0xFFF8000000000000 ) },1428{ LIT64( 0x407043C11737BE84 ), LIT64( 0xDDD58212ADC937F4 ) },1429{ LIT64( 0x8001000000000000 ), LIT64( 0x0000001000000001 ) },1430{ LIT64( 0xC036FFFFFFFFFFFF ), LIT64( 0xFE40000000000000 ) },1431{ LIT64( 0x4002FFFFFE000002 ), LIT64( 0x0000000000000000 ) },1432{ LIT64( 0x4000C3FEDE897773 ), LIT64( 0x326AC4FD8EFBE6DC ) },1433{ LIT64( 0xBFFF0000000FFFFF ), LIT64( 0xFFFFFE0000000000 ) },1434{ LIT64( 0x62C3E502146E426D ), LIT64( 0x43F3CAA0DC7DF1A0 ) },1435{ LIT64( 0xB5CBD32E52BB570E ), LIT64( 0xBCC477CB11C6236C ) },1436{ LIT64( 0xE228FFFFFFC00000 ), LIT64( 0x0000000000000000 ) },1437{ LIT64( 0x3F80000000000000 ), LIT64( 0x0000000080000008 ) },1438{ LIT64( 0xC1AFFFDFFFFFFFFF ), LIT64( 0xFFFC000000000000 ) },1439{ LIT64( 0xC96F000000000000 ), LIT64( 0x00000001FFFBFFFF ) },1440{ LIT64( 0x3DE09BFE7923A338 ), LIT64( 0xBCC8FBBD7CEC1F4F ) },1441{ LIT64( 0x401CFFFFFFFFFFFF ), LIT64( 0xFFFFFFFEFFFFFF80 ) }1442};14431444static void time_a_float128_z_int32( int32 function( float128 ) )1445{1446clock_t startClock, endClock;1447int32 count, i;1448int8 inputNum;1449float128 a;14501451count = 0;1452inputNum = 0;1453startClock = clock();1454do {1455for ( i = minIterations; i; --i ) {1456a.low = inputs_float128[ inputNum ].low;1457a.high = inputs_float128[ inputNum ].high;1458function( a );1459inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1460}1461count += minIterations;1462} while ( clock() - startClock < CLOCKS_PER_SEC );1463inputNum = 0;1464startClock = clock();1465for ( i = count; i; --i ) {1466a.low = inputs_float128[ inputNum ].low;1467a.high = inputs_float128[ inputNum ].high;1468function( a );1469inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1470}1471endClock = clock();1472reportTime( count, endClock - startClock );14731474}14751476static void time_a_float128_z_int64( int64 function( float128 ) )1477{1478clock_t startClock, endClock;1479int32 count, i;1480int8 inputNum;1481float128 a;14821483count = 0;1484inputNum = 0;1485startClock = clock();1486do {1487for ( i = minIterations; i; --i ) {1488a.low = inputs_float128[ inputNum ].low;1489a.high = inputs_float128[ inputNum ].high;1490function( a );1491inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1492}1493count += minIterations;1494} while ( clock() - startClock < CLOCKS_PER_SEC );1495inputNum = 0;1496startClock = clock();1497for ( i = count; i; --i ) {1498a.low = inputs_float128[ inputNum ].low;1499a.high = inputs_float128[ inputNum ].high;1500function( a );1501inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1502}1503endClock = clock();1504reportTime( count, endClock - startClock );15051506}15071508static void time_a_float128_z_float32( float32 function( float128 ) )1509{1510clock_t startClock, endClock;1511int32 count, i;1512int8 inputNum;1513float128 a;15141515count = 0;1516inputNum = 0;1517startClock = clock();1518do {1519for ( i = minIterations; i; --i ) {1520a.low = inputs_float128[ inputNum ].low;1521a.high = inputs_float128[ inputNum ].high;1522function( a );1523inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1524}1525count += minIterations;1526} while ( clock() - startClock < CLOCKS_PER_SEC );1527inputNum = 0;1528startClock = clock();1529for ( i = count; i; --i ) {1530a.low = inputs_float128[ inputNum ].low;1531a.high = inputs_float128[ inputNum ].high;1532function( a );1533inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1534}1535endClock = clock();1536reportTime( count, endClock - startClock );15371538}15391540static void time_a_float128_z_float64( float64 function( float128 ) )1541{1542clock_t startClock, endClock;1543int32 count, i;1544int8 inputNum;1545float128 a;15461547count = 0;1548inputNum = 0;1549startClock = clock();1550do {1551for ( i = minIterations; i; --i ) {1552a.low = inputs_float128[ inputNum ].low;1553a.high = inputs_float128[ inputNum ].high;1554function( a );1555inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1556}1557count += minIterations;1558} while ( clock() - startClock < CLOCKS_PER_SEC );1559inputNum = 0;1560startClock = clock();1561for ( i = count; i; --i ) {1562a.low = inputs_float128[ inputNum ].low;1563a.high = inputs_float128[ inputNum ].high;1564function( a );1565inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1566}1567endClock = clock();1568reportTime( count, endClock - startClock );15691570}15711572#ifdef FLOATX8015731574static void time_a_float128_z_floatx80( floatx80 function( float128 ) )1575{1576clock_t startClock, endClock;1577int32 count, i;1578int8 inputNum;1579float128 a;15801581count = 0;1582inputNum = 0;1583startClock = clock();1584do {1585for ( i = minIterations; i; --i ) {1586a.low = inputs_float128[ inputNum ].low;1587a.high = inputs_float128[ inputNum ].high;1588function( a );1589inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1590}1591count += minIterations;1592} while ( clock() - startClock < CLOCKS_PER_SEC );1593inputNum = 0;1594startClock = clock();1595for ( i = count; i; --i ) {1596a.low = inputs_float128[ inputNum ].low;1597a.high = inputs_float128[ inputNum ].high;1598function( a );1599inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1600}1601endClock = clock();1602reportTime( count, endClock - startClock );16031604}16051606#endif16071608static void time_az_float128( float128 function( float128 ) )1609{1610clock_t startClock, endClock;1611int32 count, i;1612int8 inputNum;1613float128 a;16141615count = 0;1616inputNum = 0;1617startClock = clock();1618do {1619for ( i = minIterations; i; --i ) {1620a.low = inputs_float128[ inputNum ].low;1621a.high = inputs_float128[ inputNum ].high;1622function( a );1623inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1624}1625count += minIterations;1626} while ( clock() - startClock < CLOCKS_PER_SEC );1627inputNum = 0;1628startClock = clock();1629for ( i = count; i; --i ) {1630a.low = inputs_float128[ inputNum ].low;1631a.high = inputs_float128[ inputNum ].high;1632function( a );1633inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1634}1635endClock = clock();1636reportTime( count, endClock - startClock );16371638}16391640static void time_ab_float128_z_flag( flag function( float128, float128 ) )1641{1642clock_t startClock, endClock;1643int32 count, i;1644int8 inputNumA, inputNumB;1645float128 a, b;16461647count = 0;1648inputNumA = 0;1649inputNumB = 0;1650startClock = clock();1651do {1652for ( i = minIterations; i; --i ) {1653a.low = inputs_float128[ inputNumA ].low;1654a.high = inputs_float128[ inputNumA ].high;1655b.low = inputs_float128[ inputNumB ].low;1656b.high = inputs_float128[ inputNumB ].high;1657function( a, b );1658inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );1659if ( inputNumA == 0 ) ++inputNumB;1660inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );1661}1662count += minIterations;1663} while ( clock() - startClock < CLOCKS_PER_SEC );1664inputNumA = 0;1665inputNumB = 0;1666startClock = clock();1667for ( i = count; i; --i ) {1668a.low = inputs_float128[ inputNumA ].low;1669a.high = inputs_float128[ inputNumA ].high;1670b.low = inputs_float128[ inputNumB ].low;1671b.high = inputs_float128[ inputNumB ].high;1672function( a, b );1673inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );1674if ( inputNumA == 0 ) ++inputNumB;1675inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );1676}1677endClock = clock();1678reportTime( count, endClock - startClock );16791680}16811682static void time_abz_float128( float128 function( float128, float128 ) )1683{1684clock_t startClock, endClock;1685int32 count, i;1686int8 inputNumA, inputNumB;1687float128 a, b;16881689count = 0;1690inputNumA = 0;1691inputNumB = 0;1692startClock = clock();1693do {1694for ( i = minIterations; i; --i ) {1695a.low = inputs_float128[ inputNumA ].low;1696a.high = inputs_float128[ inputNumA ].high;1697b.low = inputs_float128[ inputNumB ].low;1698b.high = inputs_float128[ inputNumB ].high;1699function( a, b );1700inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );1701if ( inputNumA == 0 ) ++inputNumB;1702inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );1703}1704count += minIterations;1705} while ( clock() - startClock < CLOCKS_PER_SEC );1706inputNumA = 0;1707inputNumB = 0;1708startClock = clock();1709for ( i = count; i; --i ) {1710a.low = inputs_float128[ inputNumA ].low;1711a.high = inputs_float128[ inputNumA ].high;1712b.low = inputs_float128[ inputNumB ].low;1713b.high = inputs_float128[ inputNumB ].high;1714function( a, b );1715inputNumA = ( inputNumA + 1 ) & ( numInputs_float128 - 1 );1716if ( inputNumA == 0 ) ++inputNumB;1717inputNumB = ( inputNumB + 1 ) & ( numInputs_float128 - 1 );1718}1719endClock = clock();1720reportTime( count, endClock - startClock );17211722}17231724static const struct {1725bits64 high, low;1726} inputs_float128_pos[ numInputs_float128 ] = {1727{ LIT64( 0x3FDA200000100000 ), LIT64( 0x0000000000000000 ) },1728{ LIT64( 0x3FFF000000000000 ), LIT64( 0x0000000000000000 ) },1729{ LIT64( 0x05F14776190C8306 ), LIT64( 0xD8715F4E3D54BB92 ) },1730{ LIT64( 0x72B00000007FFFFF ), LIT64( 0xFFFFFFFFFFF7FFFF ) },1731{ LIT64( 0x0000000000000000 ), LIT64( 0x0000000000000000 ) },1732{ LIT64( 0x3FFFFFFFFFE00000 ), LIT64( 0x0000008000000000 ) },1733{ LIT64( 0x407F1719CE722F3E ), LIT64( 0xDA6B3FE5FF29425B ) },1734{ LIT64( 0x43FFFF8000000000 ), LIT64( 0x0000000000400000 ) },1735{ LIT64( 0x401E000000000100 ), LIT64( 0x0000000000002000 ) },1736{ LIT64( 0x3FFED71DACDA8E47 ), LIT64( 0x4860E3C75D224F28 ) },1737{ LIT64( 0x3F7ECFC1E90647D1 ), LIT64( 0x7A124FE55623EE44 ) },1738{ LIT64( 0x0DF7007FFFFFFFFF ), LIT64( 0xFFFFFFFFEFFFFFFF ) },1739{ LIT64( 0x3FE5FFEFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFEFFF ) },1740{ LIT64( 0x403FFFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFBFE ) },1741{ LIT64( 0x3FFB2FBF7399AFEB ), LIT64( 0xA459EE6A5C16CA55 ) },1742{ LIT64( 0x3DB8FFFFFFFFFFFC ), LIT64( 0x0000000000000400 ) },1743{ LIT64( 0x3FC8FFDFFFFFFFFF ), LIT64( 0xFFFFFFFFF0000000 ) },1744{ LIT64( 0x3FFBFFFFFFDFFFFF ), LIT64( 0xFFF8000000000000 ) },1745{ LIT64( 0x407043C11737BE84 ), LIT64( 0xDDD58212ADC937F4 ) },1746{ LIT64( 0x0001000000000000 ), LIT64( 0x0000001000000001 ) },1747{ LIT64( 0x4036FFFFFFFFFFFF ), LIT64( 0xFE40000000000000 ) },1748{ LIT64( 0x4002FFFFFE000002 ), LIT64( 0x0000000000000000 ) },1749{ LIT64( 0x4000C3FEDE897773 ), LIT64( 0x326AC4FD8EFBE6DC ) },1750{ LIT64( 0x3FFF0000000FFFFF ), LIT64( 0xFFFFFE0000000000 ) },1751{ LIT64( 0x62C3E502146E426D ), LIT64( 0x43F3CAA0DC7DF1A0 ) },1752{ LIT64( 0x35CBD32E52BB570E ), LIT64( 0xBCC477CB11C6236C ) },1753{ LIT64( 0x6228FFFFFFC00000 ), LIT64( 0x0000000000000000 ) },1754{ LIT64( 0x3F80000000000000 ), LIT64( 0x0000000080000008 ) },1755{ LIT64( 0x41AFFFDFFFFFFFFF ), LIT64( 0xFFFC000000000000 ) },1756{ LIT64( 0x496F000000000000 ), LIT64( 0x00000001FFFBFFFF ) },1757{ LIT64( 0x3DE09BFE7923A338 ), LIT64( 0xBCC8FBBD7CEC1F4F ) },1758{ LIT64( 0x401CFFFFFFFFFFFF ), LIT64( 0xFFFFFFFEFFFFFF80 ) }1759};17601761static void time_az_float128_pos( float128 function( float128 ) )1762{1763clock_t startClock, endClock;1764int32 count, i;1765int8 inputNum;1766float128 a;17671768count = 0;1769inputNum = 0;1770startClock = clock();1771do {1772for ( i = minIterations; i; --i ) {1773a.low = inputs_float128_pos[ inputNum ].low;1774a.high = inputs_float128_pos[ inputNum ].high;1775function( a );1776inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1777}1778count += minIterations;1779} while ( clock() - startClock < CLOCKS_PER_SEC );1780inputNum = 0;1781startClock = clock();1782for ( i = count; i; --i ) {1783a.low = inputs_float128_pos[ inputNum ].low;1784a.high = inputs_float128_pos[ inputNum ].high;1785function( a );1786inputNum = ( inputNum + 1 ) & ( numInputs_float128 - 1 );1787}1788endClock = clock();1789reportTime( count, endClock - startClock );17901791}17921793#endif17941795enum {1796INT32_TO_FLOAT32 = 1,1797INT32_TO_FLOAT64,1798#ifdef FLOATX801799INT32_TO_FLOATX80,1800#endif1801#ifdef FLOAT1281802INT32_TO_FLOAT128,1803#endif1804INT64_TO_FLOAT32,1805INT64_TO_FLOAT64,1806#ifdef FLOATX801807INT64_TO_FLOATX80,1808#endif1809#ifdef FLOAT1281810INT64_TO_FLOAT128,1811#endif1812FLOAT32_TO_INT32,1813FLOAT32_TO_INT32_ROUND_TO_ZERO,1814FLOAT32_TO_INT64,1815FLOAT32_TO_INT64_ROUND_TO_ZERO,1816FLOAT32_TO_FLOAT64,1817#ifdef FLOATX801818FLOAT32_TO_FLOATX80,1819#endif1820#ifdef FLOAT1281821FLOAT32_TO_FLOAT128,1822#endif1823FLOAT32_ROUND_TO_INT,1824FLOAT32_ADD,1825FLOAT32_SUB,1826FLOAT32_MUL,1827FLOAT32_DIV,1828FLOAT32_REM,1829FLOAT32_SQRT,1830FLOAT32_EQ,1831FLOAT32_LE,1832FLOAT32_LT,1833FLOAT32_EQ_SIGNALING,1834FLOAT32_LE_QUIET,1835FLOAT32_LT_QUIET,1836FLOAT64_TO_INT32,1837FLOAT64_TO_INT32_ROUND_TO_ZERO,1838FLOAT64_TO_INT64,1839FLOAT64_TO_INT64_ROUND_TO_ZERO,1840FLOAT64_TO_FLOAT32,1841#ifdef FLOATX801842FLOAT64_TO_FLOATX80,1843#endif1844#ifdef FLOAT1281845FLOAT64_TO_FLOAT128,1846#endif1847FLOAT64_ROUND_TO_INT,1848FLOAT64_ADD,1849FLOAT64_SUB,1850FLOAT64_MUL,1851FLOAT64_DIV,1852FLOAT64_REM,1853FLOAT64_SQRT,1854FLOAT64_EQ,1855FLOAT64_LE,1856FLOAT64_LT,1857FLOAT64_EQ_SIGNALING,1858FLOAT64_LE_QUIET,1859FLOAT64_LT_QUIET,1860#ifdef FLOATX801861FLOATX80_TO_INT32,1862FLOATX80_TO_INT32_ROUND_TO_ZERO,1863FLOATX80_TO_INT64,1864FLOATX80_TO_INT64_ROUND_TO_ZERO,1865FLOATX80_TO_FLOAT32,1866FLOATX80_TO_FLOAT64,1867#ifdef FLOAT1281868FLOATX80_TO_FLOAT128,1869#endif1870FLOATX80_ROUND_TO_INT,1871FLOATX80_ADD,1872FLOATX80_SUB,1873FLOATX80_MUL,1874FLOATX80_DIV,1875FLOATX80_REM,1876FLOATX80_SQRT,1877FLOATX80_EQ,1878FLOATX80_LE,1879FLOATX80_LT,1880FLOATX80_EQ_SIGNALING,1881FLOATX80_LE_QUIET,1882FLOATX80_LT_QUIET,1883#endif1884#ifdef FLOAT1281885FLOAT128_TO_INT32,1886FLOAT128_TO_INT32_ROUND_TO_ZERO,1887FLOAT128_TO_INT64,1888FLOAT128_TO_INT64_ROUND_TO_ZERO,1889FLOAT128_TO_FLOAT32,1890FLOAT128_TO_FLOAT64,1891#ifdef FLOATX801892FLOAT128_TO_FLOATX80,1893#endif1894FLOAT128_ROUND_TO_INT,1895FLOAT128_ADD,1896FLOAT128_SUB,1897FLOAT128_MUL,1898FLOAT128_DIV,1899FLOAT128_REM,1900FLOAT128_SQRT,1901FLOAT128_EQ,1902FLOAT128_LE,1903FLOAT128_LT,1904FLOAT128_EQ_SIGNALING,1905FLOAT128_LE_QUIET,1906FLOAT128_LT_QUIET,1907#endif1908NUM_FUNCTIONS1909};19101911static struct {1912char *name;1913int8 numInputs;1914flag roundingPrecision, roundingMode;1915flag tininessMode, tininessModeAtReducedPrecision;1916} functions[ NUM_FUNCTIONS ] = {1917{ 0, 0, 0, 0, 0, 0 },1918{ "int32_to_float32", 1, FALSE, TRUE, FALSE, FALSE },1919{ "int32_to_float64", 1, FALSE, FALSE, FALSE, FALSE },1920#ifdef FLOATX801921{ "int32_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE },1922#endif1923#ifdef FLOAT1281924{ "int32_to_float128", 1, FALSE, FALSE, FALSE, FALSE },1925#endif1926{ "int64_to_float32", 1, FALSE, TRUE, FALSE, FALSE },1927{ "int64_to_float64", 1, FALSE, TRUE, FALSE, FALSE },1928#ifdef FLOATX801929{ "int64_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE },1930#endif1931#ifdef FLOAT1281932{ "int64_to_float128", 1, FALSE, FALSE, FALSE, FALSE },1933#endif1934{ "float32_to_int32", 1, FALSE, TRUE, FALSE, FALSE },1935{ "float32_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },1936{ "float32_to_int64", 1, FALSE, TRUE, FALSE, FALSE },1937{ "float32_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },1938{ "float32_to_float64", 1, FALSE, FALSE, FALSE, FALSE },1939#ifdef FLOATX801940{ "float32_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE },1941#endif1942#ifdef FLOAT1281943{ "float32_to_float128", 1, FALSE, FALSE, FALSE, FALSE },1944#endif1945{ "float32_round_to_int", 1, FALSE, TRUE, FALSE, FALSE },1946{ "float32_add", 2, FALSE, TRUE, FALSE, FALSE },1947{ "float32_sub", 2, FALSE, TRUE, FALSE, FALSE },1948{ "float32_mul", 2, FALSE, TRUE, TRUE, FALSE },1949{ "float32_div", 2, FALSE, TRUE, FALSE, FALSE },1950{ "float32_rem", 2, FALSE, FALSE, FALSE, FALSE },1951{ "float32_sqrt", 1, FALSE, TRUE, FALSE, FALSE },1952{ "float32_eq", 2, FALSE, FALSE, FALSE, FALSE },1953{ "float32_le", 2, FALSE, FALSE, FALSE, FALSE },1954{ "float32_lt", 2, FALSE, FALSE, FALSE, FALSE },1955{ "float32_eq_signaling", 2, FALSE, FALSE, FALSE, FALSE },1956{ "float32_le_quiet", 2, FALSE, FALSE, FALSE, FALSE },1957{ "float32_lt_quiet", 2, FALSE, FALSE, FALSE, FALSE },1958{ "float64_to_int32", 1, FALSE, TRUE, FALSE, FALSE },1959{ "float64_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },1960{ "float64_to_int64", 1, FALSE, TRUE, FALSE, FALSE },1961{ "float64_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },1962{ "float64_to_float32", 1, FALSE, TRUE, TRUE, FALSE },1963#ifdef FLOATX801964{ "float64_to_floatx80", 1, FALSE, FALSE, FALSE, FALSE },1965#endif1966#ifdef FLOAT1281967{ "float64_to_float128", 1, FALSE, FALSE, FALSE, FALSE },1968#endif1969{ "float64_round_to_int", 1, FALSE, TRUE, FALSE, FALSE },1970{ "float64_add", 2, FALSE, TRUE, FALSE, FALSE },1971{ "float64_sub", 2, FALSE, TRUE, FALSE, FALSE },1972{ "float64_mul", 2, FALSE, TRUE, TRUE, FALSE },1973{ "float64_div", 2, FALSE, TRUE, FALSE, FALSE },1974{ "float64_rem", 2, FALSE, FALSE, FALSE, FALSE },1975{ "float64_sqrt", 1, FALSE, TRUE, FALSE, FALSE },1976{ "float64_eq", 2, FALSE, FALSE, FALSE, FALSE },1977{ "float64_le", 2, FALSE, FALSE, FALSE, FALSE },1978{ "float64_lt", 2, FALSE, FALSE, FALSE, FALSE },1979{ "float64_eq_signaling", 2, FALSE, FALSE, FALSE, FALSE },1980{ "float64_le_quiet", 2, FALSE, FALSE, FALSE, FALSE },1981{ "float64_lt_quiet", 2, FALSE, FALSE, FALSE, FALSE },1982#ifdef FLOATX801983{ "floatx80_to_int32", 1, FALSE, TRUE, FALSE, FALSE },1984{ "floatx80_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },1985{ "floatx80_to_int64", 1, FALSE, TRUE, FALSE, FALSE },1986{ "floatx80_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },1987{ "floatx80_to_float32", 1, FALSE, TRUE, TRUE, FALSE },1988{ "floatx80_to_float64", 1, FALSE, TRUE, TRUE, FALSE },1989#ifdef FLOAT1281990{ "floatx80_to_float128", 1, FALSE, FALSE, FALSE, FALSE },1991#endif1992{ "floatx80_round_to_int", 1, FALSE, TRUE, FALSE, FALSE },1993{ "floatx80_add", 2, TRUE, TRUE, FALSE, TRUE },1994{ "floatx80_sub", 2, TRUE, TRUE, FALSE, TRUE },1995{ "floatx80_mul", 2, TRUE, TRUE, TRUE, TRUE },1996{ "floatx80_div", 2, TRUE, TRUE, FALSE, TRUE },1997{ "floatx80_rem", 2, FALSE, FALSE, FALSE, FALSE },1998{ "floatx80_sqrt", 1, TRUE, TRUE, FALSE, FALSE },1999{ "floatx80_eq", 2, FALSE, FALSE, FALSE, FALSE },2000{ "floatx80_le", 2, FALSE, FALSE, FALSE, FALSE },2001{ "floatx80_lt", 2, FALSE, FALSE, FALSE, FALSE },2002{ "floatx80_eq_signaling", 2, FALSE, FALSE, FALSE, FALSE },2003{ "floatx80_le_quiet", 2, FALSE, FALSE, FALSE, FALSE },2004{ "floatx80_lt_quiet", 2, FALSE, FALSE, FALSE, FALSE },2005#endif2006#ifdef FLOAT1282007{ "float128_to_int32", 1, FALSE, TRUE, FALSE, FALSE },2008{ "float128_to_int32_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },2009{ "float128_to_int64", 1, FALSE, TRUE, FALSE, FALSE },2010{ "float128_to_int64_round_to_zero", 1, FALSE, FALSE, FALSE, FALSE },2011{ "float128_to_float32", 1, FALSE, TRUE, TRUE, FALSE },2012{ "float128_to_float64", 1, FALSE, TRUE, TRUE, FALSE },2013#ifdef FLOATX802014{ "float128_to_floatx80", 1, FALSE, TRUE, TRUE, FALSE },2015#endif2016{ "float128_round_to_int", 1, FALSE, TRUE, FALSE, FALSE },2017{ "float128_add", 2, FALSE, TRUE, FALSE, FALSE },2018{ "float128_sub", 2, FALSE, TRUE, FALSE, FALSE },2019{ "float128_mul", 2, FALSE, TRUE, TRUE, FALSE },2020{ "float128_div", 2, FALSE, TRUE, FALSE, FALSE },2021{ "float128_rem", 2, FALSE, FALSE, FALSE, FALSE },2022{ "float128_sqrt", 1, FALSE, TRUE, FALSE, FALSE },2023{ "float128_eq", 2, FALSE, FALSE, FALSE, FALSE },2024{ "float128_le", 2, FALSE, FALSE, FALSE, FALSE },2025{ "float128_lt", 2, FALSE, FALSE, FALSE, FALSE },2026{ "float128_eq_signaling", 2, FALSE, FALSE, FALSE, FALSE },2027{ "float128_le_quiet", 2, FALSE, FALSE, FALSE, FALSE },2028{ "float128_lt_quiet", 2, FALSE, FALSE, FALSE, FALSE },2029#endif2030};20312032enum {2033ROUND_NEAREST_EVEN = 1,2034ROUND_TO_ZERO,2035ROUND_DOWN,2036ROUND_UP,2037NUM_ROUNDINGMODES2038};2039enum {2040TININESS_BEFORE_ROUNDING = 1,2041TININESS_AFTER_ROUNDING,2042NUM_TININESSMODES2043};20442045static void2046timeFunctionVariety(2047uint8 functionCode,2048int8 roundingPrecision,2049int8 roundingMode,2050int8 tininessMode2051)2052{2053uint8 roundingCode;2054int8 tininessCode;20552056functionName = functions[ functionCode ].name;2057if ( roundingPrecision == 32 ) {2058roundingPrecisionName = "32";2059}2060else if ( roundingPrecision == 64 ) {2061roundingPrecisionName = "64";2062}2063else if ( roundingPrecision == 80 ) {2064roundingPrecisionName = "80";2065}2066else {2067roundingPrecisionName = NULL;2068}2069#ifdef FLOATX802070floatx80_rounding_precision = roundingPrecision;2071#endif2072switch ( roundingMode ) {2073case 0:2074roundingModeName = NULL;2075roundingCode = float_round_nearest_even;2076break;2077case ROUND_NEAREST_EVEN:2078roundingModeName = "nearest_even";2079roundingCode = float_round_nearest_even;2080break;2081case ROUND_TO_ZERO:2082roundingModeName = "to_zero";2083roundingCode = float_round_to_zero;2084break;2085case ROUND_DOWN:2086roundingModeName = "down";2087roundingCode = float_round_down;2088break;2089case ROUND_UP:2090roundingModeName = "up";2091roundingCode = float_round_up;2092break;2093}2094float_rounding_mode = roundingCode;2095switch ( tininessMode ) {2096case 0:2097tininessModeName = NULL;2098tininessCode = float_tininess_after_rounding;2099break;2100case TININESS_BEFORE_ROUNDING:2101tininessModeName = "before";2102tininessCode = float_tininess_before_rounding;2103break;2104case TININESS_AFTER_ROUNDING:2105tininessModeName = "after";2106tininessCode = float_tininess_after_rounding;2107break;2108}2109float_detect_tininess = tininessCode;2110switch ( functionCode ) {2111case INT32_TO_FLOAT32:2112time_a_int32_z_float32( int32_to_float32 );2113break;2114case INT32_TO_FLOAT64:2115time_a_int32_z_float64( int32_to_float64 );2116break;2117#ifdef FLOATX802118case INT32_TO_FLOATX80:2119time_a_int32_z_floatx80( int32_to_floatx80 );2120break;2121#endif2122#ifdef FLOAT1282123case INT32_TO_FLOAT128:2124time_a_int32_z_float128( int32_to_float128 );2125break;2126#endif2127case INT64_TO_FLOAT32:2128time_a_int64_z_float32( int64_to_float32 );2129break;2130case INT64_TO_FLOAT64:2131time_a_int64_z_float64( int64_to_float64 );2132break;2133#ifdef FLOATX802134case INT64_TO_FLOATX80:2135time_a_int64_z_floatx80( int64_to_floatx80 );2136break;2137#endif2138#ifdef FLOAT1282139case INT64_TO_FLOAT128:2140time_a_int64_z_float128( int64_to_float128 );2141break;2142#endif2143case FLOAT32_TO_INT32:2144time_a_float32_z_int32( float32_to_int32 );2145break;2146case FLOAT32_TO_INT32_ROUND_TO_ZERO:2147time_a_float32_z_int32( float32_to_int32_round_to_zero );2148break;2149case FLOAT32_TO_INT64:2150time_a_float32_z_int64( float32_to_int64 );2151break;2152case FLOAT32_TO_INT64_ROUND_TO_ZERO:2153time_a_float32_z_int64( float32_to_int64_round_to_zero );2154break;2155case FLOAT32_TO_FLOAT64:2156time_a_float32_z_float64( float32_to_float64 );2157break;2158#ifdef FLOATX802159case FLOAT32_TO_FLOATX80:2160time_a_float32_z_floatx80( float32_to_floatx80 );2161break;2162#endif2163#ifdef FLOAT1282164case FLOAT32_TO_FLOAT128:2165time_a_float32_z_float128( float32_to_float128 );2166break;2167#endif2168case FLOAT32_ROUND_TO_INT:2169time_az_float32( float32_round_to_int );2170break;2171case FLOAT32_ADD:2172time_abz_float32( float32_add );2173break;2174case FLOAT32_SUB:2175time_abz_float32( float32_sub );2176break;2177case FLOAT32_MUL:2178time_abz_float32( float32_mul );2179break;2180case FLOAT32_DIV:2181time_abz_float32( float32_div );2182break;2183case FLOAT32_REM:2184time_abz_float32( float32_rem );2185break;2186case FLOAT32_SQRT:2187time_az_float32_pos( float32_sqrt );2188break;2189case FLOAT32_EQ:2190time_ab_float32_z_flag( float32_eq );2191break;2192case FLOAT32_LE:2193time_ab_float32_z_flag( float32_le );2194break;2195case FLOAT32_LT:2196time_ab_float32_z_flag( float32_lt );2197break;2198case FLOAT32_EQ_SIGNALING:2199time_ab_float32_z_flag( float32_eq_signaling );2200break;2201case FLOAT32_LE_QUIET:2202time_ab_float32_z_flag( float32_le_quiet );2203break;2204case FLOAT32_LT_QUIET:2205time_ab_float32_z_flag( float32_lt_quiet );2206break;2207case FLOAT64_TO_INT32:2208time_a_float64_z_int32( float64_to_int32 );2209break;2210case FLOAT64_TO_INT32_ROUND_TO_ZERO:2211time_a_float64_z_int32( float64_to_int32_round_to_zero );2212break;2213case FLOAT64_TO_INT64:2214time_a_float64_z_int64( float64_to_int64 );2215break;2216case FLOAT64_TO_INT64_ROUND_TO_ZERO:2217time_a_float64_z_int64( float64_to_int64_round_to_zero );2218break;2219case FLOAT64_TO_FLOAT32:2220time_a_float64_z_float32( float64_to_float32 );2221break;2222#ifdef FLOATX802223case FLOAT64_TO_FLOATX80:2224time_a_float64_z_floatx80( float64_to_floatx80 );2225break;2226#endif2227#ifdef FLOAT1282228case FLOAT64_TO_FLOAT128:2229time_a_float64_z_float128( float64_to_float128 );2230break;2231#endif2232case FLOAT64_ROUND_TO_INT:2233time_az_float64( float64_round_to_int );2234break;2235case FLOAT64_ADD:2236time_abz_float64( float64_add );2237break;2238case FLOAT64_SUB:2239time_abz_float64( float64_sub );2240break;2241case FLOAT64_MUL:2242time_abz_float64( float64_mul );2243break;2244case FLOAT64_DIV:2245time_abz_float64( float64_div );2246break;2247case FLOAT64_REM:2248time_abz_float64( float64_rem );2249break;2250case FLOAT64_SQRT:2251time_az_float64_pos( float64_sqrt );2252break;2253case FLOAT64_EQ:2254time_ab_float64_z_flag( float64_eq );2255break;2256case FLOAT64_LE:2257time_ab_float64_z_flag( float64_le );2258break;2259case FLOAT64_LT:2260time_ab_float64_z_flag( float64_lt );2261break;2262case FLOAT64_EQ_SIGNALING:2263time_ab_float64_z_flag( float64_eq_signaling );2264break;2265case FLOAT64_LE_QUIET:2266time_ab_float64_z_flag( float64_le_quiet );2267break;2268case FLOAT64_LT_QUIET:2269time_ab_float64_z_flag( float64_lt_quiet );2270break;2271#ifdef FLOATX802272case FLOATX80_TO_INT32:2273time_a_floatx80_z_int32( floatx80_to_int32 );2274break;2275case FLOATX80_TO_INT32_ROUND_TO_ZERO:2276time_a_floatx80_z_int32( floatx80_to_int32_round_to_zero );2277break;2278case FLOATX80_TO_INT64:2279time_a_floatx80_z_int64( floatx80_to_int64 );2280break;2281case FLOATX80_TO_INT64_ROUND_TO_ZERO:2282time_a_floatx80_z_int64( floatx80_to_int64_round_to_zero );2283break;2284case FLOATX80_TO_FLOAT32:2285time_a_floatx80_z_float32( floatx80_to_float32 );2286break;2287case FLOATX80_TO_FLOAT64:2288time_a_floatx80_z_float64( floatx80_to_float64 );2289break;2290#ifdef FLOAT1282291case FLOATX80_TO_FLOAT128:2292time_a_floatx80_z_float128( floatx80_to_float128 );2293break;2294#endif2295case FLOATX80_ROUND_TO_INT:2296time_az_floatx80( floatx80_round_to_int );2297break;2298case FLOATX80_ADD:2299time_abz_floatx80( floatx80_add );2300break;2301case FLOATX80_SUB:2302time_abz_floatx80( floatx80_sub );2303break;2304case FLOATX80_MUL:2305time_abz_floatx80( floatx80_mul );2306break;2307case FLOATX80_DIV:2308time_abz_floatx80( floatx80_div );2309break;2310case FLOATX80_REM:2311time_abz_floatx80( floatx80_rem );2312break;2313case FLOATX80_SQRT:2314time_az_floatx80_pos( floatx80_sqrt );2315break;2316case FLOATX80_EQ:2317time_ab_floatx80_z_flag( floatx80_eq );2318break;2319case FLOATX80_LE:2320time_ab_floatx80_z_flag( floatx80_le );2321break;2322case FLOATX80_LT:2323time_ab_floatx80_z_flag( floatx80_lt );2324break;2325case FLOATX80_EQ_SIGNALING:2326time_ab_floatx80_z_flag( floatx80_eq_signaling );2327break;2328case FLOATX80_LE_QUIET:2329time_ab_floatx80_z_flag( floatx80_le_quiet );2330break;2331case FLOATX80_LT_QUIET:2332time_ab_floatx80_z_flag( floatx80_lt_quiet );2333break;2334#endif2335#ifdef FLOAT1282336case FLOAT128_TO_INT32:2337time_a_float128_z_int32( float128_to_int32 );2338break;2339case FLOAT128_TO_INT32_ROUND_TO_ZERO:2340time_a_float128_z_int32( float128_to_int32_round_to_zero );2341break;2342case FLOAT128_TO_INT64:2343time_a_float128_z_int64( float128_to_int64 );2344break;2345case FLOAT128_TO_INT64_ROUND_TO_ZERO:2346time_a_float128_z_int64( float128_to_int64_round_to_zero );2347break;2348case FLOAT128_TO_FLOAT32:2349time_a_float128_z_float32( float128_to_float32 );2350break;2351case FLOAT128_TO_FLOAT64:2352time_a_float128_z_float64( float128_to_float64 );2353break;2354#ifdef FLOATX802355case FLOAT128_TO_FLOATX80:2356time_a_float128_z_floatx80( float128_to_floatx80 );2357break;2358#endif2359case FLOAT128_ROUND_TO_INT:2360time_az_float128( float128_round_to_int );2361break;2362case FLOAT128_ADD:2363time_abz_float128( float128_add );2364break;2365case FLOAT128_SUB:2366time_abz_float128( float128_sub );2367break;2368case FLOAT128_MUL:2369time_abz_float128( float128_mul );2370break;2371case FLOAT128_DIV:2372time_abz_float128( float128_div );2373break;2374case FLOAT128_REM:2375time_abz_float128( float128_rem );2376break;2377case FLOAT128_SQRT:2378time_az_float128_pos( float128_sqrt );2379break;2380case FLOAT128_EQ:2381time_ab_float128_z_flag( float128_eq );2382break;2383case FLOAT128_LE:2384time_ab_float128_z_flag( float128_le );2385break;2386case FLOAT128_LT:2387time_ab_float128_z_flag( float128_lt );2388break;2389case FLOAT128_EQ_SIGNALING:2390time_ab_float128_z_flag( float128_eq_signaling );2391break;2392case FLOAT128_LE_QUIET:2393time_ab_float128_z_flag( float128_le_quiet );2394break;2395case FLOAT128_LT_QUIET:2396time_ab_float128_z_flag( float128_lt_quiet );2397break;2398#endif2399}24002401}24022403static void2404timeFunction(2405uint8 functionCode,2406int8 roundingPrecisionIn,2407int8 roundingModeIn,2408int8 tininessModeIn2409)2410{2411int8 roundingPrecision, roundingMode, tininessMode;24122413roundingPrecision = 32;2414for (;;) {2415if ( ! functions[ functionCode ].roundingPrecision ) {2416roundingPrecision = 0;2417}2418else if ( roundingPrecisionIn ) {2419roundingPrecision = roundingPrecisionIn;2420}2421for ( roundingMode = 1;2422roundingMode < NUM_ROUNDINGMODES;2423++roundingMode2424) {2425if ( ! functions[ functionCode ].roundingMode ) {2426roundingMode = 0;2427}2428else if ( roundingModeIn ) {2429roundingMode = roundingModeIn;2430}2431for ( tininessMode = 1;2432tininessMode < NUM_TININESSMODES;2433++tininessMode2434) {2435if ( ( roundingPrecision == 32 )2436|| ( roundingPrecision == 64 ) ) {2437if ( ! functions[ functionCode ]2438.tininessModeAtReducedPrecision2439) {2440tininessMode = 0;2441}2442else if ( tininessModeIn ) {2443tininessMode = tininessModeIn;2444}2445}2446else {2447if ( ! functions[ functionCode ].tininessMode ) {2448tininessMode = 0;2449}2450else if ( tininessModeIn ) {2451tininessMode = tininessModeIn;2452}2453}2454timeFunctionVariety(2455functionCode, roundingPrecision, roundingMode, tininessMode2456);2457if ( tininessModeIn || ! tininessMode ) break;2458}2459if ( roundingModeIn || ! roundingMode ) break;2460}2461if ( roundingPrecisionIn || ! roundingPrecision ) break;2462if ( roundingPrecision == 80 ) {2463break;2464}2465else if ( roundingPrecision == 64 ) {2466roundingPrecision = 80;2467}2468else if ( roundingPrecision == 32 ) {2469roundingPrecision = 64;2470}2471}24722473}24742475main( int argc, char **argv )2476{2477char *argPtr;2478flag functionArgument;2479uint8 functionCode;2480int8 operands, roundingPrecision, roundingMode, tininessMode;24812482if ( argc <= 1 ) goto writeHelpMessage;2483functionArgument = FALSE;2484functionCode = 0;2485operands = 0;2486roundingPrecision = 0;2487roundingMode = 0;2488tininessMode = 0;2489--argc;2490++argv;2491while ( argc && ( argPtr = argv[ 0 ] ) ) {2492if ( argPtr[ 0 ] == '-' ) ++argPtr;2493if ( strcmp( argPtr, "help" ) == 0 ) {2494writeHelpMessage:2495fputs(2496"timesoftfloat [<option>...] <function>\n"2497" <option>: (* is default)\n"2498" -help --Write this message and exit.\n"2499#ifdef FLOATX802500" -precision32 --Only time rounding precision equivalent to float32.\n"2501" -precision64 --Only time rounding precision equivalent to float64.\n"2502" -precision80 --Only time maximum rounding precision.\n"2503#endif2504" -nearesteven --Only time rounding to nearest/even.\n"2505" -tozero --Only time rounding to zero.\n"2506" -down --Only time rounding down.\n"2507" -up --Only time rounding up.\n"2508" -tininessbefore --Only time underflow tininess before rounding.\n"2509" -tininessafter --Only time underflow tininess after rounding.\n"2510" <function>:\n"2511" int32_to_<float> <float>_add <float>_eq\n"2512" <float>_to_int32 <float>_sub <float>_le\n"2513" <float>_to_int32_round_to_zero <float>_mul <float>_lt\n"2514" int64_to_<float> <float>_div <float>_eq_signaling\n"2515" <float>_to_int64 <float>_rem <float>_le_quiet\n"2516" <float>_to_int64_round_to_zero <float>_lt_quiet\n"2517" <float>_to_<float>\n"2518" <float>_round_to_int\n"2519" <float>_sqrt\n"2520" -all1 --All 1-operand functions.\n"2521" -all2 --All 2-operand functions.\n"2522" -all --All functions.\n"2523" <float>:\n"2524" float32 --Single precision.\n"2525" float64 --Double precision.\n"2526#ifdef FLOATX802527" floatx80 --Extended double precision.\n"2528#endif2529#ifdef FLOAT1282530" float128 --Quadruple precision.\n"2531#endif2532,2533stdout2534);2535return EXIT_SUCCESS;2536}2537#ifdef FLOATX802538else if ( strcmp( argPtr, "precision32" ) == 0 ) {2539roundingPrecision = 32;2540}2541else if ( strcmp( argPtr, "precision64" ) == 0 ) {2542roundingPrecision = 64;2543}2544else if ( strcmp( argPtr, "precision80" ) == 0 ) {2545roundingPrecision = 80;2546}2547#endif2548else if ( ( strcmp( argPtr, "nearesteven" ) == 0 )2549|| ( strcmp( argPtr, "nearest_even" ) == 0 ) ) {2550roundingMode = ROUND_NEAREST_EVEN;2551}2552else if ( ( strcmp( argPtr, "tozero" ) == 0 )2553|| ( strcmp( argPtr, "to_zero" ) == 0 ) ) {2554roundingMode = ROUND_TO_ZERO;2555}2556else if ( strcmp( argPtr, "down" ) == 0 ) {2557roundingMode = ROUND_DOWN;2558}2559else if ( strcmp( argPtr, "up" ) == 0 ) {2560roundingMode = ROUND_UP;2561}2562else if ( strcmp( argPtr, "tininessbefore" ) == 0 ) {2563tininessMode = TININESS_BEFORE_ROUNDING;2564}2565else if ( strcmp( argPtr, "tininessafter" ) == 0 ) {2566tininessMode = TININESS_AFTER_ROUNDING;2567}2568else if ( strcmp( argPtr, "all1" ) == 0 ) {2569functionArgument = TRUE;2570functionCode = 0;2571operands = 1;2572}2573else if ( strcmp( argPtr, "all2" ) == 0 ) {2574functionArgument = TRUE;2575functionCode = 0;2576operands = 2;2577}2578else if ( strcmp( argPtr, "all" ) == 0 ) {2579functionArgument = TRUE;2580functionCode = 0;2581operands = 0;2582}2583else {2584for ( functionCode = 1;2585functionCode < NUM_FUNCTIONS;2586++functionCode2587) {2588if ( strcmp( argPtr, functions[ functionCode ].name ) == 0 ) {2589break;2590}2591}2592if ( functionCode == NUM_FUNCTIONS ) {2593fail( "Invalid option or function `%s'", argv[ 0 ] );2594}2595functionArgument = TRUE;2596}2597--argc;2598++argv;2599}2600if ( ! functionArgument ) fail( "Function argument required" );2601if ( functionCode ) {2602timeFunction(2603functionCode, roundingPrecision, roundingMode, tininessMode );2604}2605else if ( operands == 1 ) {2606for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode2607) {2608if ( functions[ functionCode ].numInputs == 1 ) {2609timeFunction(2610functionCode, roundingPrecision, roundingMode, tininessMode2611);2612}2613}2614}2615else if ( operands == 2 ) {2616for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode2617) {2618if ( functions[ functionCode ].numInputs == 2 ) {2619timeFunction(2620functionCode, roundingPrecision, roundingMode, tininessMode2621);2622}2623}2624}2625else {2626for ( functionCode = 1; functionCode < NUM_FUNCTIONS; ++functionCode2627) {2628timeFunction(2629functionCode, roundingPrecision, roundingMode, tininessMode );2630}2631}2632return EXIT_SUCCESS;26332634}2635263626372638