@@ -669,36 +669,25 @@ bool SRSubPassAfterRA::isSRCandidateAfterRA(G4_INST *inst,
669
669
return (G4_INST *)nullptr ;
670
670
};
671
671
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 ();
676
672
// if opndNum + offset is defined multiple times, cannobe be removed
677
673
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 ;
683
677
684
678
if (isRemoveAble (movInst)) {
685
679
auto iter = std::find_if (
686
680
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
+ });
694
685
// if multiple defined, cannot be removed
695
686
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));
699
688
} else {
700
689
G4_Operand *src = movInst->getSrc (0 );
701
- regMapBRA regPair (movInst, opndNum, startOffset , src); // mov source
690
+ regMapBRA regPair (movInst, opndNum, offset , src);// mov source
702
691
dstSrcRegs.dstSrcMap .push_back (regPair);
703
692
firstDefID = std::min (firstDefID, def.first ->getLocalId ());
704
693
movInstNum++;
@@ -713,17 +702,15 @@ bool SRSubPassAfterRA::isSRCandidateAfterRA(G4_INST *inst,
713
702
// The offset is the offset of original dst, which is used to identify
714
703
// the original register used in send.
715
704
// The opndNum is the opndNum of send.
716
- regMapBRA regPair (movInst, opndNum, startOffset ,
705
+ regMapBRA regPair (movInst, opndNum, offset ,
717
706
lvnMov->getDst ()); // the lvn mov dst can be reused
718
707
dstSrcRegs.dstSrcMap .push_back (regPair);
719
708
firstDefID = std::min (firstDefID, def.first ->getLocalId ());
720
709
movInstNum++;
721
710
continue ;
722
711
}
723
712
}
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));
727
714
}
728
715
}
729
716
@@ -789,10 +776,9 @@ bool SRSubPassAfterRA::replaceWithSendiAfterRA(G4_BB *bb,
789
776
bool replaced = false ;
790
777
if (j < (int )dstSrcRegs.dstSrcMap .size () &&
791
778
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;
796
782
int srcOffset = src0->getLeftBound () / GRFSize + i;
797
783
int opndOffset = dstSrcRegs.dstSrcMap [j].offset ;
798
784
@@ -833,10 +819,9 @@ bool SRSubPassAfterRA::replaceWithSendiAfterRA(G4_BB *bb,
833
819
bool replaced = false ;
834
820
if (j < (int )dstSrcRegs.dstSrcMap .size () &&
835
821
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;
840
825
int srcOffset = src1->getLeftBound () / GRFSize + i;
841
826
int opndOffset = dstSrcRegs.dstSrcMap [j].offset ;
842
827
0 commit comments