Performance improvements
This commit is contained in:
1 parent
28ee92b1b9
commit
daab18504b
1 file changed
+9
-12
@@ -393,25 +393,22 @@ public struct GpuUInt128 : IComparable<GpuUInt128>, IEquatable<GpuUInt128>
|
|||||||
|
|
||||||
ulong w1 = xLow * yHigh;
|
ulong w1 = xLow * yHigh;
|
||||||
ulong w2 = xHigh * yLow;
|
ulong w2 = xHigh * yLow;
|
||||||
return (xHigh * yHigh) + (w1 >> 32) + (w2 >> 32) +
|
ulong w3 = xLow * yLow;
|
||||||
(
|
|
||||||
(
|
ulong result = (xHigh * yHigh) + (w1 >> 32) + (w2 >> 32);
|
||||||
((xLow * yLow) >> 32) +
|
result += ((w3 >> 32) + (uint)w1 + (uint)w2) >> 32;
|
||||||
(uint)w1 +
|
return result;
|
||||||
(uint)w2
|
|
||||||
) >> 32
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Mul64(GpuUInt128 other)
|
public void Mul64(GpuUInt128 other)
|
||||||
{
|
{
|
||||||
// Multiply this.Low (assumed 64-bit value) by full 128-bit other
|
// Multiply this.Low (assumed 64-bit value) by full 128-bit other
|
||||||
ulong operand = Low,
|
ulong operand = Low;
|
||||||
otherLow = other.Low;
|
// otherLow = other.Low;
|
||||||
|
|
||||||
Low = operand * otherLow;
|
Low = operand * other.Low;
|
||||||
High = operand * other.High + MulHigh(operand, otherLow);
|
High = operand * other.High + MulHigh(operand, other.Low);
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
|||||||
Reference in new issue
Block a user