Skip to content

Commit 36bee5f

Browse files
skachkov-inteligcbot
authored andcommitted
Add option for disabling extra coalescing in VC backend
Add option that disables coalescing of instruction destination live range with some of its sources (this prevents creation of big live ranges and may decrease register pressure)
1 parent d8aa6e0 commit 36bee5f

File tree

7 files changed

+20
-1
lines changed

7 files changed

+20
-1
lines changed

IGC/VectorCompiler/igcdeps/src/TranslationInterface.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ template <typename T> T deriveDefaultableFlagValue(int Flag) {
209209
static void adjustTransformationsAndOptimizations(vc::CompileOptions &Opts) {
210210
if (IGC_IS_FLAG_ENABLED(VCLocalizeAccUsage))
211211
Opts.ForceLiveRangesLocalizationForAccUsage = true;
212+
if (IGC_IS_FLAG_ENABLED(VCDisableExtraCoalescing))
213+
Opts.ForceDisableExtraCoalescing = true;
212214
if (IGC_IS_FLAG_ENABLED(VCDisableNonOverlappingRegionOpt))
213215
Opts.ForceDisableNonOverlappingRegionOpt = true;
214216
if (IGC_IS_FLAG_ENABLED(VCSaveStackCallLinkage))

IGC/VectorCompiler/include/vc/Driver/Driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct CompileOptions {
8787

8888
llvm::Optional<unsigned> StackMemSize;
8989
bool ForceLiveRangesLocalizationForAccUsage = false;
90+
bool ForceDisableExtraCoalescing = false;
9091
bool ForceDisableNonOverlappingRegionOpt = false;
9192
bool IsLargeGRFMode = false;
9293
DisableLRCoalescingControl DisableLRCoalescingMode =

IGC/VectorCompiler/include/vc/Support/BackendConfig.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ struct GenXBackendOptions {
8989
// Disable LR coalescing
9090
bool DisableLiveRangesCoalescing = false;
9191

92+
// Disable extra coalescing
93+
bool DisableExtraCoalescing = false;
94+
9295
// Disable non-overlapping region transformation (the case with undef
9396
// value in two-address operand)
9497
bool DisableNonOverlappingRegionOpt;
@@ -240,6 +243,10 @@ class GenXBackendConfig : public ImmutablePass {
240243
return Options.DisableLiveRangesCoalescing;
241244
}
242245

246+
bool disableExtraCoalescing() const {
247+
return Options.DisableExtraCoalescing;
248+
}
249+
243250
bool disableNonOverlappingRegionOpt() const {
244251
return Options.DisableNonOverlappingRegionOpt;
245252
}

IGC/VectorCompiler/lib/Driver/Driver.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ static GenXBackendOptions createBackendOptions(const vc::CompileOptions &Opts) {
247247
BackendOpts.ForceArrayPromotion = (Opts.Binary == vc::BinaryKind::CM);
248248
if (Opts.ForceLiveRangesLocalizationForAccUsage)
249249
BackendOpts.LocalizeLRsForAccUsage = true;
250+
if (Opts.ForceDisableExtraCoalescing)
251+
BackendOpts.DisableExtraCoalescing = true;
250252
if (Opts.ForceDisableNonOverlappingRegionOpt)
251253
BackendOpts.DisableNonOverlappingRegionOpt = true;
252254
BackendOpts.FCtrl = Opts.FCtrl;

IGC/VectorCompiler/lib/GenXCodeGen/GenXVisaRegAlloc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ bool GenXVisaRegAlloc::runOnFunctionGroup(FunctionGroup &FGArg)
145145
CurrentRegId[vc::RegCategory::Predicate] = VISA_NUM_RESERVED_PREDICATES;
146146
CurrentRegId[vc::RegCategory::Surface] = VISA_NUM_RESERVED_SURFACES;
147147
// Do some extra coalescing.
148-
extraCoalescing();
148+
if (!BackendConfig->disableExtraCoalescing())
149+
extraCoalescing();
149150
// Get the live ranges in a reproducible order.
150151
std::vector<LiveRange *> LRs;
151152
getLiveRanges(LRs);

IGC/VectorCompiler/lib/Support/BackendConfig.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ static cl::opt<bool>
8383
DisableLRCoalescingOpt("vc-disable-coalescing", cl::init(false), cl::Hidden,
8484
cl::desc("disable coalescing of live ranges"));
8585

86+
static cl::opt<bool>
87+
DisableExtraCoalescingOpt("vc-disable-extra-coalescing", cl::init(false), cl::Hidden,
88+
cl::desc("disable extrac coalescing"));
89+
8690
static cl::opt<bool> DisableNonOverlappingRegionOptOpt(
8791
"vc-disable-non-overlapping-region-opt", cl::init(false), cl::Hidden,
8892
cl::desc("Disable non-overlapping region optimization"));
@@ -146,6 +150,7 @@ GenXBackendOptions::GenXBackendOptions()
146150
UseNewStackBuilder(UseNewStackBuilderOpt),
147151
LocalizeLRsForAccUsage(LocalizeLRsForAccUsageOpt),
148152
DisableLiveRangesCoalescing(DisableLRCoalescingOpt),
153+
DisableExtraCoalescing(DisableLRCoalescingOpt),
149154
DisableNonOverlappingRegionOpt(DisableNonOverlappingRegionOptOpt),
150155
FCtrl(FunctionControlOpt), IsLargeGRFMode(LargeGRFModeOpt),
151156
UseBindlessBuffers(UseBindlessBuffersOpt),

IGC/common/igc_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ DECLARE_IGC_GROUP("VectorCompiler Options")
579579
DECLARE_IGC_REGKEY(debugString, VCApiOptions, 0, "Extra API options for VC", true)
580580
DECLARE_IGC_REGKEY(debugString, VCInternalOptions, 0, "Extra Internal options to pass to VC", true)
581581
DECLARE_IGC_REGKEY(bool, VCLocalizeAccUsage, false, "Localization of possible accumulator usages for vISA RA", true)
582+
DECLARE_IGC_REGKEY(bool, VCDisableExtraCoalescing, false, "Disable extra coalescing", true)
582583
DECLARE_IGC_REGKEY(bool, VCDisableNonOverlappingRegionOpt, false, "Disable non-overlapping region optimization", true)
583584
DECLARE_IGC_REGKEY(bool, VCEnableExtraDebugLogging, false, "Turns on extra debug output to trace IGC/VC-specific execution", true)
584585
DECLARE_IGC_REGKEY(DWORD, VCNoOptFinalizerControl, 0, "Controls if finalizer is invoked with -debug flag", true)

0 commit comments

Comments
 (0)