Skip to content

Commit 75b46bb

Browse files
fangliu2020igcbot
authored andcommitted
Don't swap src operands if the swapping causes invalid datetype combination for mad instruction
Don't swap src0 and src1 of pseudo_mad instruction in HWConformity if the swapping causes invalid datatype combination. For example: pseudo_mad (32) result1(0,0)<1>:d x1(0,0)<2;0>:uw r0.1<0;0>:d z(0,0)<1;0>:d In this case, we swap src0(actually src2) and src1 if src1 is scalar but src0 is not, as src0(actually src2) has no regioning support: pseudo_mad (32) result1(0,0)<1>:d r0.1<0;0>:d x1(0,0)<2;0>:uw z(0,0)<1;0>:d After swapping, the datatype combination is invalid as it changes the datatype combination from (W * D + D) to (D * W + D). If src2(actually src0) is D, HW only supports (W * D + D). Then we wouldn't generate mad, and we generate mul+add instead. But without this swapping, actually we can generate mad as src0(actually src2) is aligned to dst.
1 parent 74c3bcc commit 75b46bb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

visa/HWConformity.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4220,7 +4220,10 @@ bool HWConformity::generateAlign1Mad(G4_BB *bb, INST_LIST_ITER iter) {
42204220
src1->isSrcRegRegion() && src1->asSrcRegRegion()->isScalar()) {
42214221
// Swap src0 and src1 if src1 is scalar but src0 is not, as src2 regioning
42224222
// support is quite limited.
4223-
inst->swapSrc(0, 1);
4223+
// But don't swap if the swapping causes invalid datatype combination,
4224+
// e.g. src0(:w) * src1(:d) -> src0(:d) * src1(:w)
4225+
if (IS_DTYPE(src0->getType()) || !IS_DTYPE(src1->getType()))
4226+
inst->swapSrc(0, 1);
42244227
} else if (isLowPrecisionFloatTy(src0->getType()) &&
42254228
src1->getType() == Type_F) {
42264229
inst->swapSrc(0, 1);

0 commit comments

Comments
 (0)