Problem
Montgomery mul at 22-25ns vs arkworks' 18-20ns (~25% gap). Current BMI2+ADX ASM may have suboptimal instruction scheduling.
Approach
Audit current montgomeryMulX86 against arkworks ff-asm for:
- Pipeline stalls between dependent
mulxq/adcxq/adoxq sequences
- Unnecessary register moves or spills
- Reduction scheduling: interleaved CIOS vs deferred reduction
- Register allocation (currently cannot use rbp due to LLVM frame pointer)
Impact
Montgomery mul is the single most called field operation. A 20% improvement applies to every curve addition, every Miller loop step, every sumcheck polynomial evaluation. Would save ~1s on primes_large (6.6s → ~5.5s).
Files
src/field/mod.zig — montgomeryMulX86 in MontgomeryField and BN254Scalar
Benchmark baseline
- Fp.mul: 22-25 ns/op
- Fr.mul: 24-25 ns/op
- Target: 18-20 ns/op
Problem
Montgomery mul at 22-25ns vs arkworks' 18-20ns (~25% gap). Current BMI2+ADX ASM may have suboptimal instruction scheduling.
Approach
Audit current
montgomeryMulX86against arkworks ff-asm for:mulxq/adcxq/adoxqsequencesImpact
Montgomery mul is the single most called field operation. A 20% improvement applies to every curve addition, every Miller loop step, every sumcheck polynomial evaluation. Would save ~1s on primes_large (6.6s → ~5.5s).
Files
src/field/mod.zig—montgomeryMulX86inMontgomeryFieldandBN254ScalarBenchmark baseline