Skip to content

Commit 7ed739a

Browse files
anikaushikigcbot
authored andcommitted
Enable copy propagation of operands with send instructions
IGC currently does not allow copy propagation of operands between mov and send instructions. Enabling this can result in performance improvement through reduction of instruction count; instruction count is reduced through elimination of mov instructions.
1 parent 289297d commit 7ed739a

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

visa/G4_IR.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,11 +1866,29 @@ bool G4_INST::canPropagateTo(G4_INST *useInst, Gen4_Operand_Number opndNum,
18661866
}
18671867
}
18681868

1869-
// The following are copied from local dataflow analysis.
1870-
// TODO: re-examine..
1871-
if (((opndNum == Opnd_src0 && useInst->isSend()) && !statelessAddr) ||
1872-
(opndNum == Opnd_src1 && useInst->isSplitSend())) {
1873-
return false;
1869+
// allow copy propagation with send instruction under following conditions
1870+
// 1. src operand is not an immediate value
1871+
// 2. src and dst have same type and # of elements
1872+
// 3. src is grf aligned
1873+
if ((opndNum == Opnd_src0 && useInst->isSend()) ||
1874+
(opndNum == Opnd_src1 && useInst->isSplitSend())) {
1875+
1876+
// check platform gen; apply this optimization only for Gen11 and beyond
1877+
// due to HW restriction where src0 and src1 operands must not overlap
1878+
if (getBuilder().getPlatformGeneration() < PlatformGen::GEN11) {
1879+
return false;
1880+
}
1881+
if (src->isImm()) return false;
1882+
if (src->getTopDcl()->getNumElems() != dst->getTopDcl()->getNumElems())
1883+
return false;
1884+
if (MT != G4_INST::Copy) return false;
1885+
// EOT messages have specific constraints on register range for src0, src1
1886+
// for now, do not do copy propaation on src0, src1 for eot sends
1887+
if (useInst->isEOT()) return false;
1888+
// Check alignment last as isOpndAligned will change the alignment
1889+
if (!getBuilder().tryToAlignOperand(src, getBuilder().numEltPerGRF<Type_UB>())) {
1890+
return false;
1891+
}
18741892
}
18751893

18761894
auto isFloatPseudoMAD = [](G4_INST *inst) {

0 commit comments

Comments
 (0)