Repository navigation
secp256k1: Add internal cpufeat package. - #3753
Merged
Merged
Conversation
davecgh
force-pushed
the
secp256k1_internal_cpufeat
branch
3 times, most recently
from
July 27, 2026 21:04
90f9006 to
fdfdeaa
Compare
davecgh
force-pushed
the
secp256k1_internal_cpufeat
branch
2 times, most recently
from
July 29, 2026 00:30
799c120 to
ecc3151
Compare
jholdstock
reviewed
Jul 29, 2026
davecgh
force-pushed
the
secp256k1_internal_cpufeat
branch
2 times, most recently
from
July 29, 2026 08:17
b1d0d74 to
f266edf
Compare
jholdstock
approved these changes
Jul 30, 2026
The current CPU feature detection for the recently added MULX/ADX optimizations is done directly in the field64 code. There is nothing wrong with this from a purely functional standpoint, but it is difficult to extend and can't be reused across other packages in the module. With that in mind, this adds an internal package to detect support for CPU and operating system features that are relevant to architecture-specific optimizations throughout the secp256k1 package. The package intentionally provides a minimal abstraction consisting only of the feature detection required by the secp256k1 implementation. This provides a clean mechanism for detecting and supporting new hardware extensions in the future. Note that does not incorporate the package yet. It only introduces the new code.
This adds dedicated tests for the functions in the new internal cpufeat package. Since the specific values depend on the hardware, this avoids asserting specific values that would fail when not running on specific hardware and instead focuses on ensuring the functions are idempotent.
This updates the field64 code to use the new cpufeat package for feature detection instead of doing it manually inline.
davecgh
force-pushed
the
secp256k1_internal_cpufeat
branch
from
November 20, 2026 07:15
f266edf to
1dd546e
Compare
dcr-approvals-proxy
approved these changes
Nov 20, 2026
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.
This is rebased on #3752.
The current CPU feature detection for the recently added MULX/ADX optimizations is done directly in the field64 code. There is nothing wrong with this from a purely functional standpoint, but it is difficult to extend and can't be reused across other packages in the module.
With that in mind, this adds an internal package to detect support for CPU and operating system features that are relevant to architecture-specific optimizations throughout the
secp256k1package.The package intentionally provides a minimal abstraction consisting only of the feature detection required by the
secp256k1implementation.This provides a clean mechanism for detecting and supporting new hardware extensions in the future.
Finally, it updates the field64 code to use the new
cpufeatpackage for feature detection instead of doing it manually inline.