Skip to content

Commit 3ddaeae

Browse files
authored
[RISC-V] Use getUnrollThreshold() to get unroll limits (#98798)
* [RISC-V] Use getUnrollThreshold() to get unroll limits * Modify formatting --------- Co-authored-by: monstercat <[email protected]>
1 parent 54e9ffe commit 3ddaeae

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/coreclr/jit/codegenriscv64.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,7 +2499,7 @@ void CodeGen::genCodeForDivMod(GenTreeOp* tree)
24992499
// Generate code for InitBlk by performing a loop unroll
25002500
// Preconditions:
25012501
// a) Both the size and fill byte value are integer constants.
2502-
// b) The size of the struct to initialize is smaller than INITBLK_UNROLL_LIMIT bytes.
2502+
// b) The size of the struct to initialize is smaller than getUnrollThreshold() bytes.
25032503
void CodeGen::genCodeForInitBlkUnroll(GenTreeBlk* node)
25042504
{
25052505
assert(node->OperIs(GT_STORE_BLK));
@@ -6138,7 +6138,7 @@ void CodeGen::genCodeForIndir(GenTreeIndir* tree)
61386138
// None
61396139
//
61406140
// Assumption:
6141-
// The size argument of the CpBlk node is a constant and <= CPBLK_UNROLL_LIMIT bytes.
6141+
// The size argument of the CpBlk node is a constant and <= getUnrollThreshold() bytes.
61426142
//
61436143
void CodeGen::genCodeForCpBlkUnroll(GenTreeBlk* cpBlkNode)
61446144
{

src/coreclr/jit/compiler.h

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

src/coreclr/jit/lowerriscv64.cpp

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

248-
if ((size <= INITBLK_UNROLL_LIMIT) && src->OperIs(GT_CNS_INT))
248+
if ((size <= comp->getUnrollThreshold(Compiler::UnrollKind::Memset)) && src->OperIs(GT_CNS_INT))
249249
{
250250
blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindUnroll;
251251

@@ -298,10 +298,11 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
298298
comp->lvaSetVarDoNotEnregister(srcLclNum DEBUGARG(DoNotEnregisterReason::BlockOp));
299299
}
300300

301-
ClassLayout* layout = blkNode->GetLayout();
302-
bool doCpObj = layout->HasGCPtr();
301+
ClassLayout* layout = blkNode->GetLayout();
302+
bool doCpObj = layout->HasGCPtr();
303+
unsigned copyBlockUnrollLimit = comp->getUnrollThreshold(Compiler::UnrollKind::Memcpy);
303304

304-
if (doCpObj && (size <= CPBLK_UNROLL_LIMIT))
305+
if (doCpObj && (size <= copyBlockUnrollLimit))
305306
{
306307
// No write barriers are needed on the stack.
307308
// If the layout contains a byref, then we know it must live on the stack.
@@ -321,7 +322,7 @@ void Lowering::LowerBlockStore(GenTreeBlk* blkNode)
321322
assert((dstAddr->TypeGet() == TYP_BYREF) || (dstAddr->TypeGet() == TYP_I_IMPL));
322323
blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindCpObjUnroll;
323324
}
324-
else if (blkNode->OperIs(GT_STORE_BLK) && (size <= CPBLK_UNROLL_LIMIT))
325+
else if (blkNode->OperIs(GT_STORE_BLK) && (size <= copyBlockUnrollLimit))
325326
{
326327
blkNode->gtBlkOpKind = GenTreeBlk::BlkOpKindUnroll;
327328

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)