From: Pat Gavlin Date: Wed, 15 Feb 2017 01:08:44 +0000 (-0800) Subject: Handle contained nodes earlier in buildRefPositionsForNode. X-Git-Tag: submit/tizen/20210909.063632~11030^2~7909^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=41cde53c9db047012083c90c17734bddc8fec203;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Handle contained nodes earlier in buildRefPositionsForNode. These nodes never produce ref positions. Handling them earlier in this function avoids a rather large amount of unnecessary work (e.g. this decreases overall compile time by about 0.5% for `crossgen System.Private.CoreLib`). Commit migrated from https://github.com/dotnet/coreclr/commit/aa910800a204edff57b51d1cb3e7960dd0f98656 --- diff --git a/src/coreclr/src/jit/lsra.cpp b/src/coreclr/src/jit/lsra.cpp index 2d317a7..00c1b7b 100644 --- a/src/coreclr/src/jit/lsra.cpp +++ b/src/coreclr/src/jit/lsra.cpp @@ -3563,6 +3563,39 @@ void LinearScan::buildRefPositionsForNode(GenTree* tree, } #endif // DEBUG + const bool isContainedNode = !info.isLocalDefUse && consume == 0 && produce == 0 && tree->canBeContained(); + if (isContainedNode) + { + assert(info.internalIntCount == 0); + assert(info.internalFloatCount == 0); + + // Contained nodes map to the concatenated lists of their operands. + LocationInfoList locationInfoList; + for (GenTree* op : tree->Operands()) + { + if (!op->gtLsraInfo.definesAnyRegisters) + { + assert(ComputeOperandDstCount(op) == 0); + continue; + } + + LocationInfoList operandList; + bool removed = operandToLocationInfoMap.TryRemove(op, &operandList); + assert(removed); + + locationInfoList.Append(operandList); + } + + if (!locationInfoList.IsEmpty()) + { + bool added = operandToLocationInfoMap.AddOrUpdate(tree, locationInfoList); + assert(added); + tree->gtLsraInfo.definesAnyRegisters = true; + } + + return; + } + // Handle the case of local variable assignment Interval* varDefInterval = nullptr; RefType defRefType = RefTypeDef; @@ -4071,27 +4104,6 @@ void LinearScan::buildRefPositionsForNode(GenTree* tree, buildUpperVectorRestoreRefPositions(tree, defLocation, liveLargeVectors); #endif // FEATURE_PARTIAL_SIMD_CALLEE_SAVE - bool isContainedNode = !noAdd && consume == 0 && produce == 0 && - (tree->OperIsFieldListHead() || ((tree->TypeGet() != TYP_VOID) && !tree->OperIsStore())); - if (isContainedNode) - { - // Contained nodes map to the concatenated lists of their operands. - for (GenTree* op : tree->Operands()) - { - if (!op->gtLsraInfo.definesAnyRegisters) - { - assert(ComputeOperandDstCount(op) == 0); - continue; - } - - LocationInfoList operandList; - bool removed = operandToLocationInfoMap.TryRemove(op, &operandList); - assert(removed); - - locationInfoList.Append(operandList); - } - } - if (!locationInfoList.IsEmpty()) { bool added = operandToLocationInfoMap.AddOrUpdate(tree, locationInfoList); diff --git a/src/coreclr/src/jit/lsra.h b/src/coreclr/src/jit/lsra.h index c8a3fb4..f3f9336 100644 --- a/src/coreclr/src/jit/lsra.h +++ b/src/coreclr/src/jit/lsra.h @@ -744,6 +744,9 @@ private: TreeNodeInfo& info = tree->gtLsraInfo; info.srcCount = 0; info.dstCount = 0; + + info.internalIntCount = 0; + info.internalFloatCount = 0; } inline bool isLocalDefUse(GenTree* tree)