Skip to content

Commit 23d2f7c

Browse files
jgu222igcbot
authored andcommitted
Backout "Remove bf_cvt (#47152)"
Revert "[IGC Refactor][IGC Core]: Remove bf_cvt (#47152)"
1 parent 6096caf commit 23d2f7c

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

IGC/Compiler/CISACodeGen/CISABuilder.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6819,6 +6819,22 @@ namespace IGC
68196819
addressOpnd, srcOpnd));
68206820
}
68216821

6822+
void CEncoder::bf_cvt(CVariable* dst, CVariable* src)
6823+
{
6824+
VISA_PredOpnd* predOpnd = GetFlagOperand(m_encoderState.m_flag);
6825+
VISA_VectorOpnd* dstOpnd = GetDestinationOperand(dst, m_encoderState.m_dstOperand);
6826+
VISA_VectorOpnd* srcOpnd0 = GetSourceOperand(src, m_encoderState.m_srcOperand[0]);
6827+
6828+
V(vKernel->AppendVISADataMovementInst(
6829+
ISA_BF_CVT,
6830+
predOpnd,
6831+
false,
6832+
GetAluEMask(dst),
6833+
visaExecSize(dst->IsUniform()
6834+
? m_encoderState.m_uniformSIMDSize : m_encoderState.m_simdSize),
6835+
dstOpnd,
6836+
srcOpnd0));
6837+
}
68226838

