From 2f51cf0a810674b4cfd03f3cdf892e36725a5465 Mon Sep 17 00:00:00 2001 From: Kim Walisch Date: Tue, 2 Jul 2024 09:34:14 +0200 Subject: [PATCH] Revert --- include/Sieve.hpp | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/include/Sieve.hpp b/include/Sieve.hpp index bb8c0bf9..014eb0f7 100644 --- a/include/Sieve.hpp +++ b/include/Sieve.hpp @@ -127,20 +127,17 @@ class Sieve /// Count 1 bits inside [start, stop] ALWAYS_INLINE uint64_t count(uint64_t start, uint64_t stop) const { - if (start > stop) - return 0; - - #if defined(ENABLE_ARM_SVE) - return count_arm_sve(start, stop); - #elif defined(ENABLE_AVX512_BMI2) - return count_avx512_bmi2(start, stop); - #elif defined(ENABLE_MULTIARCH_ARM_SVE) - return cpu_supports_sve ? count_arm_sve(start, stop) : count_default(start, stop); - #elif defined(ENABLE_MULTIARCH_AVX512_BMI2) - return cpu_supports_avx512_bmi2 ? count_avx512_bmi2(start, stop) : count_default(start, stop); - #else - return count_default(start, stop); - #endif + #if defined(ENABLE_ARM_SVE) + return count_arm_sve(start, stop); + #elif defined(ENABLE_AVX512_BMI2) + return count_avx512_bmi2(start, stop); + #elif defined(ENABLE_MULTIARCH_ARM_SVE) + return cpu_supports_sve ? count_arm_sve(start, stop) : count_default(start, stop); + #elif defined(ENABLE_MULTIARCH_AVX512_BMI2) + return cpu_supports_avx512_bmi2 ? count_avx512_bmi2(start, stop) : count_default(start, stop); + #else + return count_default(start, stop); + #endif } private: @@ -154,7 +151,9 @@ class Sieve /// uint64_t count_default(uint64_t start, uint64_t stop) const { - ASSERT(start <= stop); + if (start > stop) + return 0; + ASSERT(stop - start < segment_size()); uint64_t start_idx = start / 240; uint64_t stop_idx = stop / 240; @@ -189,7 +188,9 @@ class Sieve #endif uint64_t count_avx512_bmi2(uint64_t start, uint64_t stop) const { - ASSERT(start <= stop); + if (start > stop) + return 0; + ASSERT(stop - start < segment_size()); uint64_t start_idx = start / 240; uint64_t stop_idx = stop / 240; @@ -240,7 +241,9 @@ class Sieve #endif uint64_t count_arm_sve(uint64_t start, uint64_t stop) const { - ASSERT(start <= stop); + if (start > stop) + return 0; + ASSERT(stop - start < segment_size()); uint64_t start_idx = start / 240; uint64_t stop_idx = stop / 240;