Skip to content

Commit 4611a8b

Browse files
Gang Y Chenigcbot
authored andcommitted
fix FuseResourceLoop 3rd try
cannot reuse source variable for inst inside a fused resource-loop
1 parent e5f776d commit 4611a8b

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ CShader::CShader(Function* pFunc, CShaderProgram* pProgram)
4242
m_DL = nullptr;
4343
m_FGA = nullptr;
4444
m_VRA = nullptr;
45+
m_RLA = nullptr;
4546
m_EmitPass = nullptr;
4647
m_HW_TID = nullptr;
4748

@@ -3277,7 +3278,12 @@ CVariable* CShader::GetSymbol(llvm::Value* value, bool fromConstantPool)
32773278
{
32783279
if (auto Inst = dyn_cast<Instruction>(value))
32793280
{
3280-
var = GetSymbolFromSource(Inst, preferredAlign);
3281+
// cannot reuse source variable
3282+
// when the instruction is inside a resource-loop
3283+
if (m_RLA->GetResourceLoopMarker(Inst) ==
3284+
ResourceLoopAnalysis::MarkResourceLoopOutside) {
3285+
var = GetSymbolFromSource(Inst, preferredAlign);
3286+
}
32813287
}
32823288
}
32833289
}

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ bool EmitPass::runOnFunction(llvm::Function& F)
687687
m_currShader->SetFunctionGroupAnalysis(m_FGA);
688688
m_currShader->SetPushInfoHelper(&(m_moduleMD->pushInfo));
689689
m_currShader->SetVariableReuseAnalysis(m_VRA);
690+
m_currShader->SetResourceLoopAnalysis(m_RLA);
690691
m_currShader->SetDeSSAHelper(m_deSSA);
691692
m_currShader->SetEmitPassHelper(this);
692693

IGC/Compiler/CISACodeGen/ResourceLoopAnalysis.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,16 @@ bool ResourceLoopAnalysis::runOnFunction(Function &F) {
175175
}
176176

177177
if (!LoopEnd) {
178+
if (prevMemIter != BB->end()) {
179+
// mark instructions in between two mem-op as inside
180+
auto III = prevMemIter;
181+
++III;
182+
while (III != II) {
183+
auto InBetween = &*III;
184+
LoopMap[InBetween] = MarkResourceLoopInside;
185+
++III;
186+
}
187+
}
178188
LoopMap[I] = MarkResourceLoopInside;
179189
prevMemIter = II;
180190
DefSet.insert(I);

IGC/Compiler/CISACodeGen/ShaderCodeGen.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class DeSSA;
4848
class CoalescingEngine;
4949
class GenXFunctionGroupAnalysis;
5050
class VariableReuseAnalysis;
51+
class ResourceLoopAnalysis;
5152
class EmitPass;
5253

5354
struct PushInfo;
@@ -292,6 +293,7 @@ class CShader
292293
void SetDominatorTreeHelper(llvm::DominatorTree* DT) { m_DT = DT; }
293294
void SetDataLayout(const llvm::DataLayout* DL) { m_DL = DL; }
294295
void SetVariableReuseAnalysis(VariableReuseAnalysis* VRA) { m_VRA = VRA; }
296+
void SetResourceLoopAnalysis(ResourceLoopAnalysis *RLA) { m_RLA = RLA; }
295297
void SetMetaDataUtils(IGC::IGCMD::MetaDataUtils* pMdUtils) { m_pMdUtils = pMdUtils; }
296298
void SetScratchSpaceSize(uint size) { m_ScratchSpaceSize = size; }
297299

@@ -667,6 +669,7 @@ class CShader
667669
const llvm::DataLayout* m_DL;
668670
GenXFunctionGroupAnalysis* m_FGA;
669671
VariableReuseAnalysis* m_VRA;
672+
ResourceLoopAnalysis* m_RLA;
670673

671674
uint m_numBlocks;
672675
IGC::IGCMD::MetaDataUtils* m_pMdUtils;

0 commit comments

Comments
 (0)