Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JIT] Support x % {pow2_cns} transformation for ulong types #79676

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
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
11 changes: 7 additions & 4 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9108,11 +9108,10 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA

case GT_UMOD:

#ifdef TARGET_ARMARCH
//
// Note for TARGET_ARMARCH we don't have a remainder instruction, so we don't do this optimization
//
#else // TARGET_XARCH
#ifdef TARGET_X86
// If this is an unsigned long mod with a constant divisor,
// then don't morph to a helper call - it can be done faster inline using idiv.

Expand Down Expand Up @@ -9145,7 +9144,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac, bool* optA
return tree;
}
}
#endif // TARGET_XARCH
#endif // TARGET_X86

ASSIGN_HELPER_FOR_MOD:

Expand Down Expand Up @@ -12433,7 +12432,8 @@ GenTree* Compiler::fgMorphModToSubMulDiv(GenTreeOp* tree)
//
GenTree* Compiler::fgMorphUModToAndSub(GenTreeOp* tree)
{
JITDUMP("\nMorphing UMOD [%06u] to And/Sub\n", dspTreeID(tree));
JITDUMP("\nMorphing UMOD [%06u] to And/Sub (before)\n", dspTreeID(tree));
DISPTREE(tree);

assert(tree->OperIs(GT_UMOD));
assert(tree->gtOp2->IsIntegralConstUnsignedPow2());
Expand All @@ -12447,6 +12447,9 @@ GenTree* Compiler::fgMorphUModToAndSub(GenTreeOp* tree)

DEBUG_DESTROY_NODE(tree->gtOp2);
DEBUG_DESTROY_NODE(tree);

JITDUMP("\nMorphing UMOD [%06u] to And/Sub (after)\n", dspTreeID(tree));
DISPTREE(newTree);

return newTree;
}
Expand Down