Skip to content

Commit 3feb147

Browse files
janisozaurNikolajBjorner
authored andcommitted
Improve platform detection, in particular MSVC ARM64
1 parent 907ffde commit 3feb147

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/sat/sat_solver.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Revision History:
3030
#include "sat/sat_unit_walk.h"
3131
#include "sat/sat_ddfw.h"
3232
#include "sat/sat_prob.h"
33-
#ifdef _MSC_VER
33+
#if defined(_MSC_VER) && !defined(_M_ARM) && !defined(_M_ARM64)
3434
# include <xmmintrin.h>
3535
#endif
3636

@@ -895,7 +895,9 @@ namespace sat {
895895
#if defined(__GNUC__) || defined(__clang__)
896896
__builtin_prefetch((const char*)((m_watches[l.index()].c_ptr())));
897897
#else
898+
#if !defined(_M_ARM) && !defined(_M_ARM64)
898899
_mm_prefetch((const char*)((m_watches[l.index()].c_ptr())), _MM_HINT_T1);
900+
#endif
899901
#endif
900902
}
901903

src/util/hwf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Revision History:
4848
// clear to the compiler what instructions should be used. E.g., for sqrt(), the Windows compiler selects
4949
// the x87 FPU, even when /arch:SSE2 is on.
5050
// Luckily, these are kind of standardized, at least for Windows/Linux/macOS.
51-
#ifdef __clang__
51+
#if defined(__clang__) || defined(_M_ARM) && defined(_M_ARM64)
5252
#undef USE_INTRINSICS
5353
#endif
5454

@@ -276,7 +276,7 @@ void hwf_manager::round_to_integral(mpf_rounding_mode rm, hwf const & x, hwf & o
276276

277277
// According to the Intel Architecture manual, the x87-instruction FRNDINT is the
278278
// same in 32-bit and 64-bit mode. The _mm_round_* intrinsics are SSE4 extensions.
279-
#ifdef _WINDOWS
279+
#if defined(_WINDOWS) && !defined(_M_ARM) && !defined(_M_ARM64)
280280
#if defined( __MINGW32__ ) && ( defined( __GNUG__ ) || defined( __clang__ ) )
281281
o.value = nearbyint(x.value);
282282
#else

src/util/mpz.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,17 @@ Revision History:
4646
#define LEHMER_GCD
4747
#endif
4848

49-
#ifdef _WINDOWS
49+
#if defined(_WINDOWS) && !defined(_M_ARM) && !defined(_M_ARM64)
5050
// This is needed for _tzcnt_u32 and friends.
5151
#include <immintrin.h>
52+
#define _trailing_zeros32(X) _tzcnt_u32(X)
5253
#endif
5354

5455
#if defined(__GNUC__)
5556
#define _trailing_zeros32(X) __builtin_ctz(X)
56-
#else
57-
#define _trailing_zeros32(X) _tzcnt_u32(X)
5857
#endif
5958

60-
#if defined(__LP64__) || defined(_WIN64)
59+
#if (defined(__LP64__) || defined(_WIN64)) && !defined(_M_ARM) && !defined(_M_ARM64)
6160
#if defined(__GNUC__)
6261
#define _trailing_zeros64(X) __builtin_ctzll(X)
6362
#else
@@ -69,6 +68,11 @@ inline uint64_t _trailing_zeros64(uint64_t x) {
6968
for (; 0 == (x & 1) && r < 64; ++r, x >>= 1);
7069
return r;
7170
}
71+
inline uint32_t _trailing_zeros32(uint32_t x) {
72+
uint32_t r = 0;
73+
for (; 0 == (x & 1) && r < 32; ++r, x >>= 1);
74+
return r;
75+
}
7276
#endif
7377

7478

0 commit comments

Comments
 (0)