Skip to content

Commit

Permalink
Fix a bug in HWConformity for mad with mixed byte and
Browse files Browse the repository at this point in the history
word type source operands.

For mad with mixed byte and word type source operands, HWConformity fix
should insert mov instruction to convert the byte type operand to word
type temp.
  • Loading branch information
kychendev authored and igcbot committed Oct 10, 2023
1 parent 73c4e5e commit 5e5a31e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions visa/HWConformity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4230,6 +4230,8 @@ bool HWConformity::generateAlign1Mad(G4_BB *bb, INST_LIST_ITER iter) {

// check src
bool canBeImm = true;
bool anyByteSrc = false;
bool allByteSrc = true;
for (int k = inst->getNumSrc() - 1; k >= 0; k--) {
G4_Operand *src = inst->getSrc(k);
if (!isGoodAlign1TernarySrc(inst, k, canBeImm)) {
Expand Down Expand Up @@ -4279,6 +4281,23 @@ bool HWConformity::generateAlign1Mad(G4_BB *bb, INST_LIST_ITER iter) {
canBeImm = false;
}
}
if (IS_BTYPE(inst->getSrc(k)->getType())) {
anyByteSrc = true;
}
else {
allByteSrc = false;
}
}

if (anyByteSrc && !(allByteSrc && IS_WTYPE(inst->getDst()->getType()))) {
for (int k = inst->getNumSrc() - 1; k >= 0; k--) {
G4_Operand *src = inst->getSrc(k);
G4_Type srcType = src->getType();
if (IS_BTYPE(srcType)) {
G4_Type newSrcType = IS_UNSIGNED_INT(srcType) ? Type_UW : Type_W;
inst->setSrc(insertMovBefore(iter, k, newSrcType, bb), k);
}
}
}

inst->setOpcode(G4_mad);
Expand Down

0 comments on commit 5e5a31e

Please sign in to comment.