Skip to content

Commit 115eb70

Browse files
dlei6gigcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: f2125de
Only enable CallWA for SIMD32 when nested stackcalls or indirect calls are present Only enable CallWA for SIMD32 when nested stackcalls or indirect calls are present. Also added two FunctionGroupAnalysis Function Group attributes: hasSubroutine() and isIndirectCallGroup().
1 parent 7d0082d commit 115eb70

File tree

6 files changed

+31
-57
lines changed

6 files changed

+31
-57
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4301,7 +4301,7 @@ namespace IGC
43014301
{
43024302
SaveOption(vISA_fusedCallWA, (uint32_t)2);
43034303
}
4304-
else if (m_program->HasNestedCalls() || m_program->HasIndirectCalls() || m_program->IsIntelSymbolTableVoidProgram())
4304+
else if (m_program->HasStackCalls() || m_program->IsIntelSymbolTableVoidProgram())
43054305
{
43064306
SaveOption(vISA_fusedCallWA, (uint32_t)1);
43074307
}

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,15 @@ bool EmitPass::runOnFunction(llvm::Function& F)
687687
CShader* prevShader = m_pCtx->m_prevShader;
688688
if (isFuncGroupHead)
689689
{
690+
if (hasStackCall)
691+
{
692+
m_currShader->SetHasStackCalls();
693+
}
694+
if (isDummyKernel)
695+
{
696+
m_currShader->SetIsIntelSymbolTableVoidProgram();
697+
}
698+
690699
m_currShader->InitEncoder(m_SimdMode, m_canAbortOnSpill, m_ShaderDispatchMode);
691700
// Pre-analysis pass to be executed before call to visa builder so we can pass scratch space offset
692701
m_currShader->PreAnalysisPass();

IGC/Compiler/CISACodeGen/GenCodeGenModule.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,6 @@ void GenXFunctionGroupAnalysis::setGroupAttributes()
630630
// to this group due to cloning. However we still can't associate all functions in this group with a single callgraph.
631631

632632
// All other flags are already unset by default
633-
FG->m_isIndirectCallGroup = true;
634633
FG->m_hasCGAvailable = false;
635634
continue;
636635
}
@@ -651,10 +650,6 @@ void GenXFunctionGroupAnalysis::setGroupAttributes()
651650
FG->m_hasNestedCall = true;
652651
}
653652
}
654-
else if (!isEntryFunc(pMdUtils, F))
655-
{
656-
FG->m_hasSubroutine = true;
657-
}
658653

659654
// check all functions in the group to see if there's an vla alloca
660655
// function attribute "hasVLA" should be set at ProcessFuncAttributes pass

