Skip to content

Commit 18b9fd4

Browse files
fftzenggfxbot
authored andcommitted
Add control for branch swapping pass
Change-Id: I60ab20d834dac627186d3db8e12def82b3e0e55e
1 parent 9daad5e commit 18b9fd4

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

IGC/Compiler/CISACodeGen/DriverInfo.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ class CDriverInfo
8686

8787
/// We can safely ignore Nan
8888
virtual bool IgnoreNan() const { return false; }
89-
89+
90+
// Allow branch swapping for better Nan perf
91+
virtual bool BranchSwapping() const { return false; }
92+
9093
/// Allow propagation up-converstion of half if it can generate better code
9194
virtual bool AllowUnsafeHalf() const { return true; }
9295

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ inline void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager& mpm)
565565
mpm.add(new BreakConstantExpr());
566566
mpm.add(new Legalization(preserveNan));
567567

568-
if (IGC_IS_FLAG_DISABLED(DisableBranchSwaping))
568+
if (IGC_IS_FLAG_DISABLED(DisableBranchSwaping) && ctx.m_DriverInfo.BranchSwapping())
569569
{
570570
mpm.add(createNanHandlingPass());
571571
}

IGC/common/igc_flags.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ DECLARE_IGC_REGKEY(bool, DisableMatchPow, false, "Setting this to
8888
DECLARE_IGC_REGKEY(bool, DisableIRVerification, false, "Setting this to 1/true adds a compiler switch to disable IGC IR verification.")
8989
DECLARE_IGC_REGKEY(bool, DisableLoopUnroll, false, "Setting this to 1/true adds a compiler switch to disable loop unrolling.")
9090
DECLARE_IGC_REGKEY(bool, DisableRuntimeLoopUnrolling, false, "Setting this to 1/true adds a compiler switch to disable runtime loop unrolling.")
91-
DECLARE_IGC_REGKEY(bool, DisableBranchSwaping, true, "Setting this to 1/true adds a compiler switch to disable branch NAN swapping.")
91+
DECLARE_IGC_REGKEY(bool, DisableBranchSwaping, false, "Setting this to 1/true adds a compiler switch to disable branch NAN swapping.")
9292
DECLARE_IGC_REGKEY(DWORD,SetLoopUnrollThreshold, 0, "Set the loop unroll threshold. Value 0 will use the default threshold.")
9393
DECLARE_IGC_REGKEY(DWORD,SetBranchSwapThreshold, 100, "Set the branch swaping threshold.")
9494
DECLARE_IGC_REGKEY(debugString, LLVMCommandLine, 0, "applies LLVM command line")

0 commit comments

Comments
 (0)