From 7f4ad9c235550bff5f62927cb808acb000beed89 Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Sun, 19 May 2024 19:37:45 +0100 Subject: [PATCH 1/2] Add 32-bit x86 fallback for popcnt --- Source/astcenc_vecmathlib_sse_4.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/astcenc_vecmathlib_sse_4.h b/Source/astcenc_vecmathlib_sse_4.h index b69655f90..11a69b146 100644 --- a/Source/astcenc_vecmathlib_sse_4.h +++ b/Source/astcenc_vecmathlib_sse_4.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // ---------------------------------------------------------------------------- -// Copyright 2019-2023 Arm Limited +// Copyright 2019-2024 Arm Limited // // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy @@ -1307,7 +1307,11 @@ ASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b) */ ASTCENC_SIMD_INLINE int popcount(uint64_t v) { +#if !defined(__x86_64__) + return static_cast(__builtin_popcountll(v)); +#else return static_cast(_mm_popcnt_u64(v)); +#endif } #endif // ASTCENC_POPCNT >= 1 From 1995186420cb611cb4bdbc1b47acdce3db3f932d Mon Sep 17 00:00:00 2001 From: Peter Harris Date: Sun, 19 May 2024 19:37:45 +0100 Subject: [PATCH 2/2] Add 32-bit x86 fallback for popcnt --- Source/astcenc_vecmathlib_sse_4.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/astcenc_vecmathlib_sse_4.h b/Source/astcenc_vecmathlib_sse_4.h index 11a69b146..d50583770 100644 --- a/Source/astcenc_vecmathlib_sse_4.h +++ b/Source/astcenc_vecmathlib_sse_4.h @@ -1307,7 +1307,7 @@ ASTCENC_SIMD_INLINE vfloat4 dot3(vfloat4 a, vfloat4 b) */ ASTCENC_SIMD_INLINE int popcount(uint64_t v) { -#if !defined(__x86_64__) +#if !defined(__x86_64__) && !defined(_M_AMD64) return static_cast(__builtin_popcountll(v)); #else return static_cast(_mm_popcnt_u64(v));