Skip to content

Commit bb889e7

Browse files
committed
Fix lto2.test_avx_nontrapping
Followup to #22893
1 parent f15419f commit bb889e7

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ jobs:
544544
test_targets: "
545545
lto2.test_dylink_syslibs_all
546546
lto2.test_float_builtins
547+
lto2.test_avx_nontrapping
547548
lto0.test_exceptions_allowed_uncaught
548549
lto0.test_longjmp_standalone_standalone
549550
lto0.test_embind_i64_val

system/include/compat/emmintrin.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,9 @@ _mm_cvtpd_epi32(__m128d __a)
383383
int m[2];
384384
for(int i = 0; i < 2; ++i)
385385
{
386-
int x = lrint(__a[i]);
387-
if (x != 0 || fabs(__a[i]) < 2.0)
386+
double e = __a[i];
387+
int x = lrint(e);
388+
if ((x != 0 || fabs(e) < 2.0) && !isnan(e) && e <= INT_MAX && e >= INT_MIN)
388389
m[i] = (int)x;
389390
else
390391
m[i] = (int)0x80000000;
@@ -396,8 +397,9 @@ static __inline__ int __attribute__((__always_inline__, __nodebug__))
396397
_mm_cvtsd_si32(__m128d __a)
397398
{
398399
// TODO: OPTIMIZE!
399-
int x = lrint(__a[0]);
400-
if (x != 0 || fabs(__a[0]) < 2.0)
400+
double e = __a[0];
401+
int x = lrint(e);
402+
if ((x != 0 || fabs(e) < 2.0) && !isnan(e) && e <= INT_MAX && e >= INT_MIN)
401403
return (int)x;
402404
else
403405
return (int)0x80000000;
@@ -1045,8 +1047,9 @@ _mm_cvtps_epi32(__m128 __a)
10451047
} u;
10461048
for(int i = 0; i < 4; ++i)
10471049
{
1048-
int x = lrint(__a[i]);
1049-
if (x != 0 || fabs(__a[i]) < 2.0)
1050+
double e = __a[i];
1051+
int x = lrint(e);
1052+
if ((x != 0 || fabs(e) < 2.0) && !isnanf(e) && e <= INT_MAX && e >= INT_MIN)
10501053
u.x[i] = x;
10511054
else
10521055
u.x[i] = (int)0x80000000;

0 commit comments

Comments
 (0)