Pow2MontgomeryModWindowedConvertToStandardCpu usages replaced with a comparison to MontgomeryOne avoiding unnecessary conversions. Results updated.

This commit is contained in:
mlemanczyk committed 2026-01-03 01:37:40 +01:00
1 parent 3f59cdc14b
commit 6b80e31e6c
7 files changed
+57 -34

No files matched your search

+3 -3
View File
@@ -18,7 +18,7 @@ public static partial class ULongExtensions
// Small divisors come from the precomputed <= 4,000,000 snapshot and tiny rotation counts
// appear when cycle reductions trigger. Route both cases through the single-bit ladder so the
// CPU path avoids renting the window tables when a cheaper method is available.
if (exponent <= Pow2WindowFallbackThreshold || modulus <= (ulong)PerfectNumberConstants.MaxQForDivisorCycles)
if (exponent <= Pow2WindowFallbackThreshold || modulus <= PerfectNumberConstants.MaxQForDivisorCycles)
{
return Pow2MontgomeryModSingleBitKeepMontgomery(exponent, divisor);
}
@@ -88,7 +88,7 @@ public static partial class ULongExtensions
// Small divisors come from the precomputed <= 4,000,000 snapshot and tiny rotation counts
// appear when cycle reductions trigger. Route both cases through the single-bit ladder so the
// CPU path avoids renting the window tables when a cheaper method is available.
if (exponent <= Pow2WindowFallbackThreshold || modulus <= (ulong)PerfectNumberConstants.MaxQForDivisorCycles)
if (exponent <= Pow2WindowFallbackThreshold || modulus <= PerfectNumberConstants.MaxQForDivisorCycles)
{
return Pow2MontgomeryModSingleBitConvertToStandard(exponent, divisor);
}
@@ -274,7 +274,7 @@ public static partial class ULongExtensions
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
private static bool AdvanceMersenneDivisorCycleStepCpu(ref ulong pow, ulong divisor, ref ulong order)
{
pow += pow;