Skip to content

crypto: Use local accumulator t[] in mul_amm_256 to avoid aliasing#1477

Merged
chfast merged 1 commit into
masterfrom
crypto/modexp_n4_cpp
Jun 3, 2026
Merged

crypto: Use local accumulator t[] in mul_amm_256 to avoid aliasing#1477
chfast merged 1 commit into
masterfrom
crypto/modexp_n4_cpp

Conversation

@chfast
Copy link
Copy Markdown
Member

@chfast chfast commented Apr 2, 2026

Use a local array t[4] instead of writing directly to the output span r, which may alias the inputs x or y. This allows the compiler to keep the accumulator in registers without reloading after stores. The result is copied to r at the end.

~6% speedup on 256-bit modexp benchmarks (25846 → 24256 cycles).

@chfast chfast force-pushed the crypto/modexp_n4_cpp branch from 57c8426 to 6e5a998 Compare April 2, 2026 16:51
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.36%. Comparing base (537a945) to head (67cdfea).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1477   +/-   ##
=======================================
  Coverage   97.36%   97.36%           
=======================================
  Files         163      163           
  Lines       14495    14497    +2     
  Branches     3387     3387           
=======================================
+ Hits        14113    14115    +2     
  Misses        280      280           
  Partials      102      102           
Flag Coverage Δ
eest-develop 89.67% <100.00%> (+<0.01%) ⬆️
eest-develop-gmp 26.41% <0.00%> (-0.01%) ⬇️
eest-legacy 17.71% <0.00%> (-0.01%) ⬇️
eest-libsecp256k1 28.06% <100.00%> (+<0.01%) ⬆️
eest-stable 89.76% <100.00%> (+<0.01%) ⬆️
evmone-unittests 92.52% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 95.95% <100.00%> (+<0.01%) ⬆️
tooling 90.21% <ø> (ø)
tests 99.79% <ø> (ø)
Files with missing lines Coverage Δ
lib/evmone_precompiles/mulmod.cpp 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Use a local array t[4] instead of writing directly to the output
span r, which may alias the inputs x or y. This allows the compiler
to keep the accumulator in registers without reloading after stores.
The result is copied to r at the end.

~6% speedup on 256-bit modexp benchmarks (25846 → 24256 cycles).
@chfast chfast force-pushed the crypto/modexp_n4_cpp branch from 6e5a998 to 67cdfea Compare June 3, 2026 10:29
@chfast chfast merged commit d1254cd into master Jun 3, 2026
23 checks passed
@chfast chfast deleted the crypto/modexp_n4_cpp branch June 3, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant