-
Notifications
You must be signed in to change notification settings - Fork 24
perf(compiler): optimize x86 u256 mul with bmi2 adx #428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
12f9d47
perf(compiler): add bmi2 adx u256 mul lowering
abmcar 4d49d79
perf(compiler): tighten adx u256 mul schedule
abmcar 1f0d07e
perf(compiler): revert row-wise adx u256 mul schedule
abmcar 0fa52b8
perf(compiler): optimize u256 mul mulx/adx lowering
abmcar 9feca2f
perf(tools): stabilize u256 mul benchmark comparisons
abmcar 1fd6082
perf(tools): validate u256 mul benchmark results
abmcar 51d79ad
refactor(compiler): share x86 u256 mul lowering helpers
abmcar 828f489
perf(compiler): regroup x86 u256 mul carry schedule
abmcar 1b2864b
refactor(compiler): factor x86 u256 mul product helpers
abmcar 904aac2
perf(compiler): reduce adx u256 mul spill pressure
abmcar 5f26c3c
refactor(compiler): trim x86 u256 mul lowering paths
abmcar cd9909c
docs(compiler): clarify truncated adx carry handling
abmcar 0d9380a
docs(compiler): note evm jit-only mul lowering
abmcar bce104f
ci(ci): restart PR checks
abmcar e0f4aa3
docs(compiler): add change document for U256 MUL BMI2/ADX optimization
abmcar 7da7b92
fix(compiler): address PR review comments for u256 mul bmi2 adx
abmcar 804a33a
refactor(docs): remove manual table from docs/changes/README.md
abmcar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Change: Optimize x86 U256 MUL with BMI2/ADX | ||
|
|
||
| - **Status**: Implemented | ||
| - **Date**: 2026-03-23 | ||
| - **Tier**: Light | ||
|
|
||
| ## Overview | ||
|
|
||
| Detect `adx` and `bmi2` CPU features in the x86 compiler target and lower EVM U256 MUL to a BMI2+ADX row-wise MULX + ADCX/ADOX schedule on supported x86_64 hosts. Falls back to existing generic lowering on unsupported CPUs. | ||
|
|
||
| ## Motivation | ||
|
|
||
| U256 multiplication is one of the most expensive EVM operations in the JIT (~100 x86 instructions). BMI2 provides MULX (widening multiply without flags clobber) and ADX provides ADCX/ADOX (dual carry chains), enabling a more efficient multiplication schedule with better instruction-level parallelism. | ||
|
|
||
| ## Impact | ||
|
|
||
| - Module: `docs/modules/compiler/` (x86 lowering for U256 MUL) | ||
| - 5 files changed, +165/-28 lines | ||
| - Performance: single-shot +0.55% (noise), hot MUL loop +7.5-10.5% | ||
| - Hardware requirement: BMI2+ADX (Intel Haswell+, AMD Zen+); graceful fallback on older CPUs | ||
| - No functional behavior change; gas and output match in all cases | ||
|
|
||
| ## Checklist | ||
|
|
||
| - [x] Implementation complete | ||
| - [x] Tests added/updated (evmc run --bench, gas/output verification) | ||
| - [ ] Module specs in `docs/modules/` updated (if affected) | ||
| - [x] Build and tests pass | ||
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.