@@ -596,8 +596,9 @@ _mm_cvtsi32_ss(__m128 __a, int __b)
596596
597597static __inline__ int __attribute__((__always_inline__ , __nodebug__ , DIAGNOSE_SLOW )) _mm_cvtss_si32 (__m128 __a )
598598{
599- int x = lrint (((__f32x4 )__a )[0 ]);
600- if (x != 0 || fabsf (((__f32x4 )__a )[0 ]) < 2.f )
599+ float e = ((__f32x4 )__a )[0 ];
600+ int x = lrint (e );
601+ if ((x != 0 || fabsf (e )) < 2.f && !isnan (e ) && e <= INT_MAX && e >= INT_MIN )
601602 return x ;
602603 else
603604 return (int )0x80000000 ;
@@ -607,9 +608,8 @@ static __inline__ int __attribute__((__always_inline__, __nodebug__, DIAGNOSE_SL
607608static __inline__ int __attribute__((__always_inline__ , __nodebug__ , DIAGNOSE_SLOW )) _mm_cvttss_si32 (__m128 __a )
608609{
609610 float e = ((__f32x4 )__a )[0 ];
610- if (isnanf (e ) || e > INT_MAX || e < INT_MIN ) return (int )0x80000000 ;
611611 int x = lrint (e );
612- if ((x != 0 || fabsf (e ) < 2.f ))
612+ if ((x != 0 || fabsf (e ) < 2.f ) && ! isnanf ( e ) && e <= INT_MAX && e >= INT_MIN )
613613 return (int )e ;
614614 else
615615 return (int )0x80000000 ;
@@ -627,9 +627,9 @@ _mm_cvtsi64_ss(__m128 __a, long long __b)
627627static __inline__ long long __attribute__((__always_inline__ , __nodebug__ , DIAGNOSE_SLOW ))
628628_mm_cvtss_si64 (__m128 __a )
629629{
630- if ( isnan ((( __f32x4 ) __a )[ 0 ]) || isinf ((( __f32x4 )__a )[0 ])) return 0x8000000000000000LL ;
631- long long x = llrintf ((( __f32x4 ) __a )[ 0 ] );
632- if (x != 0xFFFFFFFF00000000ULL && (x != 0 || fabsf ((( __f32x4 ) __a )[ 0 ]) < 2.f ))
630+ float e = (( __f32x4 )__a )[0 ];
631+ long long x = llrintf (e );
632+ if (( x != 0xFFFFFFFF00000000ULL && (x != 0 || fabsf (e ) < 2.f )) && ! isnanf ( e ) && e <= LLONG_MAX && e >= LLONG_MIN )
633633 return x ;
634634 else
635635 return 0x8000000000000000LL ;
@@ -639,9 +639,8 @@ static __inline__ long long __attribute__((__always_inline__, __nodebug__, DIAGN
639639_mm_cvttss_si64 (__m128 __a )
640640{
641641 float e = ((__f32x4 )__a )[0 ];
642- if (isnan (e ) || isinf (e ) || e > LLONG_MAX || e < LLONG_MIN ) return 0x8000000000000000LL ;
643642 long long x = llrintf (e );
644- if (x != 0xFFFFFFFF00000000ULL && (x != 0 || fabsf (e ) < 2.f ))
643+ if (x != 0xFFFFFFFF00000000ULL && (x != 0 || fabsf (e ) < 2.f ) && ! isnanf ( e ) && e <= LLONG_MAX && e >= LLONG_MIN )
645644 return (long long )e ;
646645 else
647646 return 0x8000000000000000LL ;
0 commit comments