Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aa53732
Alternate approach for HELPER_METHOD_FRAME removal for arithmetic div…
davidwrighton Mar 8, 2025
e2273af
Update alignment to be a bit better for the assembly routines
davidwrighton Mar 8, 2025
29364c3
Try to adjust jithelpers.cpp for better building on arm32
davidwrighton Mar 8, 2025
f7f6e3d
Fix more oops in the build
davidwrighton Mar 8, 2025
52e28a9
More attempts to fix build breaks... maybe I should actually set up a…
davidwrighton Mar 8, 2025
6796ab4
Get the types right for JIT_UDiv and JIT_UMod
davidwrighton Mar 8, 2025
7ed11fe
Swap the args around for the 64bit long/ulong divide helpers back to …
davidwrighton Mar 10, 2025
e76b3aa
Attempt to fix 32bit linux builds, and remove all use of FCThrow, and…
davidwrighton Mar 18, 2025
a5af1b4
Fix BCL build
davidwrighton Mar 18, 2025
19ec62a
Merge branch 'main' into alternate_approach_to_removingHMF_for_arithm…
davidwrighton Mar 18, 2025
3799b0d
Get this approach building on Linux X86 and Linux Arm ... turns out t…
davidwrighton Mar 19, 2025
f418940
Merge branch 'main' into alternate_approach_to_removingHMF_for_arithm…
davidwrighton Mar 21, 2025
8d6ba7e
Integrate am11's work into my branch
davidwrighton Mar 24, 2025
ee49f1c
Merge branch 'main' of https://github.com/dotnet/runtime into alterna…
davidwrighton Mar 24, 2025
a87b046
Fix x86 eh stuff
davidwrighton Mar 31, 2025
8cc6d52
Merge branch 'main' of https://github.com/dotnet/runtime into alterna…
davidwrighton Mar 31, 2025
37ae63f
Move the math helpers to be consistently FCalls
davidwrighton Mar 31, 2025
0722c32
Tweak macros
davidwrighton Mar 31, 2025
51db312
Merge branch 'main' of https://github.com/dotnet/runtime into alterna…
davidwrighton Apr 1, 2025
356f9ba
Code revewi from am11
davidwrighton Apr 1, 2025
eda6d06
Remove unused System namespace import
davidwrighton Apr 2, 2025
0eb3870
Merge branch 'main' of https://github.com/dotnet/runtime into alterna…
davidwrighton Apr 2, 2025
a21f51d
AAGGHH
davidwrighton Apr 4, 2025
5b7bfb6
Merge branch 'main' of github.com:dotnet/runtime into alternate_appro…
davidwrighton Apr 4, 2025
b3188c5
Code review comments
davidwrighton Apr 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,24 @@

JITHELPER(CORINFO_HELP_UNDEF, NULL, METHOD__NIL)

// CORINFO_HELP_DBL2INT, CORINFO_HELP_DBL2UINT, and CORINFO_HELP_DBL2LONG get
// patched for CPUs that support SSE2 (P4 and above).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// CORINFO_HELP_DBL2INT, CORINFO_HELP_DBL2UINT, and CORINFO_HELP_DBL2LONG get
// patched for CPUs that support SSE2 (P4 and above).

Outdated comment

#ifdef TARGET_32BIT
// Arithmetic
JITHELPER(CORINFO_HELP_DIV, JIT_Div, METHOD__NIL)
JITHELPER(CORINFO_HELP_MOD, JIT_Mod, METHOD__NIL)
JITHELPER(CORINFO_HELP_UDIV, JIT_UDiv, METHOD__NIL)
JITHELPER(CORINFO_HELP_UMOD, JIT_UMod, METHOD__NIL)

// CORINFO_HELP_DBL2INT, CORINFO_HELP_DBL2UINT, and CORINFO_HELP_DBL2LONG get
// patched for CPUs that support SSE2 (P4 and above).
#ifndef TARGET_64BIT
JITHELPER(CORINFO_HELP_LLSH, JIT_LLsh, METHOD__NIL)
JITHELPER(CORINFO_HELP_LRSH, JIT_LRsh, METHOD__NIL)
JITHELPER(CORINFO_HELP_LRSZ, JIT_LRsz, METHOD__NIL)
#else // !TARGET_64BIT
#else // TARGET_32BIT
JITHELPER(CORINFO_HELP_DIV, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_MOD, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_UDIV, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_UMOD, NULL, METHOD__NIL)

