Skip to content

Commit 5ad198d

Browse files
agrabezhigcbot
authored andcommitted
Improve unroll heuristics for 1-BB loops
Double LoopUnrollThreshold for 1-BB outermost loops in small OCL kernels without Call instructions.
1 parent 2f315fb commit 5ad198d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

IGC/Compiler/GenTTI.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,28 @@ void GenIntrinsicsTTIImpl::getUnrollingPreferences(Loop *L, ScalarEvolution &SE,
539539
return;
540540
}
541541

542+
auto hasCall = [](BasicBlock *BB) {
543+
for (auto BI = BB->begin(), BE = BB->end(); BI != BE; ++BI)
544+
if (isa<CallInst>(&*BI))
545+
return true;
546+
return false;
547+
};
548+
549+
// Double LoopUnrollThreshold for 1-BB outermost loops in small OCL kernels
550+
// without Call instructions, since we expect better optimization
551+
// when these loops are fully unrolled.
552+
if (ctx->type == ShaderType::OPENCL_SHADER && !hasCall(L->getHeader()) && L->getHeader()->getParent()->size() < 5) {
553+
if (!L->getParentLoop() && TripCount != 0 && TripCount < 256) {
554+
UP.Count = TripCount;
555+
UP.MaxCount = UP.Count;
556+
UP.Threshold = LoopUnrollThreshold * 2;
557+
UP.Runtime = false;
558+
UP.Partial = false;
559+
UP.Force = true;
560+
return;
561+
}
562+
}
563+
542564
for (I = loopBlock->begin(); I != loopBlock->end(); I++) {
543565
if (const auto pIntrinsic = llvm::dyn_cast<llvm::GenIntrinsicInst>(I)) {
544566
if (isSendMessage(pIntrinsic)) {

0 commit comments

Comments
 (0)