Skip to content

Commit

Permalink
Ensure that we can still inline Math.Max and Math.Min on downlevel ha…
Browse files Browse the repository at this point in the history
…rdware (#88106)
  • Loading branch information
tannergooding authored Jun 27, 2023
1 parent 3b7afc7 commit d48a250
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8088,7 +8088,7 @@ GenTree* Compiler::impMinMaxIntrinsic(CORINFO_METHOD_HANDLE method,
{
// Given the checks, op1 can safely be the cns and op2 the other node

intrinsicName = (callType == TYP_DOUBLE) ? NI_SSE2_Max : NI_SSE_Max;
intrinsicName = (callType == TYP_DOUBLE) ? NI_SSE2_MaxScalar : NI_SSE_MaxScalar;

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

Expand Down Expand Up @@ -8118,18 +8118,18 @@ GenTree* Compiler::impMinMaxIntrinsic(CORINFO_METHOD_HANDLE method,

if (isNumber)
{
needsFixup = cnsNode->IsFloatNegativeZero();
needsFixup = cnsNode->IsFloatPositiveZero();
}
else
{
needsFixup = cnsNode->IsFloatPositiveZero();
needsFixup = cnsNode->IsFloatNegativeZero();
}

if (!needsFixup || compOpportunisticallyDependsOn(InstructionSet_AVX512F))
{
// Given the checks, op1 can safely be the cns and op2 the other node

intrinsicName = (callType == TYP_DOUBLE) ? NI_SSE2_Min : NI_SSE_Min;
intrinsicName = (callType == TYP_DOUBLE) ? NI_SSE2_MinScalar : NI_SSE_MinScalar;

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

Expand Down Expand Up @@ -8390,7 +8390,10 @@ GenTree* Compiler::impMinMaxIntrinsic(CORINFO_METHOD_HANDLE method,
}
#endif // FEATURE_HW_INTRINSICS && TARGET_XARCH

return impMathIntrinsic(method, sig, callType, intrinsicName, tailCall);
// TODO-CQ: Returning this as an intrinsic blocks inlining and is undesirable
// return impMathIntrinsic(method, sig, callType, intrinsicName, tailCall);

return nullptr;
}

//------------------------------------------------------------------------
Expand Down

0 comments on commit d48a250

Please sign in to comment.