JITHELPER(CORINFO_HELP_LLSH, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_LRSH, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_LRSZ, NULL, METHOD__NIL)
Expand All @@ -55,14 +60,18 @@
#ifndef TARGET_64BIT
DYNAMICJITHELPER(CORINFO_HELP_LMUL_OVF, NULL, METHOD__MATH__MULTIPLY_CHECKED_INT64)
DYNAMICJITHELPER(CORINFO_HELP_ULMUL_OVF, NULL, METHOD__MATH__MULTIPLY_CHECKED_UINT64)
#else
DYNAMICJITHELPER(CORINFO_HELP_LMUL_OVF, NULL, METHOD__NIL)
DYNAMICJITHELPER(CORINFO_HELP_ULMUL_OVF, NULL, METHOD__NIL)
#endif // TARGET_64BIT
JITHELPER(CORINFO_HELP_LDIV, JIT_LDiv, METHOD__NIL)
JITHELPER(CORINFO_HELP_LMOD, JIT_LMod, METHOD__NIL)
JITHELPER(CORINFO_HELP_ULDIV, JIT_ULDiv, METHOD__NIL)
JITHELPER(CORINFO_HELP_ULMOD, JIT_ULMod, METHOD__NIL)
#else
DYNAMICJITHELPER(CORINFO_HELP_LMUL_OVF, NULL, METHOD__NIL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CORINFO_HELP_LMUL/ULMUL_OVF are unused on 64-bit, I would expect them to be JITHELPER.

If they are used, I would expect them to look like the 32-bit ones and be outside the #ifndef TARGET_64BIT ifdef.

DYNAMICJITHELPER(CORINFO_HELP_ULMUL_OVF, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_LDIV, NULL, METHOD__NIL)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Padding for the METHOD__NIL column is off.

JITHELPER(CORINFO_HELP_LMOD, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_ULDIV, NULL, METHOD__NIL)
JITHELPER(CORINFO_HELP_ULMOD, NULL, METHOD__NIL)
#endif // TARGET_64BIT
JITHELPER(CORINFO_HELP_LNG2DBL, JIT_Lng2Dbl, METHOD__NIL)
JITHELPER(CORINFO_HELP_ULNG2DBL, JIT_ULng2Dbl, METHOD__NIL)
JITHELPER(CORINFO_HELP_DBL2INT, JIT_Dbl2Int, METHOD__NIL)
Expand Down
13 changes: 12 additions & 1 deletion src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7452,8 +7452,19 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
return fgMorphTree(tree);
}
}
switch (helper)
{
case CORINFO_HELP_LDIV:
case CORINFO_HELP_LMOD:
case CORINFO_HELP_ULDIV:
case CORINFO_HELP_ULMOD:
// On Windows X86, the helpers here can be written more efficiently with a reversed order
// and it doesn't matter on other platforms
return fgMorphIntoHelperCall(tree, helper, true /* morphArgs */, op2, op1);
default:
return fgMorphIntoHelperCall(tree, helper, true /* morphArgs */, op1, op2);
}

return fgMorphIntoHelperCall(tree, helper, true /* morphArgs */, op1, op2);

case GT_RETURN:
case GT_SWIFT_ERROR_RET:
Expand Down
21 changes: 17 additions & 4 deletions src/coreclr/jit/valuenum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14278,26 +14278,39 @@ bool Compiler::fgValueNumberHelperCall(GenTreeCall* call)
break;

