Skip to content

Commit c83814f

Browse files
jaladreipsigcbot
authored andcommitted
Improve insertion logic for proceed based dynamic ray management
Improve insertion logic for proceed based dynamic ray management
1 parent 6f02ebf commit c83814f

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

IGC/AdaptorCommon/RayTracing/DynamicRayManagementPass.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,16 @@ bool DynamicRayManagementPass::TryProceedBasedApproach(Function& F)
401401
for (auto* checkBB : checkBBs)
402402
{
403403
auto* IP = checkBB->getFirstNonPHI();
404+
405+
// insert the check as far forward as possible into the BB
406+
for (auto& I : *checkBB)
407+
{
408+
IP = &I;
409+
410+
if (isa<TraceRaySyncProceedHLIntrinsic>(&I))
411+
break;
412+
}
413+
404414
IRB.SetInsertPoint(IP);
405415

406416
auto* load = IRB.CreateLoad(guard, VALUE_NAME("RQGuardValue"));
@@ -416,9 +426,19 @@ bool DynamicRayManagementPass::TryProceedBasedApproach(Function& F)
416426
guardStoresAndLoads.push_back(IRB.CreateStore(IRB.getTrue(), guard));
417427
};
418428

419-
for (auto* insertBB : releaseBBs)
429+
for (auto* releaseBB : releaseBBs)
420430
{
421-
auto* IP = insertBB->getTerminator();
431+
auto* IP = releaseBB->getTerminator();
432+
433+
// insert the release as far back as possible into the BB
434+
for (auto& I : llvm::reverse(*releaseBB))
435+
{
436+
if (isa<TraceRaySyncProceedHLIntrinsic>(&I) || isa<PHINode>(&I))
437+
break;
438+
439+
IP = &I;
440+
}
441+
422442
IRB.SetInsertPoint(IP);
423443

424444
auto* cond = IRB.CreateLoad(guard, VALUE_NAME("RQGuardValue"));

0 commit comments

Comments
 (0)