Skip to content

Commit 64dd310

Browse files
pratikasharigcbot
authored andcommitted
Allow immediate on src0 or src2 of Align1 ternary ops for
XE+. Certain platforms allow immediate on src0 or src2 of Align1 ternary operations. We fold in immediate operands in such cases. Older platforms have restrictions so we continue to emit a mov for them.
1 parent face9bf commit 64dd310

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

visa/HWCaps.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,4 +888,8 @@ uint32_t getSizeOfSendQueue() const {
888888
}
889889
return 6;
890890
}
891+
892+
bool hasImmOnSrc0Src2ForAlign1Ternary() const {
893+
return getPlatformGeneration() >= PlatformGen::XE;
894+
}
891895
// end HW capabilities

visa/HWConformity.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,8 @@ void HWConformity::fixAlign13SrcInst(INST_LIST_ITER iter, G4_BB *bb) {
13531353
i);
13541354
}
13551355
} else {
1356-
if (inst->getSrc(i)->isImm()) {
1356+
if (inst->getSrc(i)->isImm() &&
1357+
!builder.hasImmOnSrc0Src2ForAlign1Ternary()) {
13571358
canBeImm = false;
13581359
}
13591360
}
@@ -3863,11 +3864,23 @@ bool HWConformity::isGoodAlign1TernarySrc(G4_INST *inst, int srcPos,
38633864
// permanent WA: simd16 inst can't have src0 imm.
38643865
// Instead of splitting, we just add a move
38653866

3866-
if (canBeImm && (srcPos == 0 || srcPos == 2) && src->getTypeSize() <= 2) {
3867+
bool isSigned = IS_SIGNED_INT(src->getType());
3868+
bool isLETwoBytes =
3869+
(src->getTypeSize() <= 2 ||
3870+
G4_Imm::isInTypeRange(src->asImm()->getImm(),
3871+
isSigned ? G4_Type::Type_W : G4_Type::Type_UW));
3872+
if (canBeImm && (srcPos == 0 || srcPos == 2) && isLETwoBytes) {
3873+
bool canInlineImm = true;
38673874
if (VISA_WA_CHECK(builder.getPWaTable(), WaNoSimd16TernarySrc0Imm)) {
3868-
return !isSrc2 && inst->getExecSize() != g4::SIMD16;
3875+
canInlineImm = !isSrc2 && inst->getExecSize() != g4::SIMD16;
38693876
}
3870-
return true;
3877+
if (canInlineImm && src->getTypeSize() > 2) {
3878+
// replace imm to 2-byte type
3879+
auto *shoterImm = builder.createImmWithLowerType(src->asImm()->getImm(),
3880+
src->getType());
3881+
inst->setSrc(shoterImm, srcPos);
3882+
}
3883+
return canInlineImm;
38713884
}
38723885
return false;
38733886
} else if (src->isSrcRegRegion()) {

0 commit comments

Comments
 (0)