Skip to content

Commit e1c1ade

Browse files
#if MONO
1 parent 0ce33ea commit e1c1ade

File tree

2 files changed

+8
-6
lines changed
  • src/libraries/System.Private.CoreLib/src/System

2 files changed

+8
-6
lines changed

src/libraries/System.Private.CoreLib/src/System/Math.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public static long BigMul(int a, int b)
171171
return ((long)a) * b;
172172
}
173173

174-
#if !(TARGET_ARM64 || (TARGET_AMD64 && CORECLR)) // BigMul 64*64 has high performance intrinsics on ARM64 and AMD64 (but not yet on MONO)
174+
#if !(TARGET_ARM64 || (TARGET_AMD64 && !MONO)) // BigMul 64*64 has high performance intrinsics on ARM64 and AMD64 (but not yet on MONO)
175175
/// <summary>
176176
/// Perform multiplication between 64 and 32 bit numbers, returning lower 64 bits in <paramref name="low"/>
177177
/// </summary>
@@ -205,8 +205,10 @@ public static ulong BigMul(ulong a, ulong b, out ulong low)
205205
#if MONO // Multiply is not yet implemented in MONO
206206
if (Bmi2.X64.IsSupported)
207207
{
208-
low = a * b;
209-
return Bmi2.X64.MultiplyNoFlags(a, b);
208+
ulong tmp;
209+
ulong high = Bmi2.X64.MultiplyNoFlags(a, b, &tmp);
210+
low = tmp;
211+
return high;
210212
}
211213
#else
212214
if (X86Base.X64.IsSupported)
@@ -254,7 +256,7 @@ static ulong SoftwareFallback(ulong a, ulong b, out ulong low)
254256
/// <returns>The high 64-bit of the product of the specified numbers.</returns>
255257
public static long BigMul(long a, long b, out long low)
256258
{
257-
#if CORECLR // Multiply is not yet implemented in MONO
259+
#if !MONO // Multiply is not yet implemented in MONO
258260
if (X86Base.X64.IsSupported)
259261
{
260262
(low, long hi) = X86Base.X64.Multiply(a, b);

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/X86Base.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ internal X64() { }
6767
[Experimental(Experimentals.X86BaseDivRemDiagId, UrlFormat = Experimentals.SharedUrlFormat)]
6868
public static (long Quotient, long Remainder) DivRem(ulong lower, long upper, long divisor) => DivRem(lower, upper, divisor);
6969

70-
#if CORECLR
70+
#if !MONO
7171
/// <summary>
7272
/// <para>unsigned _umul128(unsigned __int64 Multiplier, unsigned __int64 Multiplicand, unsigned __int64 * HighProduct)</para>
7373
/// <para> MUL reg/m64</para>
@@ -143,7 +143,7 @@ public static unsafe (int Eax, int Ebx, int Ecx, int Edx) CpuId(int functionId,
143143
[Experimental(Experimentals.X86BaseDivRemDiagId, UrlFormat = Experimentals.SharedUrlFormat)]
144144
public static (nint Quotient, nint Remainder) DivRem(nuint lower, nint upper, nint divisor) => DivRem(lower, upper, divisor);
145145

146-
#if CORECLR
146+
#if !MONO
147147
/// <summary>
148148
/// <para> MUL reg/m32</para>
149149
/// </summary>

0 commit comments

Comments
 (0)