Skip to content

Commit 7aa67b7

Browse files
committed
[RISC-V] Use getUnrollThreshold() to get unroll limits
1 parent bf4e90f commit 7aa67b7

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

src/coreclr/jit/codegenriscv64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,7 +2511,7 @@ void CodeGen::genCodeForDivMod(GenTreeOp* tree)
25112511
// Generate code for InitBlk by performing a loop unroll
25122512
// Preconditions:
25132513
// a) Both the size and fill byte value are integer constants.
2514-
// b) The size of the struct to initialize is smaller than INITBLK_UNROLL_LIMIT bytes.
2514+
// b) The size of the struct to initialize is smaller than getUnrollThreshold() bytes.
25152515
void CodeGen::genCodeForInitBlkUnroll(GenTreeBlk* node)
25162516
{
25172517
assert(node->OperIs(GT_STORE_BLK));
@@ -6176,7 +6176,7 @@ void CodeGen::genCodeForIndir(GenTreeIndir* tree)
61766176
// None
61776177
//
61786178
// Assumption:
6179-
// The size argument of the CpBlk node is a constant and <= CPBLK_UNROLL_LIMIT bytes.
6179+
// The size argument of the CpBlk node is a constant and <= getUnrollThreshold() bytes.
61806180
//
61816181
void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* cpBlkNode)
61826182
{

src/coreclr/jit/compiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9222,6 +9222,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
92229222
// | arm64 | 256 | 128 | ldp/stp (2x128bit)
92239223
// | arm | 32 | 16 | no SIMD support
92249224
// | loongarch64 | 64 | 32 | no SIMD support
9225+
// | riscv64 | 64 | 32 | no SIMD support
92259226
//
92269227
// We might want to use a different multiplier for truly hot/cold blocks based on PGO data
92279228
//

src/coreclr/jit/lowerriscv64.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
245245
src = src->AsUnOp()->gtGetOp1();
246246
}
247247

248-
if (!blkNode->OperIs(GT_STORE_DYN_BLK) && (size <= INITBLK_UNROLL_LIMIT) && src->OperIs(GT_CNS_INT))
248+
if (!blkNode->OperIs(GT_STORE_DYN_BLK) && (size <= comp->getUnrollThreshold(Compiler::UnrollKind::Memset)) &&
249+
src->OperIs(GT_CNS_INT))
249250
{
250251
blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindUnroll;
251252

@@ -300,8 +301,9 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
300301

301302
ClassLayout* layout = blkNode->GetLayout();
302303
bool doCpObj = !blkNode->OperIs(GT_STORE_DYN_BLK) && layout->HasGCPtr();
304+
unsigned copyBlockUnrollLimit = comp->getUnrollThreshold(Compiler::UnrollKind::Memcpy);
303305

304-
if (doCpObj && (size <= CPBLK_UNROLL_LIMIT))
306+
if (doCpObj && (size <= copyBlockUnrollLimit))
305307
{
306308
// No write barriers are needed on the stack.
307309
// If the layout contains a byref, then we know it must live on the stack.
@@ -321,7 +323,7 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
321323
assert((dstAddr->TypeGet() == TYP_BYREF) || (dstAddr->TypeGet() == TYP_I_IMPL));
322324
blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindCpObjUnroll;
323325
}
324-
else if (blkNode->OperIs(GT_STORE_BLK) && (size <= CPBLK_UNROLL_LIMIT))
326+
else if (blkNode->OperIs(GT_STORE_BLK) && (size <= copyBlockUnrollLimit))
325327
{
326328
blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindUnroll;
327329

src/coreclr/jit/targetriscv64.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#define ROUND_FLOAT 0 // Do not round intermed float expression results
1313
#define CPU_HAS_BYTE_REGS 0
1414

15-
#define CPBLK_UNROLL_LIMIT 64 // Upper bound to let the code generator to loop unroll CpBlk
16-
#define INITBLK_UNROLL_LIMIT 64 // Upper bound to let the code generator to loop unroll InitBlk
1715

1816
#ifdef FEATURE_SIMD
1917
#pragma error("SIMD Unimplemented yet RISCV64")

0 commit comments

Comments
 (0)