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