@@ -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