Skip to content
Merged
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
44 changes: 29 additions & 15 deletions src/coreclr/jit/rationalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ void Rationalizer::RewriteNodeAsCall(GenTree** use,
// Replace "tree" with "call"
if (parents.Height() > 1)
{
GenTree* tmpInsertionPoint = insertionPoint;

if (tmpNum != BAD_VAR_NUM)
{
result = comp->gtNewLclvNode(tmpNum, retType);
Expand All @@ -169,18 +167,17 @@ void Rationalizer::RewriteNodeAsCall(GenTree** use,
#if defined(FEATURE_HW_INTRINSICS)
// No managed call returns TYP_MASK, so convert it from a TYP_SIMD

var_types simdType = tree->TypeGet();
assert(varTypeIsSIMD(simdType));

unsigned simdSize;
CorInfoType simdBaseJitType = comp->getBaseJitTypeAndSizeOfSIMDType(call->gtRetClsHnd, &simdSize);
assert(simdSize != 0);

GenTree* cvtNode = comp->gtNewSimdCvtVectorToMaskNode(TYP_MASK, result, simdBaseJitType, simdSize);
BlockRange().InsertAfter(insertionPoint, LIR::Range(comp->fgSetTreeSeq(cvtNode), cvtNode));
result = cvtNode;
result = comp->gtNewSimdCvtVectorToMaskNode(TYP_MASK, result, simdBaseJitType, simdSize);

tmpInsertionPoint = result;
if (tmpNum == BAD_VAR_NUM)
{
// Propagate flags of "call" to its parent.
result->gtFlags |= (call->gtFlags & GTF_ALL_EFFECT) | GTF_CALL;
}
#else
unreached();
#endif // FEATURE_HW_INTRINSICS
Expand All @@ -190,27 +187,44 @@ void Rationalizer::RewriteNodeAsCall(GenTree** use,

if (tmpNum != BAD_VAR_NUM)
{
// We have a return buffer, so we need to insert both the result and the call
// since they are independent trees. If we have a convert node, it will indirectly
// insert the local node.

comp->gtSetEvalOrder(result);
BlockRange().InsertAfter(insertionPoint, LIR::Range(comp->fgSetTreeSeq(result), result));

comp->gtSetEvalOrder(call);
BlockRange().InsertAfter(insertionPoint, LIR::Range(comp->fgSetTreeSeq(call), call));
}
else
{
// We don't have a return buffer, so we only need to insert the result, which
// will indirectly insert the call in the case we have a convert node as well.

comp->gtSetEvalOrder(result);
BlockRange().InsertAfter(tmpInsertionPoint, LIR::Range(comp->fgSetTreeSeq(result), result));
BlockRange().InsertAfter(insertionPoint, LIR::Range(comp->fgSetTreeSeq(result), result));
}
}
else
{
// If there's no parent, the tree being replaced is the root of the
// statement (and no special handling is necessary).
*use = result;
}

comp->gtSetEvalOrder(call);
BlockRange().InsertAfter(insertionPoint, LIR::Range(comp->fgSetTreeSeq(call), call));
comp->gtSetEvalOrder(call);
BlockRange().InsertAfter(insertionPoint, LIR::Range(comp->fgSetTreeSeq(call), call));
}

if (result == call)
if (tmpNum == BAD_VAR_NUM)
{
// Propagate flags of "call" to its parents.
GenTreeFlags callFlags = (call->gtFlags & GTF_ALL_EFFECT) | GTF_CALL;

// 0 is current node, so start at 1
for (int i = 1; i < parents.Height(); i++)
{
parents.Top(i)->gtFlags |= (call->gtFlags & GTF_ALL_EFFECT) | GTF_CALL;
parents.Top(i)->gtFlags |= callFlags;
}
}
else
Expand Down