Skip to content

Commit 5975649

Browse files
authored
Enable UMOD optimization for x64 (#68091)
1 parent cb2277d commit 5975649

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/coreclr/jit/morph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10759,14 +10759,14 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
1075910759

1076010760
if (!optValnumCSE_phase)
1076110761
{
10762-
#ifdef TARGET_ARM64
1076310762
if (tree->OperIs(GT_UMOD) && op2->IsIntegralConstUnsignedPow2())
1076410763
{
1076510764
// Transformation: a % b = a & (b - 1);
1076610765
tree = fgMorphUModToAndSub(tree->AsOp());
1076710766
op1 = tree->AsOp()->gtOp1;
1076810767
op2 = tree->AsOp()->gtOp2;
1076910768
}
10769+
#ifdef TARGET_ARM64
1077010770
// ARM64 architecture manual suggests this transformation
1077110771
// for the mod operator.
1077210772
// However, we do skip this optimization for ARM64 if the second operand
@@ -10779,7 +10779,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac)
1077910779
// when 'b' is not a power of 2 constant and mod operator is signed.
1078010780
// Lowering for XARCH does this optimization already,
1078110781
// but is also done here to take advantage of CSE.
10782-
if (tree->OperIs(GT_MOD) && op2->IsIntegralConst() && !op2->IsIntegralConstAbsPow2())
10782+
else if (tree->OperIs(GT_MOD) && op2->IsIntegralConst() && !op2->IsIntegralConstAbsPow2())
1078310783
#endif
1078410784
{
1078510785
// Transformation: a % b = a - (a / b) * b;

0 commit comments

Comments
 (0)