@@ -569,7 +569,8 @@ void SBNode::finalizeDistanceType1(IR_Builder &builder,
569569 return ;
570570 }
571571
572- if (builder.hasA0WARHWissue () && (builder.hasThreeALUPipes () || builder.hasFourALUPipes ())) {
572+ if (builder.hasA0WARHWissue () &&
573+ (builder.hasThreeALUPipes () || builder.hasFourALUPipes ())) {
573574 G4_INST *inst = GetInstruction ();
574575
575576 if (inst->getDst () && inst->getDst ()->isDirectA0 ()) {
@@ -712,7 +713,8 @@ void SBNode::finalizeDistanceType2(IR_Builder &builder,
712713 return ;
713714 }
714715
715- if (builder.hasA0WARHWissue () && (builder.hasThreeALUPipes () || builder.hasFourALUPipes ())) {
716+ if (builder.hasA0WARHWissue () &&
717+ (builder.hasThreeALUPipes () || builder.hasFourALUPipes ())) {
716718 G4_INST *inst = GetInstruction ();
717719
718720 if (inst->getDst () && inst->getDst ()->isDirectA0 ()) {
@@ -870,7 +872,8 @@ void SBNode::finalizeDistanceType3(IR_Builder &builder,
870872 return ;
871873 }
872874
873- if (builder.hasA0WARHWissue () && (builder.hasThreeALUPipes () || builder.hasFourALUPipes ())) {
875+ if (builder.hasA0WARHWissue () &&
876+ (builder.hasThreeALUPipes () || builder.hasFourALUPipes ())) {
874877 G4_INST *inst = GetInstruction ();
875878
876879 if (inst->getDst () && inst->getDst ()->isDirectA0 ()) {
@@ -1258,18 +1261,33 @@ SBFootprint *G4_BB_SB::getFootprintForFlag(G4_Operand *opnd,
12581261SBFootprint *G4_BB_SB::getFootprintForA0 (G4_Operand *opnd,
12591262 Gen4_Operand_Number opnd_num,
12601263 G4_INST *inst) {
1264+ bool valid = true ;
1265+ unsigned subRegNum = 0 ;
1266+ if (opnd->isSrcRegRegion ()) {
1267+ G4_SrcRegRegion *srcRegRegion = opnd->asSrcRegRegion ();
1268+ if (srcRegRegion->getRegAccess () == Direct) {
1269+ subRegNum = srcRegRegion->ExSubRegNum (valid);
1270+ } else {
1271+ subRegNum = srcRegRegion->ExIndSubRegNum (valid);
1272+ }
1273+ } else if (opnd->isDstRegRegion ()) {
1274+ G4_DstRegRegion *dstRegRegion = opnd->asDstRegRegion ();
1275+ if (dstRegRegion->getRegAccess () == Direct) {
1276+ subRegNum = dstRegRegion->ExSubRegNum (valid);
1277+ } else {
1278+ subRegNum = dstRegRegion->ExIndSubRegNum (valid);
1279+ }
1280+ } else {
1281+ vISA_ASSERT_UNREACHABLE (" invalid A0 operand" );
1282+ }
1283+
12611284 unsigned short LB = 0 ;
12621285 unsigned short RB = 0 ;
12631286 G4_Type type = opnd->getType ();
1287+ G4_Type addrType = opnd->isIndirect () ? ADDR_REG_TYPE : opnd->getType ();
1288+ LB = subRegNum * TypeSize (addrType);
1289+ RB = opnd->getRightBound () - opnd->getLeftBound () + LB;
12641290
1265- bool valid = true ;
1266- unsigned subRegOff = opnd->getBase ()->ExSubRegNum (valid);
1267- G4_Type addrType = opnd->isIndirect () ? Type_UW : opnd->getType ();
1268-
1269- LB = (unsigned short )(subRegOff * TypeSize (addrType));
1270- RB = (unsigned short )(LB + opnd->getRightBound () - opnd->getLeftBound ());
1271-
1272- // Updated to the bucket footprint
12731291 LB += (builder.kernel .getNumRegTotal () + builder.getNumScalarRegisters ()) *
12741292 builder.numEltPerGRF <Type_UB>();
12751293 RB += (builder.kernel .getNumRegTotal () + builder.getNumScalarRegisters ()) *
@@ -4694,8 +4712,7 @@ void SWSB::insertTokenSync() {
46944712 syncInst->setDistance (1 );
46954713 if (kernel.fg .builder ->hasThreeALUPipes () ||
46964714 kernel.fg .builder ->hasFourALUPipes ()) {
4697- syncInst->setDistanceTypeXe (
4698- G4_INST::DistanceType::DISTALL);
4715+ syncInst->setDistanceTypeXe (G4_INST::DistanceType::DISTALL);
46994716 }
47004717 }
47014718 }
@@ -5729,9 +5746,15 @@ bool G4_BB_SB::getFootprintForOperand(SBNode *node, G4_INST *inst,
57295746 }
57305747 }
57315748
5732- if (builder.needA0WARForSend () && isA0) {
5749+ if (builder.needA0WAR () && isA0) {
57335750 footprint = getFootprintForA0 (opnd, opndNum, inst);
5734- node->setFootprint (footprint, opndNum);
5751+ if (opndNum == Opnd_dst && opnd->asDstRegRegion ()->isIndirect ()) {
5752+ // Indirect will only be used in the src0~src2, using Opnd_src4 as the
5753+ // indirect used in dst
5754+ node->setFootprint (footprint, Opnd_src4);
5755+ } else {
5756+ node->setFootprint (footprint, opndNum);
5757+ }
57355758 }
57365759
57375760 if (isS0Reg) {
@@ -6169,21 +6192,14 @@ void G4_BB_SB::setDistance(const SBFootprint *footprint, SBNode *node,
61696192}
61706193
61716194void G4_BB_SB::setSpecialDistance (SBNode *node) {
6172- G4_INST *inst = node->GetInstruction ();
6173- if (!inst->getDst ()) {
6174- return ;
6175- }
6176-
6177- if (inst->getDst ()->isDirectA0 ()) {
6178- SBDISTDEP_ITEM depItem;
6179- depItem.liveNodePipe = PIPE_FLOAT;
6180- depItem.nodePipe = node->ALUPipe ;
6181- depItem.operandType = PIPE_INT;
6182- depItem.dstDep = false ;
6183- node->setDistance (1 );
6184- node->distDep .push_back (depItem);
6185- node->setDistInfo (PIPE_FLOAT, 1 );
6186- }
6195+ SBDISTDEP_ITEM depItem;
6196+ depItem.liveNodePipe = PIPE_FLOAT;
6197+ depItem.nodePipe = node->ALUPipe ;
6198+ depItem.operandType = PIPE_INT;
6199+ depItem.dstDep = false ;
6200+ node->setDistance (1 );
6201+ node->distDep .push_back (depItem);
6202+ node->setDistInfo (PIPE_FLOAT, 1 );
61876203
61886204 return ;
61896205}
@@ -6675,8 +6691,17 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
66756691
66766692 if (builder.hasA0WARHWissue () &&
66776693 (builder.hasThreeALUPipes () || builder.hasFourALUPipes ())) {
6678- setSpecialDistance (node);
6694+ if (curInst->getDst () && curInst->getDst ()->isDirectA0 ()) {
6695+ setSpecialDistance (node);
6696+ }
6697+ } else if (builder.needA0WAR ()) {
6698+ if (!indexes->setFirstA0 && curInst->getDst () &&
6699+ curInst->getDst ()->isDirectA0 ()) {
6700+ indexes->setFirstA0 = 1 ;
6701+ setSpecialDistance (node);
6702+ }
66796703 }
6704+
66806705 // Record the node IDs of the instructions in BB
66816706 if (first_node == INVALID_ID) {
66826707 first_node = nodeID;
@@ -7085,13 +7110,16 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
70857110 continue ;
70867111 }
70877112
7088- if (builder.needA0WARForSend () &&
7089- curBucket == builder.kernel .getNumRegTotal () +
7090- builder.getNumScalarRegisters ()) {
7091- if (!tokenHonourInstruction (liveInst) || dep != WAR ||
7092- hasSameFunctionID (liveInst, curInst)) {
7093- ++bn_it;
7094- continue ;
7113+ if (builder.needA0WAR ()) {
7114+ const int A0_start =
7115+ builder.kernel .getNumRegTotal () + builder.getNumScalarRegisters ();
7116+ const int A0_end =
7117+ A0_start + builder.getNumAddrRegistersInGRFSizeSWSB () - 1 ;
7118+ if (curBucket >= A0_start && curBucket <= A0_end) {
7119+ if (dep != WAR) {
7120+ ++bn_it;
7121+ continue ;
7122+ }
70957123 }
70967124 }
70977125
@@ -7204,7 +7232,7 @@ void G4_BB_SB::SBDDD(G4_BB *bb, LiveGRFBuckets *&LB,
72047232 if (distanceHonourInstruction (liveInst)) {
72057233 if (dep == RAW &&
72067234 (curBucket < globalRegisterNum)) { // Only need track GRF
7207- // RAW dependence
7235+ // RAW dependence
72087236 LB->killOperand (bn_it);
72097237 setDistance (curFootprint, node, liveNode, false );
72107238 liveNode->setInstKilled (true ); // Instrtuction level kill
0 commit comments