Skip to content

Commit

Permalink
Preserve cache policy metadata
Browse files Browse the repository at this point in the history
Changed some load optimization passes so that they preserve
the lsc.cache.ctrl metadata that is used to override cache
policy in the HW.
  • Loading branch information
davidjwoo authored and igcbot committed Aug 5, 2024
1 parent f21497a commit bbaecb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions IGC/Compiler/CISACodeGen/LdShrink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ bool LdShrink::runOnFunction(Function& F) {

LoadInst* NewLoad = Builder.CreateAlignedLoad(ScalarTy, ScalarPtr, IGCLLVM::getAlign(alignment));
NewLoad->setDebugLoc(LI->getDebugLoc());
if (MDNode* mdNode = LI->getMetadata("lsc.cache.ctrl"))
{
NewLoad->setMetadata("lsc.cache.ctrl", mdNode);
}

ExtractElementInst* EEI = cast<ExtractElementInst>(*LI->user_begin());
EEI->replaceAllUsesWith(NewLoad);
Expand Down
7 changes: 6 additions & 1 deletion IGC/Compiler/CISACodeGen/VectorPreProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ namespace
{
Type* newPtrType = PointerType::get(returnType, ptr->getType()->getPointerAddressSpace());
ptr = builder.CreateBitCast(ptr, newPtrType);
return builder.CreateAlignedLoad(returnType, ptr, IGCLLVM::getAlign(alignment), isVolatile);
LoadInst* newLI = builder.CreateAlignedLoad(returnType, ptr, IGCLLVM::getAlign(alignment), isVolatile);
if (MDNode* lscMetadata = m_inst->getMetadata("lsc.cache.ctrl"))
{
newLI->setMetadata("lsc.cache.ctrl", lscMetadata);
}
return newLI;
}
else
{
Expand Down

0 comments on commit bbaecb1

Please sign in to comment.