Skip to content

Commit d85f68d

Browse files
pratikashargfxbot
authored andcommitted
Allow mem2reg when -cl-opt-disable is passed
Change-Id: I763a93e851085be3d8f10f65546a2a9178c79247
1 parent bd548a2 commit d85f68d

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

IGC/Compiler/CISACodeGen/ShaderCodeGen.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,11 @@ inline void AddLegalizationPasses(CodeGenContext &ctx, IGCPassManager& mpm)
449449
}
450450
mpm.add(createPromoteMemoryToRegisterPass());
451451
}
452+
else
453+
{
454+
if(IGC_IS_FLAG_ENABLED(AllowMem2Reg))
455+
mpm.add(createPromoteMemoryToRegisterPass());
456+
}
452457
if(ctx.m_instrTypes.hasLoop)
453458
{
454459
// need to run loop simplify to canonicalize loop and merge latches

IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,14 +1307,13 @@ namespace //Anonymous
13071307

13081308
// Run mem2reg pass to make the processing simpler
13091309
bool isOptDisabled = modMD->compOpt.OptDisable;
1310-
if (!isOptDisabled)
1310+
if (!isOptDisabled || IGC_IS_FLAG_ENABLED(AllowMem2Reg))
13111311
{
13121312
legacy::PassManager PM;
13131313
PM.add(createPromoteMemoryToRegisterPass());
13141314
changed = PM.run(M) || changed;
13151315
}
13161316

1317-
13181317
// calls to blocks (not enqueues) are implemented as indirect calls
13191318
// these calls should be resolved now because indirect calls are not
13201319
// supported by other passes

IGC/common/igc_flags.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ DECLARE_IGC_REGKEY(bool, EnableAtomicFusion, false, "To enable/disabl
6161
DECLARE_IGC_REGKEY(bool, Use16ByteBindlessSampler, false, "True if 16-byte aligned bindless sampler state is used")
6262

6363
DECLARE_IGC_GROUP("IGC Optimization")
64+
DECLARE_IGC_REGKEY(bool, AllowMem2Reg, false, "Setting this to true makes IGC run mem2reg even when optimizations are disabled")
6465
DECLARE_IGC_REGKEY(bool, DisableIGCOptimizations, false, "Setting this to 1/true adds a compiler switch to disables all the above IGC optimizations")
6566
DECLARE_IGC_REGKEY(bool, DisableLLVMGenericOptimizations, false, "Disable LLVM generic optimization passes")
6667
DECLARE_IGC_REGKEY(bool, DisableCodeSinking, false, "Setting this to 1/true adds a compiler switch to disable code-sinking")

0 commit comments

Comments
 (0)