Skip to content

Commit

Permalink
Add a key to control llvm jumpThreading pass
Browse files Browse the repository at this point in the history
JumpThreading pass isn't good for GPU in general as GPU favors
early convergence, where jump threading may dumplicate BBs and
results in more branching code.

Here, add a key to control jumpThreading pass, so that we can
turn it off to see how it goes.
  • Loading branch information
jgu222 authored and igcbot committed Sep 27, 2023
1 parent 21e69c0 commit 590e569
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,8 @@ void OptimizeIR(CodeGenContext* const pContext)
}
GFX_ONLY_PASS { mpm.add(new GenUpdateCB()); }

if (!pContext->m_instrTypes.hasAtomics && !extensiveShader(pContext))
if (IGC_IS_FLAG_ENABLED(EnableJumpThreading) &&
!pContext->m_instrTypes.hasAtomics && !extensiveShader(pContext))
{
if (pContext->type == ShaderType::OPENCL_SHADER)
{
Expand Down Expand Up @@ -1597,7 +1598,8 @@ void OptimizeIR(CodeGenContext* const pContext)

// Conditions apply just as above due to problems with atomics
// (see comment above for details).
if (!pContext->m_instrTypes.hasAtomics && !extensiveShader(pContext))
if (IGC_IS_FLAG_ENABLED(EnableJumpThreading) &&
!pContext->m_instrTypes.hasAtomics && !extensiveShader(pContext))
{
// After lowering 'switch', run jump threading to remove redundant jumps.
mpm.add(llvm::createJumpThreadingPass());
Expand Down
1 change: 1 addition & 0 deletions IGC/common/igc_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ DECLARE_IGC_REGKEY(bool, DisableMatchPredAdd, false, "Setting this to
DECLARE_IGC_REGKEY(bool, DisableMatchSimpleAdd, false, "Setting this to 1/true adds a compiler switch to disable simple cmp+and+add optimization", false)
DECLARE_IGC_REGKEY(bool, DisableMatchPow, false, "Setting this to 1/true adds a compiler switch to disable log2/mul/exp2 = pow optimization", false)
DECLARE_IGC_REGKEY(bool, DisableIRVerification, false, "Setting this to 1/true adds a compiler switch to disable IGC IR verification.", false)
DECLARE_IGC_REGKEY(bool, EnableJumpThreading, true, "Setting this to 1/true adds a compiler switch to enable llvm jumpThreading pass.", true)
DECLARE_IGC_REGKEY(bool, DisableLoopUnroll, false, "Setting this to 1/true adds a compiler switch to disable loop unrolling.", true)
DECLARE_IGC_REGKEY(DWORD, RuntimeLoopUnrolling, 0, "Setting this to switch on/off runtime loop unrolling. 0: default (on), 1: force on, 2: force off", false)
DECLARE_IGC_REGKEY(bool, DisableBranchSwaping, false, "Setting this to 1/true adds a compiler switch to disable branch swapping.", false)
Expand Down

0 comments on commit 590e569

Please sign in to comment.