Skip to content

Commit 30de3da

Browse files
srividyakarumurisys_zuul
authored andcommitted
Set loop unroll threshold for high register pressure shaders via IGC flag
Also control the register pressure threshold used to limit the loop unroll to smaller loops via IGC flag Change-Id: Icef68a541145da98c1a04744dbeb3e1152cc5c7e
1 parent 6e03333 commit 30de3da

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

IGC/Compiler/GenTTI.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,22 @@ namespace llvm {
133133
LoopUnrollThreshold = IGC_GET_FLAG_VALUE(SetLoopUnrollThreshold);
134134
}
135135
unsigned totalInstCountInShader = countTotalInstructions(L->getBlocks()[0]->getParent());
136-
bool lowPressure = (this->ctx->m_tempCount < 64) && (totalInstCountInShader < LoopUnrollThreshold);
136+
bool lowPressure = (this->ctx->m_tempCount < IGC_GET_FLAG_VALUE(SetRegisterPressureThresholdForLoopUnroll)) && (totalInstCountInShader < LoopUnrollThreshold);
137137
// For OCL shaders, do a two-step loop unrolling. The first
138138
// unrolling is simple and full, and the second runs after
139139
// LICM, which allows partial unrolling. Same for other APIs?
140-
if (lowPressure || (ctx->type == ShaderType::OPENCL_SHADER) || (IGC_GET_FLAG_VALUE(SetLoopUnrollThreshold)))
140+
if (lowPressure || (ctx->type == ShaderType::OPENCL_SHADER))
141141
{
142142
UP.Threshold = LoopUnrollThreshold;
143143
UP.PartialThreshold = LoopUnrollThreshold;
144144
UP.Partial = true;
145145
}
146146
else // for high registry pressure shaders, limit the unrolling to small loops and only fully unroll
147147
{
148-
UP.Threshold = 200;
148+
if(IGC_GET_FLAG_VALUE(SetLoopUnrollThresholdForHighRegPressure) != 0)
149+
UP.Threshold = IGC_GET_FLAG_VALUE(SetLoopUnrollThresholdForHighRegPressure);
150+
else
151+
UP.Threshold = 200;
149152
}
150153

151154
#if LLVM_VERSION_MAJOR == 4

IGC/common/igc_flags.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ DECLARE_IGC_REGKEY(bool, DisableLoopUnroll, false, "Setting this to
116116
DECLARE_IGC_REGKEY(bool, DisableRuntimeLoopUnrolling, false, "Setting this to 1/true adds a compiler switch to disable runtime loop unrolling.", false)
117117
DECLARE_IGC_REGKEY(bool, DisableBranchSwaping, false, "Setting this to 1/true adds a compiler switch to disable branch swapping.", false)
118118
DECLARE_IGC_REGKEY(DWORD,SetLoopUnrollThreshold, 0, "Set the loop unroll threshold. Value 0 will use the default threshold.", false)
119+
DECLARE_IGC_REGKEY(DWORD,SetLoopUnrollThresholdForHighRegPressure, 0, "Set the loop unroll threshold for shaders with high reg pressure. Value 0 will use the default threshold.", false)
120+
DECLARE_IGC_REGKEY(DWORD,SetRegisterPressureThresholdForLoopUnroll, 64, "Set the register pressure threshold for limiting the loop unroll to smaller loops", false)
119121
DECLARE_IGC_REGKEY(DWORD,SetBranchSwapThreshold, 400, "Set the branch swaping threshold.", false)
120122
DECLARE_IGC_REGKEY(debugString, LLVMCommandLine, 0, "applies LLVM command line", false)
121123
DECLARE_IGC_REGKEY(bool, DisableDX9LowPrecision, true, "Disables HF in DX9.", false)

0 commit comments

Comments
 (0)