@@ -385,7 +385,7 @@ _mm_cvtpd_epi32(__m128d __a)
385
385
{
386
386
double e = __a [i ];
387
387
int x = lrint (e );
388
- if ((x != 0 || fabs (e ) < 2.0 ) && ! isnan ( e ) && e <= INT_MAX && e >= INT_MIN )
388
+ if (e <= INT_MAX && e >= INT_MIN && (x != 0 || fabs (e ) < 2.0 ))
389
389
m [i ] = x ;
390
390
else
391
391
m [i ] = (int )0x80000000 ;
@@ -399,7 +399,7 @@ _mm_cvtsd_si32(__m128d __a)
399
399
// TODO: OPTIMIZE!
400
400
double e = __a [0 ];
401
401
int x = lrint (e );
402
- if ((x != 0 || fabs (e ) < 2.0 ) && ! isnan ( e ) && e <= INT_MAX && e >= INT_MIN )
402
+ if (e <= INT_MAX && e >= INT_MIN && (x != 0 || fabs (e ) < 2.0 ))
403
403
return x ;
404
404
else
405
405
return (int )0x80000000 ;
@@ -433,11 +433,11 @@ _mm_cvttpd_epi32(__m128d __a)
433
433
int m [2 ];
434
434
for (int i = 0 ; i < 2 ; ++ i )
435
435
{
436
- float elem = __a [i ];
437
- if (( lrint ( elem ) != 0 || fabs ( elem ) < 2.0 ) && ! isnanf ( elem ) && elem <= INT_MAX && elem >= INT_MIN )
436
+ double elem = __a [i ];
437
+ if (elem < 2147483648.0 && elem >= -2147483648.0 && ( lrint ( elem ) != 0 || fabs ( elem ) < 2.0 ) )
438
438
// Use the trapping instruction here since we have explicit bounds checks
439
439
// above.
440
- m [i ] = __builtin_wasm_trunc_s_i32_f32 (elem );
440
+ m [i ] = __builtin_wasm_trunc_s_i32_f64 (elem );
441
441
else
442
442
m [i ] = (int )0x80000000 ;
443
443
}
@@ -448,11 +448,11 @@ static __inline__ int __attribute__((__always_inline__, __nodebug__))
448
448
_mm_cvttsd_si32 (__m128d __a )
449
449
{
450
450
// TODO: OPTIMIZE!
451
- float elem = __a [0 ];
452
- if (( lrint ( elem ) != 0 || fabs ( elem ) < 2.0 ) && ! isnanf ( elem ) && elem <= INT_MAX && elem >= INT_MIN )
451
+ double elem = __a [0 ];
452
+ if (elem < 2147483648.0 && elem >= -2147483648.0 && ( lrint ( elem ) != 0 || fabs ( elem ) < 2.0 ) )
453
453
// Use the trapping instruction here since we have explicit bounds checks
454
454
// above.
455
- return __builtin_wasm_trunc_s_i32_f32 (elem );
455
+ return __builtin_wasm_trunc_s_i32_f64 (elem );
456
456
else
457
457
return (int )0x80000000 ;
458
458
}
@@ -1010,7 +1010,7 @@ _mm_cvtsd_si64(__m128d __a)
1010
1010
double e = __a [0 ];
1011
1011
if (isnan (e ) || isinf (e )) return 0x8000000000000000LL ;
1012
1012
long long x = llrint (e );
1013
- if (x != 0xFFFFFFFF00000000ULL && (x != 0 || fabs (e ) < 2.f ) && e <= LLONG_MAX && e >= LLONG_MIN )
1013
+ if (e <= LLONG_MAX && e >= LLONG_MIN && (x != 0 || fabs (e ) < 2.f ))
1014
1014
return x ;
1015
1015
else
1016
1016
return 0x8000000000000000LL ;
@@ -1023,10 +1023,10 @@ _mm_cvttsd_si64(__m128d __a)
1023
1023
double e = __a [0 ];
1024
1024
if (isnan (e ) || isinf (e ) || e > LLONG_MAX || e < LLONG_MIN ) return 0x8000000000000000LL ;
1025
1025
long long x = llrint (e );
1026
- if (x != 0xFFFFFFFF00000000ULL && ( x != 0 || fabs (e ) < 2.f ) )
1026
+ if (x != 0 || fabs (e ) < 2.f )
1027
1027
// Use the trapping instruction here since we have explicit bounds checks
1028
1028
// above
1029
- return __builtin_wasm_trunc_s_i64_f32 (e );
1029
+ return __builtin_wasm_trunc_s_i64_f64 (e );
1030
1030
else
1031
1031
return 0x8000000000000000LL ;
1032
1032
}
@@ -1049,7 +1049,7 @@ _mm_cvtps_epi32(__m128 __a)
1049
1049
{
1050
1050
double e = __a [i ];
1051
1051
int x = lrint (e );
1052
- if ((x != 0 || fabs (e ) < 2.0 ) && ! isnan ( e ) && e <= INT_MAX && e >= INT_MIN )
1052
+ if (e <= INT_MAX && e >= INT_MIN && (x != 0 || fabs (e ) < 2.0 ))
1053
1053
u .x [i ] = x ;
1054
1054
else
1055
1055
u .x [i ] = (int )0x80000000 ;
@@ -1068,8 +1068,7 @@ _mm_cvttps_epi32(__m128 __a)
1068
1068
for (int i = 0 ; i < 4 ; ++ i )
1069
1069
{
1070
1070
float e = __a [i ];
1071
- int x = lrint (e );
1072
- if ((x != 0 || fabs (e ) < 2.0 ) && !isnanf (e ) && e <= INT_MAX && e >= INT_MIN )
1071
+ if (e < 2147483648.0f && e >= -2147483648.0f && (lrint (e ) != 0 || fabs (e ) < 2.0 ))
1073
1072
// Use the trapping instruction here since we have explicit bounds checks
1074
1073
// above.
1075
1074
u .x [i ] = __builtin_wasm_trunc_s_i32_f32 (e );
0 commit comments