Skip to content

Commit 8eb9254

Browse files
weiyu-chenigcbot
authored andcommitted
Fix packed immediate handling on platforms that don't have byte regioning.
1 parent 80368ce commit 8eb9254

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

visa/HWConformity.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -442,40 +442,37 @@ G4_Operand* HWConformity::insertMovBefore(INST_LIST_ITER it, uint32_t srcNum, G4
442442
dcl->getElemType());
443443
}
444444

445-
void HWConformity::fixPackedSource(INST_LIST_ITER it, G4_BB* bb, G4_Type extype)
445+
void HWConformity::fixPackedSource(INST_LIST_ITER it, G4_BB* bb)
446446
{
447447
G4_INST* inst = *it;
448448

449449
bool nonTypeWFound = false, nonTypeFFound = false, incompatibleTypeFound = false;
450450

451451
for (int i = 0; i < inst->getNumSrc(); i++)
452452
{
453-
G4_Operand* src = inst->getSrc(i);
454-
if (!src || !(IS_VTYPE(src->getType())))
453+
auto src = inst->getSrc(i);
454+
if (!src)
455+
{
456+
continue;
457+
}
458+
if (!IS_VTYPE(src->getType()))
455459
{
456460
// Make sure other src operands are of word type only as this is a HW requirement
457-
if (src &&
458-
(src->getType() != Type_W &&
459-
src->getType() != Type_UW))
461+
if (src->getType() != Type_W && src->getType() != Type_UW)
460462
{
461463
nonTypeWFound = true;
462464
}
463-
if (src &&
464-
(src->getType() != Type_F))
465+
if (src->getType() != Type_F)
465466
{
466467
nonTypeFFound = true;
467468
}
468469
continue;
469470
}
470-
G4_Type target_type = Type_W;
471-
if (src->getType() == Type_VF)
472-
{
473-
target_type = Type_F;
474-
}
475-
476-
if (target_type == Type_W && nonTypeWFound == true)
471+
G4_Type target_type = src->getType() == Type_VF ? Type_F : Type_W;
472+
if (target_type == Type_W && (nonTypeWFound || !builder.hasByteALU()))
477473
{
478474
// non-word type src is not allowed to co-exist with :v src
475+
// also if platform lacks byte regioning :v src may be incompatible with later legalization
479476
incompatibleTypeFound = true;
480477
}
481478
else if (target_type == Type_F && nonTypeFFound == true)
@@ -484,10 +481,8 @@ void HWConformity::fixPackedSource(INST_LIST_ITER it, G4_BB* bb, G4_Type extype)
484481
incompatibleTypeFound = true;
485482
}
486483

487-
// Insert a move only if immediate operand is not
488-
// last src operand
489-
if (i != inst->getNumSrc() - 1 ||
490-
incompatibleTypeFound == true)
484+
// Insert a move only if immediate operand is not last src operand
485+
if (i != inst->getNumSrc() - 1 || incompatibleTypeFound == true)
491486
{
492487
inst->setSrc(insertMovBefore(it, i, target_type, bb), i);
493488
}

visa/HWConformity.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ namespace vISA
106106
G4_SubReg_Align getDclAlignment(int opndBytes, G4_INST *inst, bool isScalar);
107107

108108
// HW conformity check functions
109-
void fixPackedSource(INST_LIST_ITER it, G4_BB *bb, G4_Type extype);
109+
void fixPackedSource(INST_LIST_ITER it, G4_BB *bb);
110110
bool fixMathInst(INST_LIST_ITER it, G4_BB *bb);
111111
bool fixMULInst(INST_LIST_ITER &it, G4_BB *bb);
112112
void fixMULHInst(INST_LIST_ITER &i, G4_BB *bb);

visa/ReduceExecSize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ bool HWConformity::fixInstOpndTypeAlign(INST_LIST_ITER i, G4_BB* bb)
162162

163163
if (extypesize == numEltPerGRF<Type_UB>()/2 && inst->opcode() != G4_mov)
164164
{
165-
fixPackedSource(i, bb, extype);
165+
fixPackedSource(i, bb);
166166
extype = inst->getOpExecType(extypesize);
167167
}
168168

visa/VisaToG4/TranslateSend3D.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,10 @@ int IR_Builder::translateVISASampleInfoInst(
122122
else
123123
{
124124
useHeader = false;
125-
msg = createTempVar(8, Type_UD, Any);
125+
msg = createTempVar(getNativeExecSize(), Type_UD, GRFALIGN);
126126
G4_DstRegRegion *dst = createDst(msg->getRegVar(), 0, 0, 1, Type_UD);
127127
G4_Imm* src0Imm = createImm(0, Type_UD);
128-
auto temp = createMov(g4::SIMD8, dst, src0Imm, InstOpt_NoOpt, true);
129-
temp->setOptionOn(InstOpt_WriteEnable);
128+
(void) createMov(getNativeExecSize(), dst, src0Imm, InstOpt_WriteEnable, true);
130129
m0 = createSrc(msg->getRegVar(), 0, 0, getRegionStride1(), Type_UD);
131130
}
132131
// Now create message descriptor

0 commit comments

Comments
 (0)