Skip to content

Commit

Permalink
Fix lto2.test_avx_nontrapping (#22911)
Browse files Browse the repository at this point in the history
Followup to #22893
  • Loading branch information
sbc100 authored Nov 12, 2024
1 parent ae4a548 commit 5c81135
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ jobs:
test_targets: "
lto2.test_dylink_syslibs_all
lto2.test_float_builtins
lto2.test_avx_nontrapping
lto0.test_exceptions_allowed_uncaught
lto0.test_longjmp_standalone_standalone
lto0.test_embind_i64_val
Expand Down
19 changes: 11 additions & 8 deletions system/include/compat/emmintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,10 @@ _mm_cvtpd_epi32(__m128d __a)
int m[2];
for(int i = 0; i < 2; ++i)
{
int x = lrint(__a[i]);
if (x != 0 || fabs(__a[i]) < 2.0)
m[i] = (int)x;
double e = __a[i];
int x = lrint(e);
if ((x != 0 || fabs(e) < 2.0) && !isnan(e) && e <= INT_MAX && e >= INT_MIN)
m[i] = x;
else
m[i] = (int)0x80000000;
}
Expand All @@ -396,9 +397,10 @@ static __inline__ int __attribute__((__always_inline__, __nodebug__))
_mm_cvtsd_si32(__m128d __a)
{
// TODO: OPTIMIZE!
int x = lrint(__a[0]);
if (x != 0 || fabs(__a[0]) < 2.0)
return (int)x;
double e = __a[0];
int x = lrint(e);
if ((x != 0 || fabs(e) < 2.0) && !isnan(e) && e <= INT_MAX && e >= INT_MIN)
return x;
else
return (int)0x80000000;
}
Expand Down Expand Up @@ -1045,8 +1047,9 @@ _mm_cvtps_epi32(__m128 __a)
} u;
for(int i = 0; i < 4; ++i)
{
int x = lrint(__a[i]);
if (x != 0 || fabs(__a[i]) < 2.0)
double e = __a[i];
int x = lrint(e);
if ((x != 0 || fabs(e) < 2.0) && !isnan(e) && e <= INT_MAX && e >= INT_MIN)
u.x[i] = x;
else
u.x[i] = (int)0x80000000;
Expand Down

0 comments on commit 5c81135

Please sign in to comment.