68236839
std::string CEncoder::GetVariableName(CVariable* var)
68246840
{

IGC/Compiler/CISACodeGen/CISABuilder.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ namespace IGC
318318
void dpas(CVariable* dst, CVariable* input, CVariable* weight, PrecisionType weight_precision,
319319
CVariable* actication, PrecisionType activation_precision, uint8_t systolicDepth,
320320
uint8_t repeatCount, bool IsDpasw);
321+
void bf_cvt(CVariable* dst, CVariable* src);
321322
void fcvt(CVariable* dst, CVariable* src);
322323
void Bfn(uint8_t booleanFuncCtrl, CVariable* dst, CVariable* src0, CVariable* src1, CVariable* src2);
323324
void QWGather(CVariable* dst, const ResourceDescriptor& resource, CVariable* offset, unsigned elementSize, unsigned numElems);

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18660,28 +18660,31 @@ void EmitPass::emitfcvt(llvm::GenIntrinsicInst* GII)
1866018660
if (FP_RM != ERoundingMode::ROUND_TO_ANY)
1866118661
SetRoundingMode_FP(FP_RM);
1866218662

18663-
// vISA instruction doesn't support immediate source of type BF
18664-
if (id == GenISAIntrinsic::GenISA_bftof && src->IsImmediate())
18665-
{
18666-
uint32_t imm32 = ((uint32_t)src->GetImmediateValue()) & 0xFFFF;
18667-
imm32 = imm32 << 16; // make it as float immediate
18668-
CVariable* fSrc = m_currShader->ImmToVariable((uint64_t)imm32, ISA_TYPE_F);
18669-
m_encoder->Copy(dst, fSrc);
18670-
m_encoder->Push();
18671-
return;
18663+
// BF_CVT vISA instruction doesn't support immediate source
18664+
if (id == GenISAIntrinsic::GenISA_ftobf ||
18665+
id == GenISAIntrinsic::GenISA_bftof) {
18666+
if (src->IsImmediate()) {
18667+
CVariable* tempMov = m_currShader->GetNewVariable(
18668+
1, src->GetType(), EALIGN_GRF, true, src->getName());
18669+
m_encoder->Copy(tempMov, src);
18670+
m_encoder->Push();
18671+
src = tempMov;
18672+
}
1867218673
}
1867318674

1867418675
if (id == GenISAIntrinsic::GenISA_ftobf ||
1867518676
id == GenISAIntrinsic::GenISA_bftof)
1867618677
{
18678+
/// Use UW as we are not exposing BF for now.
18679+
/// vISA will convert it to BF.
1867718680
CVariable* tDst = nullptr, * tSrc = nullptr;
1867818681
if (id == GenISAIntrinsic::GenISA_ftobf) {
18679-
tDst = m_currShader->GetNewAlias(dst, ISA_TYPE_BF, 0, 0);
18682+
tDst = m_currShader->GetNewAlias(dst, ISA_TYPE_UW, 0, 0);
1868018683
tSrc = src;
1868118684
}
1868218685
else if (id == GenISAIntrinsic::GenISA_bftof) {
1868318686
tDst = dst;
18684-
tSrc = m_currShader->GetNewAlias(src, ISA_TYPE_BF, 0, 0);
18687+
tSrc = m_currShader->GetNewAlias(src, ISA_TYPE_UW, 0, 0);
1868518688
}
1868618689
else {
1868718690
IGC_ASSERT_EXIT_MESSAGE(0, "Something wrong in cvt!");
@@ -18706,7 +18709,7 @@ void EmitPass::emitfcvt(llvm::GenIntrinsicInst* GII)
1870618709
uint32_t stride = (esize >= 8 ? 8 : esize);
1870718710
m_encoder->SetSrcRegion(0, stride, stride, 1);
1870818711
}
18709-
m_encoder->Copy(tDst, tSrc);
18712+
m_encoder->bf_cvt(tDst, tSrc);
1871018713
m_encoder->Push();
1871118714
}
1871218715
}
@@ -18717,7 +18720,7 @@ void EmitPass::emitfcvt(llvm::GenIntrinsicInst* GII)
1871718720
{
1871818721
m_encoder->SetDstSubReg(dstOff);
1871918722
m_encoder->SetSrcSubReg(0, srcOff);
18720-
m_encoder->Copy(tDst, tSrc);
18723+
m_encoder->bf_cvt(tDst, tSrc);
1872118724
m_encoder->Push();
1872218725

1872318726
dstOff += (isDstUniform ? 1 : nsimdsize);
@@ -18730,7 +18733,7 @@ void EmitPass::emitfcvt(llvm::GenIntrinsicInst* GII)
1873018733
CVariable* srcs[2];
1873118734
srcs[0] = src;
1873218735
srcs[1] = GetSymbol(GII->getOperand(1));
18733-
CVariable* tDst = m_currShader->GetNewAlias(dst, ISA_TYPE_BF, 0, 0);
18736+
CVariable* tDst = m_currShader->GetNewAlias(dst, ISA_TYPE_HF, 0, 0);
1873418737
SmallVector<uint32_t, 16> insts;
1873518738
getAllExecsize(insts, nelts);
1873618739
for (int e = 0; e < 2; ++e)
@@ -18755,7 +18758,7 @@ void EmitPass::emitfcvt(llvm::GenIntrinsicInst* GII)
1875518758
uint32_t stride = (esize >= 8 ? 8 : esize);
1875618759
m_encoder->SetSrcRegion(0, stride, stride, 1);
1875718760
}
18758-
m_encoder->Copy(tDst, tSrc);
18761+
m_encoder->bf_cvt(tDst, tSrc);
1875918762
m_encoder->Push();
1876018763
}
1876118764
}
@@ -18767,7 +18770,7 @@ void EmitPass::emitfcvt(llvm::GenIntrinsicInst* GII)
1876718770
m_encoder->SetDstSubReg(2 * dstOff + e);
1876818771
m_encoder->SetDstRegion(2);
1876918772
m_encoder->SetSrcSubReg(0, srcOff);
18770-
m_encoder->Copy(tDst, tSrc);
18773+
m_encoder->bf_cvt(tDst, tSrc);
1877118774
m_encoder->Push();
1877218775

1877318776
dstOff += (isDstUniform ? 1 : nsimdsize);

0 commit comments

Comments
 (0)