Enable UNALIGNED_ACCESS_IS_FAST for all PowerPC variants#448
Merged
ebiggers merged 1 commit intoebiggers:masterfrom Mar 16, 2026
Merged
Enable UNALIGNED_ACCESS_IS_FAST for all PowerPC variants#448ebiggers merged 1 commit intoebiggers:masterfrom
ebiggers merged 1 commit intoebiggers:masterfrom
Conversation
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 ebiggers#362
Owner
|
Merged, thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
UNALIGNED_ACCESS_IS_FASTcheck incommon_defs.honly tests__powerpc64__, which misses:__powerpc__instead__POWERPC__insteadThis causes all Mac PowerPC builds (G3/G4/G5) and 32-bit Linux PowerPC
to take the slow byte-by-byte code path unnecessarily.
Fixes #362
Fix
Add
__powerpc__and__POWERPC__to the preprocessor conditional alongside the existing__powerpc64__check.Testing
Power Mac G5 (Darwin 9.8.0, GCC 10.5.0, big-endian PPC):
__POWERPC__is defined (not__powerpc64__or__powerpc__)UNALIGNED_ACCESS_IS_FAST = 0(missed)UNALIGNED_ACCESS_IS_FAST = 1(detected)IBM POWER8 S824 (Ubuntu 20.04, GCC 9.4.0, ppc64le):
__powerpc64__and__powerpc__defined__powerpc64__, still works with the additional checksMacro coverage
__powerpc64____powerpc____POWERPC__