From 56068be1c001f3738ebadb6bd17492cc20e09e9f Mon Sep 17 00:00:00 2001 From: Scott Date: Sun, 15 Mar 2026 22:59:10 -0500 Subject: [PATCH] Enable UNALIGNED_ACCESS_IS_FAST for all PowerPC variants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing check only tests __powerpc64__, which is defined on 64-bit Linux/BSD PowerPC. Add __powerpc__ (32-bit Linux/BSD) and __POWERPC__ (Darwin/macOS, both 32-bit and 64-bit ABI) so that all PowerPC platforms benefit from the fast unaligned access code paths. All PowerPC processors support unaligned 32-bit integer access in hardware with minimal penalty, so the byte-by-byte fallback path is unnecessarily conservative on these platforms. Tested on Power Mac G5 (Darwin 9.8.0, GCC 10.5.0) where only __POWERPC__ is defined — the fix correctly enables the fast path. Also verified on IBM POWER8 S824 (ppc64le, GCC 9.4.0). Fixes #362 --- common_defs.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common_defs.h b/common_defs.h index a0868d44..bd4d954b 100644 --- a/common_defs.h +++ b/common_defs.h @@ -402,7 +402,8 @@ static forceinline u64 bswap64(u64 v) */ #if (defined(__GNUC__) || defined(__clang__)) && \ (defined(ARCH_X86_64) || defined(ARCH_X86_32) || \ - defined(__ARM_FEATURE_UNALIGNED) || defined(__powerpc64__) || \ + defined(__ARM_FEATURE_UNALIGNED) || \ + defined(__powerpc64__) || defined(__powerpc__) || defined(__POWERPC__) || \ defined(__riscv_misaligned_fast) || \ /* * For all compilation purposes, WebAssembly behaves like any other CPU