Skip to content

Commit

Permalink
Changes in code.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcheng0127 authored and igcbot committed Feb 25, 2025
1 parent 34c8a74 commit b15c849
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions visa/HWCaps.inc
Original file line number Diff line number Diff line change
Expand Up @@ -936,4 +936,10 @@ bool useDynamicAddrForExDesc() const {
return getOption(vISA_dynamicAddrForExDescInLscSend);
}


bool src1Src2SwapForCompaction()
{
return false;
}

// end HW capabilities
5 changes: 5 additions & 0 deletions visa/Optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,9 @@ void Optimizer::initOptimizations() {
TimerID::NUM_TIMERS);
OPT_INITIALIZE_PASS(insertDummyCompactInst, vISA_InsertDummyCompactInst,
TimerID::NUM_TIMERS);
OPT_INITIALIZE_PASS(swapSrc1Src2OfMadForCompaction,
vISA_SwapSrc1Src2OfMadForCompaction,
TimerID::NUM_TIMERS);
OPT_INITIALIZE_PASS(mergeScalarInst, vISA_MergeScalar, TimerID::OPTIMIZER);
OPT_INITIALIZE_PASS(lowerMadSequence, vISA_EnableMACOpt, TimerID::OPTIMIZER);
OPT_INITIALIZE_PASS(LVN, vISA_LVN, TimerID::OPTIMIZER);
Expand Down Expand Up @@ -1056,6 +1059,8 @@ int Optimizer::optimization() {
// Insert a dummy compact instruction if requested for SKL+
runPass(PI_insertDummyCompactInst);

runPass(PI_swapSrc1Src2OfMadForCompaction);

runPass(PI_mapOrphans);

runPass(PI_analyzeMove);
Expand Down
2 changes: 2 additions & 0 deletions visa/Optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class Optimizer {
void insertDummyMovForHWRSWA();
void insertHashMovs();
void insertDummyCompactInst();
void swapSrc1Src2OfMadForCompaction();
void removeLifetimeOps();
void recomputeBound(std::unordered_set<G4_Declare *> &declares);

Expand Down Expand Up @@ -376,6 +377,7 @@ class Optimizer {
PI_HWDebug,
PI_insertDummyMovForHWRSWA,
PI_insertDummyCompactInst,
PI_swapSrc1Src2OfMadForCompaction,
PI_mergeScalarInst,
PI_lowerMadSequence,
PI_LVN,
Expand Down
32 changes: 32 additions & 0 deletions visa/SWWA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,38 @@ void Optimizer::insertDummyCompactInst() {
bb->push_back(movInst);
}

void Optimizer::swapSrc1Src2OfMadForCompaction() {
if (!builder.src1Src2SwapForCompaction())
return;

BB_LIST_ITER ib, bend(fg.end());
for (ib = fg.begin(); ib != bend; ++ib) {
G4_BB *bb = (*ib);
INST_LIST_ITER ii = bb->begin();

while (ii != bb->end()) {
G4_INST *inst = *ii;
if (inst->opcode() == G4_mad) {
G4_Operand *src1 = inst->getSrc(1);
G4_Operand *src2 = inst->getSrc(2);
if (src1 && src2 && src1->getType() == src2->getType() &&
src1->isSrcRegRegion() &&
src2->isSrcRegRegion() &&
src1->getBase()->isRegVar() && src2->getBase()->isRegVar() &&
src1->getTopDcl()->getRegFile() == G4_GRF &&
src2->getTopDcl()->getRegFile() == G4_GRF) {
if (src1->asSrcRegRegion()->getRegion()->isScalar() &&
src2->asSrcRegRegion()->getRegion()->isFlatRegion()) {
inst->setSrc(src2, 1);
inst->setSrc(src1, 2);
}
}
}
ii++;
}
}
}

// add (1|M0) null<1>:uw null<0;1,0>:uw 0x0:uw
void Optimizer::insertDummyAdd(G4_BB *bb, INST_LIST_ITER inst_it, int imm) {
// Dst
Expand Down
2 changes: 2 additions & 0 deletions visa/include/VISAOptionsDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ DEF_VISA_OPTION(vISA_InsertDummyMovForDPASRSWA, ET_BOOL,
"-insertDPASRSDummyMov", UNUSED, true)
DEF_VISA_OPTION(vISA_InsertDummyCompactInst, ET_BOOL, "-insertDummyCompactInst",
UNUSED, false)
DEF_VISA_OPTION(vISA_SwapSrc1Src2OfMadForCompaction, ET_BOOL, "-disableSwapSrc1Src2OfMadForCompaction",
UNUSED, true)
DEF_VISA_OPTION(vISA_AsmFileNameOverridden, ET_BOOL, NULLSTR, UNUSED, false)
DEF_VISA_OPTION(vISA_HashVal, ET_2xINT32, "-hashmovs",
"USAGE: -hashmovs hi32 lo32\n", 0)
Expand Down

0 comments on commit b15c849

Please sign in to comment.