New MulMod version added

This commit is contained in:
Marek Lemańczyk committed 2025-09-30 17:14:35 +02:00
1 parent 93a82f756f
commit 34817bec21
1 file changed
+10 -4
@@ -40,6 +40,12 @@ public class MulMod64Benchmarks
return MulMod64Inline(Input.Left, Input.Right, Input.Modulus); return MulMod64Inline(Input.Left, Input.Right, Input.Modulus);
} }
[Benchmark]
public ulong InlineUInt128OperandsWithReductionFirst()
{
return MulMod64InlineWithReductionFirst(Input.Left, Input.Right, Input.Modulus);
}
[Benchmark] [Benchmark]
public ulong InlineUInt128OperandsWithOperandReduction() public ulong InlineUInt128OperandsWithOperandReduction()
{ {
@@ -65,10 +71,10 @@ public class MulMod64Benchmarks
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ulong MulMod64Inline(ulong a, ulong b, ulong modulus) private static ulong MulMod64Inline(ulong a, ulong b, ulong modulus) => (ulong)(((UInt128)a * b) % modulus);
{
return (ulong)(((UInt128)a * b) % modulus); [MethodImpl(MethodImplOptions.AggressiveInlining)]
} private static ulong MulMod64InlineWithReductionFirst(ulong a, ulong b, ulong modulus) => (ulong)(((UInt128)(a % modulus) * (b % modulus)) % modulus);
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private static ulong MulMod64InlineWithOperandReduction(ulong a, ulong b, ulong modulus) private static ulong MulMod64InlineWithOperandReduction(ulong a, ulong b, ulong modulus)