Skip to content

Commit

Permalink
Relax unrolling for structs with gc refs (#112227)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorBo authored Feb 6, 2025
1 parent 86dbcbd commit 666bb9d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/coreclr/jit/lowerxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,15 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)

ClassLayout* layout = blkNode->GetLayout();
bool doCpObj = layout->HasGCPtr();
unsigned copyBlockUnrollLimit = comp->getUnrollThreshold(Compiler::UnrollKind::Memcpy, false);
bool isNotHeap = blkNode->IsAddressNotOnHeap(comp);
bool canUseSimd = !doCpObj || isNotHeap;
unsigned copyBlockUnrollLimit = comp->getUnrollThreshold(Compiler::UnrollKind::Memcpy, canUseSimd);

#ifndef JIT32_GCENCODER
if (doCpObj && (size <= copyBlockUnrollLimit))
{
// No write barriers are needed on the stack.
// If the layout is byref-like, then we know it must live on the stack.
if (blkNode->IsAddressNotOnHeap(comp))
// No write barriers are needed if the destination is known to be outside of the GC heap.
if (isNotHeap)
{
// If the size is small enough to unroll then we need to mark the block as non-interruptible
// to actually allow unrolling. The generated code does not report GC references loaded in the
Expand Down Expand Up @@ -515,7 +516,7 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
}
}
else if (blkNode->OperIs(GT_STORE_BLK) &&
(size <= comp->getUnrollThreshold(Compiler::UnrollKind::Memcpy, !layout->HasGCPtr())))
(size <= comp->getUnrollThreshold(Compiler::UnrollKind::Memcpy, canUseSimd)))
{
blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindUnroll;

Expand Down

0 comments on commit 666bb9d

Please sign in to comment.