@@ -596,8 +596,9 @@ _mm_cvtsi32_ss(__m128 __a, int __b)
596
596
597
597
static __inline__ int __attribute__((__always_inline__ , __nodebug__ , DIAGNOSE_SLOW )) _mm_cvtss_si32 (__m128 __a )
598
598
{
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 )
601
602
return x ;
602
603
else
603
604
return (int )0x80000000 ;
@@ -607,9 +608,8 @@ static __inline__ int __attribute__((__always_inline__, __nodebug__, DIAGNOSE_SL
607
608
static __inline__ int __attribute__((__always_inline__ , __nodebug__ , DIAGNOSE_SLOW )) _mm_cvttss_si32 (__m128 __a )
608
609
{
609
610
float e = ((__f32x4 )__a )[0 ];
610
- if (isnanf (e ) || e > INT_MAX || e < INT_MIN ) return (int )0x80000000 ;
611
611
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 )
613
613
return (int )e ;
614
614
else
615
615
return (int )0x80000000 ;
@@ -627,9 +627,9 @@ _mm_cvtsi64_ss(__m128 __a, long long __b)
627
627
static __inline__ long long __attribute__((__always_inline__ , __nodebug__ , DIAGNOSE_SLOW ))
628
628
_mm_cvtss_si64 (__m128 __a )
629
629
{
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 )
633
633
return x ;
634
634
else
635
635
return 0x8000000000000000LL ;
@@ -639,9 +639,8 @@ static __inline__ long long __attribute__((__always_inline__, __nodebug__, DIAGN
639
639
_mm_cvttss_si64 (__m128 __a )
640
640
{
641
641
float e = ((__f32x4 )__a )[0 ];
642
- if (isnan (e ) || isinf (e ) || e > LLONG_MAX || e < LLONG_MIN ) return 0x8000000000000000LL ;
643
642
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 )
645
644
return (long long )e ;
646
645
else
647
646
return 0x8000000000000000LL ;
0 commit comments