Skip to content

Commit 1f09f26

Browse files
traoux1gfxbot
authored andcommitted
Tweak the optimization order and move instruction combining
after the CFG optimizations Change-Id: Iad5893d8f28fccd7f092fc83cadde90ad2bf5731
1 parent 225bd22 commit 1f09f26

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,6 @@ inline void AddLegalizationPasses(CodeGenContext &ctx, const CShaderProgram::Ker
390390
mpm.add(llvm::createLoopSimplifyPass());
391391
}
392392

393-
if (isOptDisabled)
394-
{
395-
// Since we don't support switch statements, switch lowering is needed.
396-
// But when optimizations are disabled, the pass doesn't run as a part of OptimizeIR.
397-
mpm.add(llvm::createLowerSwitchPass());
398-
}
399393

400394
// Lower/Resolve OCL inlined constants.
401395
if (ctx.m_DriverInfo.NeedLoweringInlinedConstants()) {
@@ -497,10 +491,9 @@ inline void AddLegalizationPasses(CodeGenContext &ctx, const CShaderProgram::Ker
497491
mpm.add(createConstantPropagationPass());
498492
mpm.add(createDeadCodeEliminationPass());
499493
mpm.add(createCFGSimplificationPass());
500-
//CFG simplification can create switch statement we don't support
501-
mpm.add(createLowerSwitchPass());
502-
503-
}
494+
}
495+
// Since we don't support switch statements, switch lowering is needed after the last CFG simplication
496+
mpm.add(llvm::createLowerSwitchPass());
504497

505498
// Split big vector & 3-element load/store, etc.
506499
mpm.add(createVectorPreProcessPass());
@@ -1227,7 +1220,6 @@ void OptimizeIR(CodeGenContext* pContext)
12271220
{
12281221
mpm.add(createSROAPass());
12291222
}
1230-
mpm.add(llvm::createInstructionCombiningPass());
12311223
}
12321224

12331225
if (pContext->m_shaderHasLoadStore)
@@ -1291,7 +1283,11 @@ void OptimizeIR(CodeGenContext* pContext)
12911283
mpm.add(llvm::createLowerSwitchPass());
12921284
// After lowering 'switch', run jump threading to remove redundant jumps.
12931285
mpm.add(llvm::createJumpThreadingPass());
1286+
1287+
// run instruction combining to clean up the code after CFG optimizations
1288+
mpm.add(createInstructionCombiningPass());
12941289
mpm.add(llvm::createDeadCodeEliminationPass());
1290+
mpm.add(llvm::createEarlyCSEPass());
12951291

12961292
if(pContext->type == ShaderType::PIXEL_SHADER)
12971293
{

0 commit comments

Comments
 (0)