Skip to content

Commit 9d00a69

Browse files
bcheng0127pszymich
authored andcommitted
fix HW WA
Put the WA at the end of the HW comformity, because HW comformity itself may generate the code pattern which need be updated.
1 parent c688ac4 commit 9d00a69

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

visa/HWConformity.cpp

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5989,7 +5989,7 @@ void HWConformity::conformBB(G4_BB* bb)
59895989
}
59905990
// do this early since otherwise the moves inserted by other passes may still
59915991
// inherit bad regions from the original inst
5992-
fixSrcRegion(i, bb);
5992+
fixSrcRegion(inst);
59935993

59945994
bool changed = fixMov(i, bb);
59955995
if (changed)
@@ -6249,6 +6249,20 @@ void HWConformity::conformBB(G4_BB* bb)
62496249
#endif
62506250
}
62516251

6252+
if (builder.hasBDstWSrc1EvenAlignIssue())
6253+
{
6254+
i = bb->begin(), iEnd = bb->end();
6255+
next_iter = i;
6256+
for (; i != iEnd; i = next_iter)
6257+
{
6258+
++next_iter;
6259+
fixOddAlignSrc1Region(i, bb);
6260+
#ifdef _DEBUG
6261+
verifyG4Kernel(kernel, Optimizer::PI_HWConformityChk, false);
6262+
#endif
6263+
}
6264+
}
6265+
62526266
if (VISA_WA_CHECK(builder.getPWaTable(), Wa_16012725276))
62536267
{
62546268
for (auto it = bb->begin(), itEnd = bb->end(); it != itEnd; ++it)
@@ -7298,8 +7312,8 @@ G4_INST* HWConformity::splitInstWithByteDst(G4_INST* expand_op)
72987312
// 7. Dst.HorzStride must not be 0. -- this needs not to be checked.
72997313
// 8. VertStride must be used to cross GRF register boundaries. This rule implies that
73007314
// elements within a 'Width' cannot cross GRF boundaries.
7301-
void HWConformity::fixSrcRegion(INST_LIST_ITER i, G4_BB *bb) {
7302-
G4_INST *inst = *i;
7315+
void HWConformity::fixSrcRegion(G4_INST *inst) {
7316+
73037317
bool comprInst = isCompressedInst(inst);
73047318
for (int i = 0; i < G4_MAX_SRCS; i++)
73057319
{
@@ -7411,25 +7425,32 @@ void HWConformity::fixSrcRegion(INST_LIST_ITER i, G4_BB *bb) {
74117425
}
74127426
}
74137427
}
7414-
74157428
if (inst->getDst() && !inst->hasNULLDst())
74167429
{
74177430
MUST_BE_TRUE(inst->getDst()->getHorzStride() != 0,
74187431
"Bad source region: Width is greater than execution size.");
7432+
}
7433+
}
74197434

7420-
if (builder.hasBDstWSrc1EvenAlignIssue()) {
7421-
G4_Operand *src1 = inst->getSrc(1);
7422-
if (src1 && src1->isSrcRegRegion()) {
7423-
G4_Operand *dst = inst->getDst();
7424-
if (dst && dst->isDstRegRegion() &&
7425-
dst->asDstRegRegion()->getHorzStride() > 2 &&
7426-
(dst->getType() == Type_B || dst->getType() == Type_UB) &&
7427-
(src1->getType() == Type_W || src1->getType() == Type_UW) &&
7428-
(src1->asSrcRegRegion()->getSubRegOff() % 2)) {
7429-
G4_Operand *new_src1 =
7430-
insertMovBefore(i, 1, src1->getType(), bb, Even_Word);
7431-
inst->setSrc(new_src1, 1);
7432-
}
7435+
void HWConformity::fixOddAlignSrc1Region(INST_LIST_ITER i, G4_BB *bb)
7436+
{
7437+
G4_INST *inst = *i;
7438+
7439+
if (inst->getDst() && !inst->hasNULLDst())
7440+
{
7441+
G4_Operand *src1 = inst->getSrc(1);
7442+
if (src1 && src1->isSrcRegRegion())
7443+
{
7444+
G4_Operand *dst = inst->getDst();
7445+
if (dst && dst->isDstRegRegion() &&
7446+
dst->asDstRegRegion()->getHorzStride() > 2 &&
7447+
(dst->getType() == Type_B || dst->getType() == Type_UB) &&
7448+
(src1->getType() == Type_W || src1->getType() == Type_UW) &&
7449+
(src1->asSrcRegRegion()->getSubRegOff() % 2))
7450+
{
7451+
G4_Operand *new_src1 =
7452+
insertMovBefore(i, 1, src1->getType(), bb, Even_Word);
7453+
inst->setSrc(new_src1, 1);
74337454
}
74347455
}
74357456
}

visa/HWConformity.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ namespace vISA
126126
bool fixAcc(INST_LIST_ITER i, G4_BB* bb);
127127
void fixDstHstride(INST_LIST_ITER i, int extypesize);
128128
void fixMADInst(G4_BB* bb);
129-
void fixSrcRegion(INST_LIST_ITER i, G4_BB *bb);
130-
void conformBB(G4_BB* bb);
129+
void fixSrcRegion(G4_INST *inst);
130+
void fixOddAlignSrc1Region(INST_LIST_ITER i, G4_BB *bb);
131+
void conformBB(G4_BB * bb);
131132
void fixSADA2Inst(G4_BB* bb);
132133
void fixMixedHFInst(G4_BB* bb);
133134
void fixSendInst(G4_BB* bb);

0 commit comments

Comments
 (0)