Skip to content

Commit

Permalink
Add spilling side effect + Fix of formats (#65625)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkiFoD committed Jun 22, 2022
1 parent fd79612 commit 1aed08f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4542,6 +4542,9 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,

retNode = cnsNode;

impSpillSideEffects(false, (unsigned)CHECK_SPILL_ALL DEBUGARG(
"spill side effects before folding two consts"));

impPopStack();
impPopStack();
DEBUG_DESTROY_NODE(otherNode);
Expand All @@ -4553,28 +4556,35 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,

if (cnsNode->IsFloatNaN())
{
impSpillSideEffects(false, (unsigned)CHECK_SPILL_ALL DEBUGARG(
"spill side effects before propagating NaN"));

// maxsd, maxss, minsd, and minss all return op2 if either is NaN
// we require NaN to be propagated so ensure the known NaN is op2

impPopStack();
impPopStack();
DEBUG_DESTROY_NODE(otherNode);

retNode = cnsNode;
break;
}
else if (ni == NI_System_Math_Max)

if (ni == NI_System_Math_Max)
{
// maxsd, maxss return op2 if both inputs are 0 of either sign
// we require +0 to be greater than -0, so we can't handle if
// the known constant is +0. This is because if the unknown value
// is -0, we'd need the cns to be op2. But if the unknown value
// is NaN, we'd need the cns to be op1 instead.

if (cnsNode->IsFloatPositiveZero())
{
break;
}

// Given the checks, op1 can safely be the cns and op2 the other node

ni = (callType == TYP_DOUBLE) ? NI_SSE2_Max : NI_SSE_Max;

// one is constant and we know its something we can handle, so pop both peeked values
Expand All @@ -4591,12 +4601,14 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
// the known constant is -0. This is because if the unknown value
// is +0, we'd need the cns to be op2. But if the unknown value
// is NaN, we'd need the cns to be op1 instead.

if (cnsNode->IsFloatNegativeZero())
{
break;
}

// Given the checks, op1 can safely be the cns and op2 the other node

ni = (callType == TYP_DOUBLE) ? NI_SSE2_Min : NI_SSE_Min;

// one is constant and we know its something we can handle, so pop both peeked values
Expand Down

0 comments on commit 1aed08f

Please sign in to comment.