case CORINFO_HELP_DIV:
case CORINFO_HELP_LDIV:
vnpExc = fgValueNumberDivisionExceptions(GT_DIV, call->gtArgs.GetUserArgByIndex(0)->GetNode(),
call->gtArgs.GetUserArgByIndex(1)->GetNode());
break;
case CORINFO_HELP_MOD:
case CORINFO_HELP_LMOD:
vnpExc = fgValueNumberDivisionExceptions(GT_MOD, call->gtArgs.GetUserArgByIndex(0)->GetNode(),
call->gtArgs.GetUserArgByIndex(1)->GetNode());
break;
case CORINFO_HELP_UDIV:
case CORINFO_HELP_ULDIV:
vnpExc = fgValueNumberDivisionExceptions(GT_UDIV, call->gtArgs.GetUserArgByIndex(0)->GetNode(),
call->gtArgs.GetUserArgByIndex(1)->GetNode());
break;
case CORINFO_HELP_UMOD:
case CORINFO_HELP_ULMOD:
vnpExc = fgValueNumberDivisionExceptions(GT_UMOD, call->gtArgs.GetUserArgByIndex(0)->GetNode(),
call->gtArgs.GetUserArgByIndex(1)->GetNode());
break;

case CORINFO_HELP_LDIV:
vnpExc = fgValueNumberDivisionExceptions(GT_DIV, call->gtArgs.GetUserArgByIndex(1)->GetNode(),
call->gtArgs.GetUserArgByIndex(0)->GetNode());
break;
case CORINFO_HELP_LMOD:
vnpExc = fgValueNumberDivisionExceptions(GT_MOD, call->gtArgs.GetUserArgByIndex(1)->GetNode(),
call->gtArgs.GetUserArgByIndex(0)->GetNode());
break;
case CORINFO_HELP_ULDIV:
vnpExc = fgValueNumberDivisionExceptions(GT_UDIV, call->gtArgs.GetUserArgByIndex(1)->GetNode(),
call->gtArgs.GetUserArgByIndex(0)->GetNode());
break;
case CORINFO_HELP_ULMOD:
vnpExc = fgValueNumberDivisionExceptions(GT_UMOD, call->gtArgs.GetUserArgByIndex(1)->GetNode(),
call->gtArgs.GetUserArgByIndex(0)->GetNode());
break;

default:
// Setup vnpExc with the information that multiple different exceptions
// could be generated by this helper, in an opaque way
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static partial class MathHelpers
[SuppressGCTransition]
private static partial ulong RhpULMod(ulong dividend, ulong divisor);

public static ulong ULMod(ulong dividend, ulong divisor)
public static ulong ULMod(ulong divisor, ulong dividend)
{
if (divisor == 0)
ThrowHelper.ThrowDivideByZeroException();
Expand All @@ -34,7 +34,7 @@ public static ulong ULMod(ulong dividend, ulong divisor)
[SuppressGCTransition]
private static partial long RhpLMod(long dividend, long divisor);

public static long LMod(long dividend, long divisor)
public static long LMod(long divisor, long dividend)
{
if (divisor == 0)
ThrowHelper.ThrowDivideByZeroException();
Expand All @@ -48,7 +48,7 @@ public static long LMod(long dividend, long divisor)
[SuppressGCTransition]
private static partial ulong RhpULDiv(ulong dividend, ulong divisor);

public static ulong ULDiv(ulong dividend, ulong divisor)
public static ulong ULDiv(ulong divisor, ulong dividend)
{
if (divisor == 0)
ThrowHelper.ThrowDivideByZeroException();
Expand All @@ -60,7 +60,7 @@ public static ulong ULDiv(ulong dividend, ulong divisor)
[SuppressGCTransition]
private static partial long RhpLDiv(long dividend, long divisor);

public static long LDiv(long dividend, long divisor)
public static long LDiv(long divisor, long dividend)
{
if (divisor == 0)
ThrowHelper.ThrowDivideByZeroException();
Expand Down
9 changes: 8 additions & 1 deletion src/coreclr/vm/fcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,14 @@ struct FCSigCheck {
{ \
while (NULL == \
__FCThrow(__me, reKind, 0, 0, 0, 0)) {}; \
return 0; \
return 0; \
}

#define FCThrowRetVoid(reKind) \
{ \
while (NULL == \
__FCThrow(__me, reKind, 0, 0, 0, 0)) {}; \
return; \
}

// The managed calling convention expects returned small types (e.g. bool) to be
Expand Down
Loading
Loading