From 5a79943f7dc00f2b637b35deec4045d0c16f94c0 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 12 Mar 2012 17:40:43 -0700 Subject: [PATCH] always propagate default NaN (all bits set) --- softfloat_riscv/s_propagateNaNF32UI.c | 34 ++------------------------- softfloat_riscv/s_propagateNaNF64UI.c | 34 ++------------------------- 2 files changed, 4 insertions(+), 64 deletions(-) diff --git a/softfloat_riscv/s_propagateNaNF32UI.c b/softfloat_riscv/s_propagateNaNF32UI.c index 07774e8..d8738d1 100755 --- a/softfloat_riscv/s_propagateNaNF32UI.c +++ b/softfloat_riscv/s_propagateNaNF32UI.c @@ -17,39 +17,9 @@ uint_fast32_t softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB ) { - bool isNaNA, isSigNaNA, isNaNB, isSigNaNB; - uint_fast32_t uiMagA, uiMagB; - - /*------------------------------------------------------------------------ - *------------------------------------------------------------------------*/ - isNaNA = isNaNF32UI( uiA ); - isSigNaNA = softfloat_isSigNaNF32UI( uiA ); - isNaNB = isNaNF32UI( uiB ); - isSigNaNB = softfloat_isSigNaNF32UI( uiB ); - /*------------------------------------------------------------------------ - | Make NaNs non-signaling. - *------------------------------------------------------------------------*/ - uiA |= 0x00400000; - uiB |= 0x00400000; - /*------------------------------------------------------------------------ - *------------------------------------------------------------------------*/ - if ( isSigNaNA | isSigNaNB ) { + if ( softfloat_isSigNaNF32UI( uiA ) | softfloat_isSigNaNF32UI( uiB ) ) { softfloat_raiseFlags( softfloat_flag_invalid ); } - if ( isSigNaNA ) { - if ( isSigNaNB ) goto returnLargerSignificand; - return isNaNB ? uiB : uiA; - } else if ( isNaNA ) { - if ( isSigNaNB || ! isNaNB ) return uiA; - returnLargerSignificand: - uiMagA = uiA<<1; - uiMagB = uiB<<1; - if ( uiMagA < uiMagB ) return uiB; - if ( uiMagB < uiMagA ) return uiA; - return ( uiA < uiB ) ? uiA : uiB; - } else { - return uiB; - } - + return defaultNaNF32UI; } diff --git a/softfloat_riscv/s_propagateNaNF64UI.c b/softfloat_riscv/s_propagateNaNF64UI.c index 0ff6446..871989d 100755 --- a/softfloat_riscv/s_propagateNaNF64UI.c +++ b/softfloat_riscv/s_propagateNaNF64UI.c @@ -17,39 +17,9 @@ uint_fast64_t softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB ) { - bool isNaNA, isSigNaNA, isNaNB, isSigNaNB; - uint_fast64_t uiMagA, uiMagB; - - /*------------------------------------------------------------------------ - *------------------------------------------------------------------------*/ - isNaNA = isNaNF64UI( uiA ); - isSigNaNA = softfloat_isSigNaNF64UI( uiA ); - isNaNB = isNaNF64UI( uiB ); - isSigNaNB = softfloat_isSigNaNF64UI( uiB ); - /*------------------------------------------------------------------------ - | Make NaNs non-signaling. - *------------------------------------------------------------------------*/ - uiA |= UINT64_C( 0x0008000000000000 ); - uiB |= UINT64_C( 0x0008000000000000 ); - /*------------------------------------------------------------------------ - *------------------------------------------------------------------------*/ - if ( isSigNaNA | isSigNaNB ) { + if ( softfloat_isSigNaNF64UI( uiA ) | softfloat_isSigNaNF64UI( uiB ) ) { softfloat_raiseFlags( softfloat_flag_invalid ); } - if ( isSigNaNA ) { - if ( isSigNaNB ) goto returnLargerSignificand; - return isNaNB ? uiB : uiA; - } else if ( isNaNA ) { - if ( isSigNaNB || ! isNaNB ) return uiA; - returnLargerSignificand: - uiMagA = uiA & UINT64_C( 0x7FFFFFFFFFFFFFFF ); - uiMagB = uiB & UINT64_C( 0x7FFFFFFFFFFFFFFF ); - if ( uiMagA < uiMagB ) return uiB; - if ( uiMagB < uiMagA ) return uiA; - return ( uiA < uiB ) ? uiA : uiB; - } else { - return uiB; - } - + return defaultNaNF64UI; } -- 2.30.2