Skip to content

Commit 06026fd

Browse files
bcheng0127sys_zuul
authored andcommitted
group instructions together for performance
Change-Id: I94b286e910729d4cdc33880f3c4e71849a117886
1 parent 0176c6d commit 06026fd

File tree

4 files changed

+77
-7
lines changed

4 files changed

+77
-7
lines changed

visa/Gen4_IR.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8201,3 +8201,34 @@ G4_INST* G4_InstMath::cloneInst()
82018201
src0, src1, getMathCtrl(), option, getLineNo(), getCISAOff(), getSrcFilename());
82028202
}
82038203

8204+
8205+
bool G4_INST::isRMWCombinCandidate(G4_INST *next)
8206+
{
8207+
if (isSend() || next->isSend())
8208+
{
8209+
return false;
8210+
}
8211+
8212+
G4_Operand* dst = getDst();
8213+
G4_Operand* nextDst = next->getDst();
8214+
//The current instruction must has Integer macro dst as well
8215+
if (nextDst &&
8216+
nextDst->isGen12IntegerMacroDst() &&
8217+
dst->getType() == nextDst->getType())
8218+
{
8219+
8220+
unsigned short lastLB = (unsigned short)dst->getLinearizedStart();
8221+
unsigned short lastRB = (unsigned short)dst->getLinearizedEnd();
8222+
unsigned short nextLB = (unsigned short)nextDst->getLinearizedStart();
8223+
unsigned short nextRB = (unsigned short)nextDst->getLinearizedEnd();
8224+
8225+
if (lastLB / G4_GRF_REG_NBYTES == nextLB / G4_GRF_REG_NBYTES &&
8226+
lastRB / G4_GRF_REG_NBYTES == nextRB / G4_GRF_REG_NBYTES &&
8227+
(lastLB > nextRB || nextLB > lastRB))
8228+
{
8229+
return true;
8230+
}
8231+
}
8232+
8233+
return false;
8234+
}

visa/Gen4_IR.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,7 @@ class G4_INST
957957
}
958958

959959
bool mayExpandToAccMacro() const;
960+
bool isRMWCombinCandidate(G4_INST* next);
960961

961962
Gen4_Operand_Number getSrcOperandNum(int srcPos) const
962963
{
@@ -2326,6 +2327,25 @@ class G4_Operand
23262327
return type;
23272328
}
23282329
}
2330+
bool isGen12IntegerMacroDst()
2331+
{
2332+
if (isNullReg())
2333+
{
2334+
return false;
2335+
}
2336+
2337+
if (type == Type_UW ||
2338+
type == Type_W ||
2339+
type == Type_B ||
2340+
type == Type_UB ||
2341+
type == Type_D ||
2342+
type == Type_UD)
2343+
{
2344+
return true;
2345+
}
2346+
2347+
return false;
2348+
}
23292349
};
23302350

23312351
class G4_VarBase

visa/LocalScheduler/SWSB_G4IR.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4199,12 +4199,18 @@ void G4_BB_SB::getGRFFootprintForIndirect(SBNode* node,
41994199
void G4_BB_SB::getGRFBuckets(SBNode* node,
42004200
SBFootprint* footprint,
42014201
Gen4_Operand_Number opndNum,
4202-
std::vector<SBBucketDescr>& BDvec)
4202+
std::vector<SBBucketDescr>& BDvec,
4203+
bool GRFOnly)
42034204
{
42044205
SBFootprint* curFootprint = footprint;
42054206

42064207
while (curFootprint != nullptr)
42074208
{
4209+
if (GRFOnly && (curFootprint->fType != GRF_T))
4210+
{
4211+
continue;
4212+
}
4213+
42084214
int aregOffset = totalGRFNum;
42094215
int startingBucket = curFootprint->LeftB / G4_GRF_REG_NBYTES;
42104216
int endingBucket = curFootprint->RightB / G4_GRF_REG_NBYTES;
@@ -4273,7 +4279,7 @@ void G4_BB_SB::getGRFBucketsForOperands(SBNode* node,
42734279
{
42744280
continue;
42754281
}
4276-
getGRFBuckets(node, footprint, opndNum, BDvec);
4282+
getGRFBuckets(node, footprint, opndNum, BDvec, GRFOnly);
42774283
}
42784284

42794285
return;
@@ -4451,7 +4457,6 @@ void G4_BB_SB::SBDDD(G4_BB* bb,
44514457
getGRFBucketDescrs(node, liveBDvec, false);
44524458
}
44534459

4454-
44554460
// For ALU instructions without GRF usage
44564461
if (distanceHonourInstruction(curInst))
44574462
{

visa/LocalScheduler/SWSB_G4IR.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,23 @@ namespace vISA
136136

137137
void setOffset(unsigned short o) { offset = o; }
138138

139+
bool hasOverlap(SBFootprint* liveFootprint) const
140+
{
141+
SBFootprint* curFootprint2Ptr = liveFootprint;
142+
while (curFootprint2Ptr)
143+
{
144+
// Negative of no overlap: !(LeftB > curFootprint2Ptr->RightB || RightB < curFootprint2Ptr->LeftB)
145+
if (fType == curFootprint2Ptr->fType &&
146+
LeftB <= curFootprint2Ptr->RightB && RightB >= curFootprint2Ptr->LeftB)
147+
{
148+
return true;
149+
}
150+
curFootprint2Ptr = curFootprint2Ptr->next;
151+
}
152+
153+
return false;
154+
}
155+
139156
bool hasOverlap(SBFootprint *liveFootprint, unsigned short &internalOffset) const
140157
{
141158
SBFootprint *curFootprint2Ptr = liveFootprint;
@@ -984,14 +1001,11 @@ namespace vISA
9841001
SBFootprint* getFootprintForFlag(G4_Operand* opnd,
9851002
Gen4_Operand_Number opnd_num,
9861003
G4_INST* inst);
987-
void getGRFBuckets(SBNode *node,
988-
SBFootprint* footprint,
989-
Gen4_Operand_Number opndNum,
990-
std::vector<SBBucketDescr>& BDvec);
9911004
bool getFootprintForOperand(SBNode *node,
9921005
G4_INST *inst,
9931006
G4_Operand* opnd,
9941007
Gen4_Operand_Number opnd_num);
1008+
void getGRFBuckets(SBNode* node, SBFootprint* footprint, Gen4_Operand_Number opndNum, std::vector<SBBucketDescr>& BDvec, bool GRFOnly);
9951009
bool getGRFFootPrintOperands(SBNode *node,
9961010
G4_INST *inst,
9971011
Gen4_Operand_Number first_opnd,

0 commit comments

Comments
 (0)