sha256: improve hashing performance by starting w computation earlier #7657
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.
While poking around the sha256 impl, I noticed some bad codegen around the schedule updates. GCC 15 and LLVM 21 seem to miss re-ordering the schedule updates higher for Zen 5 (LLVM still just aliases the numbers of Zen 4), and thus we miss on a bit of ILP.
With the benchmark provided in
test_sha256.c, this increases the performance by around 1m hashes / second on a Ryzen 5 9600X.LLVM 21.1.8:
GCC 15.2:
(also adds the missing
FOUR_ROUNDSundefine, it was accidentally removed cuz it was a typo)