Skip to content

Commit 95c834d

Browse files
pkwasnie-inteligcbot
authored andcommitted
Run GEP Loop Strength Reduction pass after LICM with optional
IGC flag 1) Adds new flag RunGEPLSRAfterLICM to run GEP LSR pass after first LICM pass (default=false). 2) Makes all GEP LSR's flags available in release build.
1 parent 1076f30 commit 95c834d

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,17 +1473,19 @@ void OptimizeIR(CodeGenContext* const pContext)
14731473
mpm.add(llvm::createLCSSAPass());
14741474
mpm.add(llvm::createLoopSimplifyPass());
14751475

1476-
if (IGC_IS_FLAG_ENABLED(EnableGEPLSR) &&
1476+
bool allowLICM = IGC_IS_FLAG_ENABLED(allowLICM) && pContext->m_retryManager.AllowLICM();
1477+
bool runGEPLSR = IGC_IS_FLAG_ENABLED(EnableGEPLSR) &&
14771478
pContext->type == ShaderType::OPENCL_SHADER &&
14781479
pContext->platform.getPlatformInfo().eProductFamily == IGFX_PVC &&
14791480
!useStatelessToStateful(*pContext) &&
1480-
pContext->m_retryManager.IsFirstTry())
1481+
pContext->m_retryManager.IsFirstTry();
1482+
1483+
if (runGEPLSR && IGC_IS_FLAG_DISABLED(RunGEPLSRAfterLICM))
14811484
{
1482-
mpm.add(createGEPLoopStrengthReductionPass(IGC_IS_FLAG_ENABLED(allowLICM) &&
1483-
pContext->m_retryManager.AllowLICM()));
1485+
mpm.add(createGEPLoopStrengthReductionPass(allowLICM));
14841486
}
14851487

1486-
if (IGC_IS_FLAG_ENABLED(allowLICM) && pContext->m_retryManager.AllowLICM())
1488+
if (allowLICM)
14871489
{
14881490
mpm.add(createSpecialCasesDisableLICM());
14891491
int licmTh = IGC_GET_FLAG_VALUE(LICMStatThreshold);
@@ -1496,6 +1498,11 @@ void OptimizeIR(CodeGenContext* const pContext)
14961498
mpm.add(new InstrStatistic(pContext, LICM_STAT, InstrStatStage::END, licmTh));
14971499
}
14981500

1501+
if (runGEPLSR && IGC_IS_FLAG_ENABLED(RunGEPLSRAfterLICM))
1502+
{
1503+
mpm.add(createGEPLoopStrengthReductionPass(allowLICM));
1504+
}
1505+
14991506

15001507
if (!pContext->m_retryManager.IsFirstTry())
15011508
{
@@ -1546,7 +1553,7 @@ void OptimizeIR(CodeGenContext* const pContext)
15461553
// LoopUnroll and LICM.
15471554
mpm.add(createBarrierNoopPass());
15481555

1549-
if (IGC_IS_FLAG_ENABLED(allowLICM) && pContext->m_retryManager.AllowLICM())
1556+
if (allowLICM)
15501557
{
15511558
mpm.add(createSpecialCasesDisableLICM());
15521559
#if LLVM_VERSION_MAJOR >= 14

IGC/common/igc_flags.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,10 @@ DECLARE_IGC_REGKEY(bool, ForceHoistDp3, false, "force dp3 Hoistin
288288
DECLARE_IGC_REGKEY(bool, EnableBitcastedLoadNarrowing, false, "Enable narrowing of vector loads in bitcasts patterns.", false)
289289
DECLARE_IGC_REGKEY(bool, EnableBitcastedLoadNarrowingToScalar, false, "Enable narrowing of vector loads to scalar ones in bitcasts patterns.", false)
290290
DECLARE_IGC_REGKEY(bool, EnableOptReportLoadNarrowing, false, "Generate opt report for narrowing of vector loads.", false)
291-
DECLARE_IGC_REGKEY(bool, EnableGEPLSR, true, "Enables GEP Loop Strength Reduction pass", false)
292-
DECLARE_IGC_REGKEY(DWORD, GEPLSRThresholdRatio, 100, "Ratio for register pressure threshold in GEP Loop Strength Reduction pass", false)
293-
DECLARE_IGC_REGKEY(bool, EnableGEPLSRToPreheader, true, "Enables reduction to loop's preheader in GEP Loop Strength Reduction pass", false)
291+
DECLARE_IGC_REGKEY(bool, EnableGEPLSR, true, "Enables GEP Loop Strength Reduction pass", true)
292+
DECLARE_IGC_REGKEY(bool, RunGEPLSRAfterLICM, false, "Runs GEP Loop Strength Reduction pass after first LICM", true)
293+
DECLARE_IGC_REGKEY(DWORD, GEPLSRThresholdRatio, 100, "Ratio for register pressure threshold in GEP Loop Strength Reduction pass", true)
294+
DECLARE_IGC_REGKEY(bool, EnableGEPLSRToPreheader, true, "Enables reduction to loop's preheader in GEP Loop Strength Reduction pass", true)
294295
DECLARE_IGC_REGKEY(bool, EnableGEPLSRAnyIntBitWidth, false, "Experimental: Enables reduction of SCEV with illegal integers. Requires legalization pass to clear up expanded code.", true)
295296
DECLARE_IGC_REGKEY(DWORD, FPRoundingModeCoalescingMaxDistance, 20, "Max distance in instructions for reordering FP instructions with common rounding mode", false)
296297
DECLARE_IGC_REGKEY(bool, DisableDotAddToDp4aMerge, false, "Disable Dot and Add ops to Dp4a merge optimization.", false)

0 commit comments

Comments
 (0)