Skip to content

Commit 8553c8d

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 945aad6: Fix bug of sendg
For multiple define registers, don't remove the corresponding mov instruction
1 parent 885fc99 commit 8553c8d

File tree

1 file changed

+17
-32
lines changed

1 file changed

+17
-32
lines changed

visa/Passes/SRSubstitution.cpp

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -669,36 +669,25 @@ bool SRSubPassAfterRA::isSRCandidateAfterRA(G4_INST *inst,
669669
return (G4_INST *)nullptr;
670670
};
671671

672-
// The source opndNum of send instruction which was defined
673-
Gen4_Operand_Number opndNum = (*I).second;
674-
unsigned srcStartGRF = inst->getOperand(opndNum)->getLinearizedStart() /
675-
builder.getGRFSize();
676672
//if opndNum + offset is defined multiple times, cannobe be removed
677673
G4_Operand *dst = movInst->getDst();
678-
unsigned startOffset =
679-
(dst->getLinearizedStart() / builder.getGRFSize()) - srcStartGRF;
680-
unsigned dstSize = (dst->getLinearizedEnd() - dst->getLinearizedStart() +
681-
builder.getGRFSize() - 1) /
682-
builder.getGRFSize();
674+
unsigned offset = dst->getLeftBound() / builder.getGRFSize();
675+
// The source opndNum of send instruction which was defined
676+
Gen4_Operand_Number opndNum = (*I).second;
683677

684678
if (isRemoveAble(movInst)) {
685679
auto iter = std::find_if(
686680
dstSrcRegs.dstSrcMap.begin(), dstSrcRegs.dstSrcMap.end(),
687-
[opndNum, dst](regMapBRA regmap) {
688-
return regmap.opndNum == opndNum &&
689-
!((regmap.inst->getDst()->getLinearizedStart() >
690-
dst->getLinearizedEnd()) ||
691-
(dst->getLinearizedStart() >
692-
regmap.inst->getDst()->getLinearizedEnd()));
693-
});
681+
[opndNum, offset](regMapBRA regmap) {
682+
return regmap.opndNum == opndNum &&
683+
regmap.offset == offset;
684+
});
694685
// if multiple defined, cannot be removed
695686
if (iter != dstSrcRegs.dstSrcMap.end()) {
696-
for (unsigned offset = startOffset; offset < dstSize; offset++) {
697-
notRemoveableMap.push_back(std::make_pair(opndNum, offset));
698-
}
687+
notRemoveableMap.push_back(std::make_pair(opndNum, offset));
699688
} else {
700689
G4_Operand *src = movInst->getSrc(0);
701-
regMapBRA regPair(movInst, opndNum, startOffset, src); // mov source
690+
regMapBRA regPair(movInst, opndNum, offset, src);//mov source
702691
dstSrcRegs.dstSrcMap.push_back(regPair);
703692
firstDefID = std::min(firstDefID, def.first->getLocalId());
704693
movInstNum++;
@@ -713,17 +702,15 @@ bool SRSubPassAfterRA::isSRCandidateAfterRA(G4_INST *inst,
713702
// The offset is the offset of original dst, which is used to identify
714703
// the original register used in send.
715704
// The opndNum is the opndNum of send.
716-
regMapBRA regPair(movInst, opndNum, startOffset,
705+
regMapBRA regPair(movInst, opndNum, offset,
717706
lvnMov->getDst()); // the lvn mov dst can be reused
718707
dstSrcRegs.dstSrcMap.push_back(regPair);
719708
firstDefID = std::min(firstDefID, def.first->getLocalId());
720709
movInstNum++;
721710
continue;
722711
}
723712
}
724-
for (unsigned offset = startOffset; offset < dstSize; offset++) {
725-
notRemoveableMap.push_back(std::make_pair(opndNum, offset));
726-
}
713+
notRemoveableMap.push_back(std::make_pair(opndNum, offset));
727714
}
728715
}
729716

@@ -789,10 +776,9 @@ bool SRSubPassAfterRA::replaceWithSendiAfterRA(G4_BB *bb,
789776
bool replaced = false;
790777
if (j < (int)dstSrcRegs.dstSrcMap.size() &&
791778
dstSrcRegs.dstSrcMap[j].opndNum == Opnd_src0) {
792-
int opndSize =
793-
(dstSrcRegs.dstSrcMap[j].opnd->getLinearizedEnd() -
794-
dstSrcRegs.dstSrcMap[j].opnd->getLinearizedStart() + GRFSize - 1) /
795-
GRFSize;
779+
int opndSize = (dstSrcRegs.dstSrcMap[j].opnd->getLinearizedEnd() -
780+
dstSrcRegs.dstSrcMap[j].opnd->getLinearizedStart() + 1) /
781+
GRFSize;
796782
int srcOffset = src0->getLeftBound() / GRFSize + i;
797783
int opndOffset = dstSrcRegs.dstSrcMap[j].offset;
798784

@@ -833,10 +819,9 @@ bool SRSubPassAfterRA::replaceWithSendiAfterRA(G4_BB *bb,
833819
bool replaced = false;
834820
if (j < (int)dstSrcRegs.dstSrcMap.size() &&
835821
dstSrcRegs.dstSrcMap[j].opndNum == Opnd_src1) {
836-
int opndSize =
837-
(dstSrcRegs.dstSrcMap[j].opnd->getLinearizedEnd() -
838-
dstSrcRegs.dstSrcMap[j].opnd->getLinearizedStart() + GRFSize - 1) /
839-
GRFSize;
822+
int opndSize = (dstSrcRegs.dstSrcMap[j].opnd->getLinearizedEnd() -
823+
dstSrcRegs.dstSrcMap[j].opnd->getLinearizedStart() + 1) /
824+
GRFSize;
840825
int srcOffset = src1->getLeftBound() / GRFSize + i;
841826
int opndOffset = dstSrcRegs.dstSrcMap[j].offset;
842827

0 commit comments

Comments
 (0)