Files
amethyst/quartz
Claude 0ca3ff71eb perf: fuse 128-bit multiply for K/Native (saves 16 mul per field op)
Add fieldMulReduceFused and fieldSqrReduceFused that compute both lo
and hi of each 64×64→128 multiply from 4 shared sub-products.

Previous: lo = a * b (1 hardware mul) + hi = umulh(a,b) (4 imul) = 5
Fused: 4 shared sub-products compute both lo and hi = 4 multiplies

The inline lambda consumer pattern avoids allocation:
  mulFull(a, b) { lo, hi -> ... }  // everything inlined at call site

K/Native benchmark improvement (linuxX64):
  verifySchnorrFast: 101,637 → 96,699 ns (-5%)
  signSchnorr(cached): 50,206 → 45,037 ns (-10%)
  compressedPubKeyFor: 40,906 → 37,075 ns (-9%)
  Native instruction count: 95 → 79 multiplies per field mul

Android keeps the unfused path because ART's single-cycle MUL for
a*b is faster than manually constructing lo from sub-products.
The fused approach saves 1 multiply but adds ~5 shift/and/or ops —
net regression on ART (80,756 vs 74,898 ns for verify).

https://claude.ai/code/session_015CtM5k88rF7WFgX8o2AGNR
2026-04-09 20:45:50 +00:00
..