Skip to content

Commit eb41980

Browse files
Provide MSVC-compatible implementation of fabs on AVX512
1 parent c2afea4 commit eb41980

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

include/xsimd/types/xsimd_avx512_double.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,11 @@ namespace xsimd
449449

450450
static batch_type abs(const batch_type& rhs)
451451
{
452-
return (__m512d)(_mm512_and_epi64(_mm512_set1_epi64(0x7FFFFFFFFFFFFFFF),
453-
(__m512i)((__m512d)(rhs))));
452+
__m512d rhs_asd = (__m512d)rhs;
453+
__m512i rhs_asi = *reinterpret_cast<__m512i*>(&rhs_asd);
454+
__m512i res_asi = _mm512_and_epi64(_mm512_set1_epi64(0x7FFFFFFFFFFFFFFF),
455+
rhs_asi);
456+
return *reinterpret_cast<__m512d*>(&res_asi);
454457
}
455458

456459
static batch_type fabs(const batch_type& rhs)

include/xsimd/types/xsimd_avx512_float.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,11 @@ namespace xsimd
472472

473473
static batch_type abs(const batch_type& rhs)
474474
{
475-
return (__m512)(_mm512_and_epi32((__m512i)((__m512)(rhs)),
476-
_mm512_set1_epi32(0x7fffffff)));
475+
__m512 rhs_asf = (__m512)rhs;
476+
__m512i rhs_asi = *reinterpret_cast<__m512i*>(&rhs_asf);
477+
__m512i res_asi = _mm512_and_epi32(_mm512_set1_epi32(0x7FFFFFFF),
478+
rhs_asi);
479+
return *reinterpret_cast<__m512*>(&res_asi);
477480
}
478481

479482
static batch_type fabs(const batch_type& rhs)

0 commit comments

Comments
 (0)