IGC/Compiler/CISACodeGen/GenCodeGenModule.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ namespace IGC {
135135
bool isSingle() const {
136136
return (Functions.size() == 1 && Functions.front()->size() == 1);
137137
}
138-
/// \brief Function group has a subroutine
139-
bool hasSubroutine() const {
140-
return m_hasSubroutine;
141-
}
142138
/// \brief Function group has a stack call (including indirect calls)
143139
bool hasStackCall() const {
144140
return m_hasStackCall;
@@ -166,10 +162,6 @@ namespace IGC {
166162
bool hasRecursion() const {
167163
return m_hasRecursion;
168164
}
169-
/// \brief This is the indirect call group
170-
bool isIndirectCallGroup() const {
171-
return m_isIndirectCallGroup;
172-
}
173165

174166
void replaceGroupHead(llvm::Function* OH, llvm::Function* NH) {
175167
IGC_UNUSED(OH);
@@ -185,15 +177,13 @@ namespace IGC {
185177
void setSimdModeInvalid(SIMDMode Mode);
186178

187179
private:
188-
bool m_hasSubroutine = false;
189180
bool m_hasStackCall = false;
190181
bool m_hasInlineAsm = false;
191182
bool m_hasVariableLengthAlloca = false;
192183
bool m_hasIndirectCall = false;
193184
bool m_hasRecursion = false;
194185
bool m_hasNestedCall = false;
195186
bool m_hasCGAvailable = true;
196-
bool m_isIndirectCallGroup = false;
197187
bool SIMDModeValid[3] = {true, true, true};
198188
};
199189

IGC/Compiler/CISACodeGen/OpenCLKernelCodeGen.cpp

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3927,10 +3927,9 @@ namespace IGC
39273927
simd_size = funcInfoMD->getSubGroupSize()->getSIMD_size();
39283928
}
39293929

3930-
auto FG = m_FGA ? m_FGA->getGroup(&F) : nullptr;
3931-
bool hasStackCall = FG && FG->hasStackCall();
3932-
bool isIndirectGroup = FG && FG->isIndirectCallGroup();
3933-
bool hasSubroutine = FG && !FG->isSingle() && !hasStackCall && !isIndirectGroup;
3930+
bool hasStackCall = m_FGA && m_FGA->getGroup(&F) && m_FGA->getGroup(&F)->hasStackCall();
3931+
bool isIndirectGroup = m_FGA && m_FGA->getGroup(&F) && IGC::isIntelSymbolTableVoidProgram(m_FGA->getGroupHead(&F));
3932+
bool hasSubroutine = m_FGA && m_FGA->getGroup(&F) && !m_FGA->getGroup(&F)->isSingle() && !hasStackCall && !isIndirectGroup;
39343933
bool forceLowestSIMDForStackCalls = IGC_IS_FLAG_ENABLED(ForceLowestSIMDForStackCalls) && (hasStackCall || isIndirectGroup);
39353934

39363935
if (simd_size == 0)
@@ -4099,31 +4098,26 @@ namespace IGC
40994098
}
41004099
}
41014100

4102-
auto FG = m_FGA ? m_FGA->getGroup(&F) : nullptr;
4103-
bool hasStackCall = FG && FG->hasStackCall();
4104-
bool isIndirectGroup = FG && FG->isIndirectCallGroup();
4105-
bool hasSubroutine = FG && !FG->isSingle() && !hasStackCall && !isIndirectGroup;
4101+
bool hasStackCall = m_FGA && m_FGA->getGroup(&F) && m_FGA->getGroup(&F)->hasStackCall();
4102+
bool isIndirectGroup = m_FGA && m_FGA->getGroup(&F) && IGC::isIntelSymbolTableVoidProgram(m_FGA->getGroupHead(&F));
4103+
bool hasSubroutine = m_FGA && m_FGA->getGroup(&F) && !m_FGA->getGroup(&F)->isSingle() && !hasStackCall && !isIndirectGroup;
41064104

41074105
// If stack calls are present, disable simd32 in order to do CallWA in visa
41084106
if (IGC_IS_FLAG_ENABLED(EnableCallWA) &&
41094107
pCtx->platform.hasFusedEU() &&
41104108
pCtx->platform.getWATable().Wa_14016243945 == false &&
4111-
simdMode == SIMDMode::SIMD32)
4109+
simdMode == SIMDMode::SIMD32 &&
4110+
(hasStackCall || isIndirectGroup))
41124111
{
4113-
bool hasNestedCall = FG && FG->hasNestedCall();
4114-
bool hasIndirectCall = FG && FG->hasIndirectCall();
4115-
if (hasNestedCall || hasIndirectCall || isIndirectGroup)
4112+
// If sub_group_size is set to 32, resize it to 16 so SIMD16 compilation will still succeed
4113+
if (simd_size == 32)
41164114
{
4117-
// If sub_group_size is set to 32, resize it to 16 so SIMD16 compilation will still succeed
4118-
if (simd_size == 32)
4119-
{
4120-
llvm::Function* Kernel = FG->getHead();
4121-
funcInfoMD = pMdUtils->getFunctionsInfoItem(Kernel);
4122-
funcInfoMD->getSubGroupSize()->setSIMD_size(16);
4123-
}
4124-
pCtx->SetSIMDInfo(SIMD_SKIP_HW, simdMode, ShaderDispatchMode::NOT_APPLICABLE);
4125-
return SIMDStatus::SIMD_FUNC_FAIL;
4115+
llvm::Function* Kernel = m_FGA->getGroup(&F)->getHead();
4116+
funcInfoMD = pMdUtils->getFunctionsInfoItem(Kernel);
4117+
funcInfoMD->getSubGroupSize()->setSIMD_size(16);
41264118
}
4119+
pCtx->SetSIMDInfo(SIMD_SKIP_HW, simdMode, ShaderDispatchMode::NOT_APPLICABLE);
4120+
return SIMDStatus::SIMD_FUNC_FAIL;
41274121
}
41284122

41294123
if (simd_size == 0)

IGC/Compiler/CISACodeGen/ShaderCodeGen.hpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -576,26 +576,10 @@ class CShader
576576
unsigned int GetScalarTypeSizeInRegisterInBits(const llvm::Type* Ty) const;
577577
unsigned int GetScalarTypeSizeInRegister(const llvm::Type* Ty) const;
578578

579-
inline bool HasStackCalls() const
580-
{
581-
auto FG = m_FGA ? m_FGA->getGroupForHead(entry) : nullptr;
582-
return (FG && FG->hasStackCall()) || IGC_IS_FLAG_ENABLED(ForceAddingStackcallKernelPrerequisites);
583-
}
584-
inline bool IsIntelSymbolTableVoidProgram() const
585-
{
586-
auto FG = m_FGA ? m_FGA->getGroupForHead(entry) : nullptr;
587-
return FG && FG->isIndirectCallGroup();
588-
}
589-
inline bool HasNestedCalls() const
590-
{
591-
auto FG = m_FGA ? m_FGA->getGroupForHead(entry) : nullptr;
592-
return FG && FG->hasNestedCall();
593-
}
594-
inline bool HasIndirectCalls() const
595-
{
596-
auto FG = m_FGA ? m_FGA->getGroupForHead(entry) : nullptr;
597-
return FG && FG->hasIndirectCall();
598-
}
579+
bool HasStackCalls() const { return m_HasStackCalls; }
580+
void SetHasStackCalls() { m_HasStackCalls = true; }
581+
bool IsIntelSymbolTableVoidProgram() const { return m_isIntelSymbolTableVoidProgram; }
582+
void SetIsIntelSymbolTableVoidProgram() { m_isIntelSymbolTableVoidProgram = true; }
599583

600584
////////////////////////////////////////////////////////////////////
601585
// NOTE: for vector load/stores instructions pass the
@@ -753,6 +737,8 @@ class CShader
753737

754738
DebugInfoData diData;
755739

740+
bool m_HasStackCalls = false;
741+
bool m_isIntelSymbolTableVoidProgram = false;
756742
// Shader has LSC store messages with non-default L1 cache control
757743
bool m_HasLscStoresWithNonDefaultL1CacheControls = false;
758744
bool m_HasSample = false;

0 commit comments

Comments
 (0)