Skip to content

Commit 377899c

Browse files
fangliu2020igcbot
authored andcommitted
[IGC vISA] Fix byte swizzle restriction on src0 in HWConformity
When fix byte swizzle restrictions, we split SIMD2 instruction to fix the illegal operands to generate better codes. But if dst and src have overlap, we should avoid splitting instruction, otherwise there will be a extra mov instructions inserted to resolve the dst/src overlap which is not legalized. Before fix: mov (2) V42(0,14)<1>:w V42(0,14)<2;1,0>:w => mov (2) TV(0,0)<1> V42(0,14)<2;1,0>:w mov (1) V42(0,14)<1>:w TV(0,0)<0;1,0>:w mov (1) V42(0,15)<1>:w TV(0,1)<0;1,0>:w After fix: mov (2) V42(0,14)<1>:w V42(0,14)<2;1,0>:w => mov (2) TV(0,28)<2>:w V42(0,14)<2;1,0>:w mov (2) V42(0,14)<1>:w TV(0,28)<2;1,0>:w
1 parent e57d151 commit 377899c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

visa/HWConformity.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9106,9 +9106,31 @@ void HWConformity::fixByteXBarRestriction(INST_LIST_ITER it, G4_BB *bb) {
91069106
}
91079107

91089108
if (needFix) {
9109+
9110+
// split currently can't handle packed imm
9111+
// Also don't split if src and dst have overlap as it will introduce extra
9112+
// mov which could be illegal. If we further fix the extra illegal mov
9113+
// instruction, we will get worse codes compared to not splitting.
9114+
auto canDoSplit = [](G4_INST *inst, IR_Builder &builder) {
9115+
if (inst->getPredicate() || inst->getCondMod()) {
9116+
return false;
9117+
}
9118+
for (int i = 0, numSrc = inst->getNumSrc(); i < numSrc; ++i) {
9119+
auto ty = inst->getSrc(i)->getType();
9120+
if (IS_VINTTYPE(ty) || IS_VFTYPE(ty)) {
9121+
return false;
9122+
} else {
9123+
G4_CmpRelation rel =
9124+
inst->getDst()->compareOperand(inst->getSrc(i), builder);
9125+
if (rel != Rel_disjoint)
9126+
return false;
9127+
}
9128+
}
9129+
return true;
9130+
};
9131+
91099132
if (inst->getExecSize() == g4::SIMD2 && allDirect &&
9110-
inst->getNumSrc() != 3 && !inst->getPredicate() &&
9111-
!inst->getCondModBase()) {
9133+
inst->getNumSrc() != 3 && canDoSplit(inst, builder)) {
91129134
// just split the inst
91139135
evenlySplitInst(it, bb);
91149136
return;

0 commit comments

Comments
 (0)