Skip to content

Commit 02ca07e

Browse files
jgu222sys_zuul
authored andcommitted
[Autobackout][FuncReg]Revert of change: 8ca504f
When doing bitcast of immediate, if the dst type has the same size as the original one, it is okay to regenerate imm with dst's type (exisiting code). If the dst type is a vector type, we need to create a temp var, initialized with the imm, and return the alias to the new temp var. Also, simplify emitVectorBitcast to avoid potential redundant mov instructions when src is immeidate. Change-Id: Ibcf35d9317a6cf908a3427165ff7bb81648897e5
1 parent 0768f76 commit 02ca07e

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -857,31 +857,9 @@ CVariable* CShader::GetGlobalCVar(llvm::Value* value)
857857
CVariable* CShader::BitCast(CVariable* var, VISA_Type newType)
858858
{
859859
CVariable* bitCast = nullptr;
860-
uint32_t newEltSz = CEncoder::GetCISADataTypeSize(newType);
861-
uint32_t eltSz = var->GetElemSize();
862-
// Bitcase requires both src and dst have the same size. Thus, they
863-
// are either equal or one is a multiple of the other.
864-
IGC_ASSERT( (newEltSz >= eltSz && (newEltSz % eltSz) == 0)
865-
|| (newEltSz < eltSz && (eltSz% newEltSz) == 0));
866860
if (var->IsImmediate())
867861
{
868-
if (newEltSz == eltSz)
869-
bitCast = ImmToVariable(var->GetImmediateValue(), newType);
870-
else
871-
{
872-
// Need a temp. For example, bitcast i64 0 -> 2xi32
873-
CVariable* tmp = GetNewVariable(
874-
1,
875-
var->GetType(),
876-
CEncoder::GetCISADataTypeAlignment(var->GetType()),
877-
true,
878-
1,
879-
"vecImmBitCast");
880-
encoder.Copy(tmp, var);
881-
encoder.Push();
882-
883-
bitCast = GetNewAlias(tmp, newType, 0, 0);
884-
}
862+
bitCast = ImmToVariable(var->GetImmediateValue(), newType);
885863
}
886864
else
887865
{

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14460,21 +14460,26 @@ void EmitPass::emitVectorBitCast(llvm::BitCastInst* BCI)
1446014460
dstNElts = 1;
1446114461
}
1446214462

14463-
uint32_t dstEltBytes = int_cast<uint32_t>((unsigned int)dstEltTy->getPrimitiveSizeInBits() / 8);
14464-
uint32_t srcEltBytes = int_cast<uint32_t>((unsigned int)srcEltTy->getPrimitiveSizeInBits() / 8);
1446514463
if (src->IsImmediate())
1446614464
{
14467-
IGC_ASSERT((dstNElts * dstEltBytes) == srcEltBytes && srcNElts == 1);
14468-
CVariable* tmp = m_currShader->GetNewAlias(m_destination, src->GetType(), 0, 0);
14469-
m_encoder->Copy(tmp, src);
14465+
CVariable* reg = m_currShader->GetNewVariable(
14466+
1,
14467+
src->GetType(),
14468+
m_encoder->GetCISADataTypeAlignment(src->GetType()),
14469+
true,
14470+
1, CName::NONE);
14471+
14472+
m_encoder->Copy(reg, src);
1447014473
m_encoder->Push();
14471-
return;
14474+
14475+
src = reg;
1447214476
}
1447314477

1447414478
uint32_t width = numLanes(m_currShader->m_SIMDSize);
14479+
uint32_t dstEltBytes = int_cast<uint32_t>((unsigned int)dstEltTy->getPrimitiveSizeInBits() / 8);
14480+
uint32_t srcEltBytes = int_cast<uint32_t>((unsigned int)srcEltTy->getPrimitiveSizeInBits() / 8);
1447514481
bool srcUniform = src->IsUniform();
1447614482
bool dstUniform = m_destination->IsUniform();
14477-
1447814483
if (srcUniform && dstUniform &&
1447914484
(dstNElts == 2 || dstNElts == 4 || dstNElts == 8) &&
1448014485
m_destination != src &&

0 commit comments

Comments
 (0)