Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 0a04fd0

Browse files
committed
Port the fix for Issue 17969 to Rel/2.1
1 parent 73b3ec3 commit 0a04fd0

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/jit/morph.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10714,21 +10714,24 @@ GenTree* Compiler::fgMorphCopyBlock(GenTree* tree)
1071410714
}
1071510715
}
1071610716

10717+
// Check to see if we are doing a copy to/from the same local block.
10718+
// If so, morph it to a nop.
10719+
if ((destLclVar != nullptr) && (srcLclVar == destLclVar) && (destFldSeq == srcFldSeq) &&
10720+
destFldSeq != FieldSeqStore::NotAField())
10721+
{
10722+
JITDUMP("Self-copy; replaced with a NOP.\n");
10723+
GenTree* nop = gtNewNothingNode();
10724+
INDEBUG(nop->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED);
10725+
return nop;
10726+
}
10727+
1071710728
// Check to see if we are required to do a copy block because the struct contains holes
1071810729
// and either the src or dest is externally visible
1071910730
//
1072010731
bool requiresCopyBlock = false;
1072110732
bool srcSingleLclVarAsg = false;
1072210733
bool destSingleLclVarAsg = false;
1072310734

10724-
if ((destLclVar != nullptr) && (srcLclVar == destLclVar) && (destFldSeq == srcFldSeq))
10725-
{
10726-
// Self-assign; no effect.
10727-
GenTree* nop = gtNewNothingNode();
10728-
INDEBUG(nop->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED);
10729-
return nop;
10730-
}
10731-
1073210735
// If either src or dest is a reg-sized non-field-addressed struct, keep the copyBlock.
1073310736
if ((destLclVar != nullptr && destLclVar->lvRegStruct) || (srcLclVar != nullptr && srcLclVar->lvRegStruct))
1073410737
{

0 commit comments

Comments
 (0)