Skip to content

Commit e6cdaac

Browse files
Anton Sidorenkoigcbot
authored andcommitted
Tighten legalization rules for EU fusion platforms
If the module contains stack calls and target has fused EUs, legalization width must be less or equal 16.
1 parent b84e4d0 commit e6cdaac

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXLegalization.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ SPDX-License-Identifier: MIT
236236
using namespace llvm;
237237
using namespace genx;
238238

239+
static cl::opt<bool> UseUpper16Lanes("vc-use-upper16-lanes", cl::init(true),
240+
cl::Hidden,
241+
cl::desc("Limit legalization width"));
242+
239243
namespace {
240244

241245
// Information on a part of a predicate.
@@ -355,6 +359,9 @@ class GenXLegalization : public FunctionPass {
355359
// Illegally sized predicate values that need splitting at the end of
356360
// processing the function.
357361
SetVector<Instruction *> IllegalPredicates;
362+
// Whether the function's module has stack calls or not. Used for making
363+
// legalization decisions.
364+
bool HasStackCalls = false;
358365

359366
public:
360367
static char ID;
@@ -538,6 +545,12 @@ bool GenXLegalization::runOnFunction(Function &F) {
538545
.getTM<GenXTargetMachine>()
539546
.getGenXSubtarget();
540547
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
548+
// FIXME: Non-optimal solution. FGs info or some stackcalls-related analysis
549+
// will be useful here.
550+
HasStackCalls =
551+
llvm::any_of(F.getParent()->functions(), [](const Function &MF) {
552+
return genx::requiresStackCall(MF);
553+
});
541554
// Check args for illegal predicates.
542555
for (Function::arg_iterator fi = F.arg_begin(), fe = F.arg_end(); fi != fe;
543556
++fi) {
@@ -1385,6 +1398,15 @@ unsigned GenXLegalization::determineWidth(unsigned WholeWidth,
13851398
unsigned ExecSizeAllowedBits = 0x3f;
13861399
if (auto Main = B.getMainInst())
13871400
ExecSizeAllowedBits = getExecSizeAllowedBits(Main->Inst);
1401+
if (!UseUpper16Lanes || (HasStackCalls && ST->hasFusedEU()))
1402+
// Actually, we should legalize with these more strict requirements only FGs
1403+
// of indirectly called functions. But there are two design issues that make
1404+
// us legalize everything if the module has a stack call:
1405+
// * jmpi to goto transformation is appied in VISA and it transforms more
1406+
// than necessary
1407+
// * this legalization pass does not have access to FGs
1408+
ExecSizeAllowedBits &= 0x1f;
1409+
13881410
unsigned MainInstMinWidth =
13891411
1 << countTrailingZeros(ExecSizeAllowedBits, ZB_Undefined);
13901412
// Determine the vector width that we need to split into.

0 commit comments

Comments
 (0)