Skip to content

Commit a37e95b

Browse files
admitricigcbot
authored andcommitted
Add option to disable scalarization of phi nodes
Add option DisablePHIScalarization to skip phi nodes scalarization in ScalarizeFunction pass
1 parent 92166ca commit a37e95b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

IGC/Compiler/Optimizer/Scalarizer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,10 @@ void ScalarizeFunction::dispatchInstructionToScalarize(Instruction* I)
383383
scalarizeInstruction(dyn_cast<CastInst>(I));
384384
break;
385385
case Instruction::PHI:
386-
scalarizeInstruction(dyn_cast<PHINode>(I));
386+
if (IGC_IS_FLAG_DISABLED(DisablePHIScalarization))
387+
scalarizeInstruction(dyn_cast<PHINode>(I));
388+
else
389+
recoverNonScalarizableInst(I);
387390
break;
388391
case Instruction::Select:
389392
scalarizeInstruction(dyn_cast<SelectInst>(I));

IGC/common/igc_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ DECLARE_IGC_REGKEY(bool, DisableScalarAtomics, false, "Disable the Scal
489489
DECLARE_IGC_REGKEY(bool, EnableScalarTypedAtomics, true, "Enable the Scalar Typed Atomics optimization", false)
490490
DECLARE_IGC_REGKEY(bool, EnableVectorizer, true, "Enable IGCVectorizer pass", false)
491491
DECLARE_IGC_REGKEY(bool, DisableOCLScalarizer, false, "Disable ScalarizeFunction pass in OCL pipeline", true)
492+
DECLARE_IGC_REGKEY(bool, DisablePHIScalarization, false, "Disable scalarization of PHINode instructions", true)
492493
DECLARE_IGC_REGKEY(bool, EnableSelectiveScalarizer, false, "enable selective scalarizer on GPGPU path", true)
493494
DECLARE_IGC_REGKEY(bool, HoistPSConstBufferValues, true, "Hoists up down converts for contant buffer accesses, so they an be vectorized more easily.", false)
494495
DECLARE_IGC_REGKEY(bool, EnableSingleVertexDispatch, false, "Vertex Shader Single Patch Dispatch Regkey", false)

IGC/ocloc_tests/Options/disable_scalarize_option.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010

1111
; RUN: llvm-as %s -o %t.bc
1212
; RUN: ocloc compile -llvm_input -file %t.bc -device pvc -options " -ze-opt-large-register-file -igc_opts 'DisableOCLScalarizer=1,EnableVectorizer=0,PrintToConsole=1,PrintAfter=EmitPass'" 2>&1 | FileCheck %s --check-prefixes=CHECK
13+
; RUN: ocloc compile -llvm_input -file %t.bc -device pvc -options " -ze-opt-large-register-file -igc_opts 'DisablePHIScalarization=1,EnableVectorizer=0,PrintToConsole=1,PrintAfter=EmitPass'" 2>&1 | FileCheck %s --check-prefixes=CHECK
1314

14-
; Check that scalarizer is disabled when DisableOCLScalarizer=1 is passed to IGC
15+
; Check that phi is not scalarized when DisableOCLScalarizer=1 or DisablePHIScalarization=1 is passed to IGC
1516
; Disabling vectorizer as well in order to check that scalarizer is disabled and not vectorizer transformed the code
1617

1718
; CHECK-LABEL: @foo(
18-
; CHECK: [[VEC_PHI:%.*]] = phi <8 x [[TYPE:[A-Za-z0-9]+]]> [ zeroinitializer, [[BB1:%.*]] ], [ [[V:%.*]], [[BB2:%.*]] ]
19-
; CHECK-NOT: [[SCALAR_FLOAT_PHI:%.*]] = phi float [ [[ZERO:.*]], [[BB1:%.*]] ], [ [[TMP:%.*]], [[BB2:%.*]] ]
19+
; CHECK: [[VEC_PHI:%.*]] = phi <8 x [[TYPE:[A-Za-z0-9]+]]>
20+
; CHECK-NOT: [[SCALAR_FLOAT_PHI:%.*]] = phi float
2021
; CHECK: ret void
2122

2223

0 commit comments

Comments
 (0)