From 5f04208dbd2045f1ebcaf8c930c3b1f49ec8028d Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 21 Apr 2020 17:13:22 -0400 Subject: [PATCH] This removes the problematic use of the intrinsic _addcarry_u64 for Visual Studio (#758) in the ARM 64-bit kernel. This intrinsic does not appear in the documentation https://docs.microsoft.com/en-us/cpp/intrinsics/arm64-intrinsics?view=vs-2019 and should probably not be used. Note that we expect the compiler to produce efficient code out of our implementation. --- src/arm64/bitmanipulation.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/arm64/bitmanipulation.h b/src/arm64/bitmanipulation.h index b3d609fee..a8447104c 100644 --- a/src/arm64/bitmanipulation.h +++ b/src/arm64/bitmanipulation.h @@ -50,9 +50,8 @@ really_inline int count_ones(uint64_t input_num) { really_inline bool add_overflow(uint64_t value1, uint64_t value2, uint64_t *result) { #ifdef _MSC_VER - // todo: this might fail under visual studio for ARM - return _addcarry_u64(0, value1, value2, - reinterpret_cast(result)); + *result = value1 + value2; + return *result < value1; #else return __builtin_uaddll_overflow(value1, value2, (unsigned long long *)result);