Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiling for Arm64 Windows with MSVC #483

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/math/emath.h
Expand Up @@ -15,6 +15,10 @@
#if defined(__ARM_NEON)
#include "../simd/arm/emulation.h"
#else
#if defined(_M_ARM64)
// Windows MSVC allows for *mmintrin.h on Arm64 but only with USE_SOFT_INTRINSICS.
#define USE_SOFT_INTRINSICS
#endif
#include <emmintrin.h>
#include <xmmintrin.h>
#include <immintrin.h>
Expand Down
18 changes: 8 additions & 10 deletions common/sys/intrinsics.h
Expand Up @@ -12,6 +12,10 @@
#if defined(__ARM_NEON)
#include "../simd/arm/emulation.h"
#else
#if defined(_M_ARM64)
// Windows MSVC allows for immintrin.h on Arm64 but only with USE_SOFT_INTRINSICS.
#define USE_SOFT_INTRINSICS
#endif
#include <immintrin.h>
#if defined(__EMSCRIPTEN__)
#include "../simd/wasm/emulation.h"
Expand Down Expand Up @@ -89,15 +93,13 @@ namespace embree
#endif
}

#if defined(__X86_64__) || defined (__aarch64__)
__forceinline size_t bsf(size_t v) {
__forceinline uint64_t bsf(uint64_t v) {
#if defined(__AVX2__)
return _tzcnt_u64(v);
#else
unsigned long r = 0; _BitScanForward64(&r,v); return r;
#endif
}
#endif

__forceinline int bscf(int& v)
{
Expand All @@ -113,14 +115,12 @@ namespace embree
return i;
}

#if defined(__X86_64__) || defined (__aarch64__)
__forceinline size_t bscf(size_t& v)
__forceinline uint64_t bscf(uint64_t& v)
{
size_t i = bsf(v);
uint64_t i = bsf(v);
v &= v-1;
return i;
}
#endif

__forceinline int bsr(int v) {
#if defined(__AVX2__) && !defined(__aarch64__)
Expand All @@ -138,15 +138,13 @@ namespace embree
#endif
}

#if defined(__X86_64__) || defined (__aarch64__)
__forceinline size_t bsr(size_t v) {
__forceinline uint64_t bsr(uint64_t v) {
#if defined(__AVX2__)
return 63 -_lzcnt_u64(v);
#else
unsigned long r = 0; _BitScanReverse64(&r, v); return r;
#endif
}
#endif

__forceinline int lzcnt(const int x)
{
Expand Down
2 changes: 1 addition & 1 deletion common/sys/platform.h
Expand Up @@ -58,7 +58,7 @@
#endif

/* detect 64 bit platform */
#if defined(__X86_64__) || defined(__aarch64__)
#if UINTPTR_MAX == UINT64_MAX
#define __64BIT__
#endif

Expand Down