Skip to content

Commit 685b6ca

Browse files
dlei6gsys_zuul
authored andcommitted
Copy struct by element instead of by byte.
Change-Id: I520c078990b848977177c600bc1a5d11aa5287ae
1 parent 28a4b3e commit 685b6ca

File tree

1 file changed

+16
-23
lines changed

1 file changed

+16
-23
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15835,32 +15835,25 @@ void EmitPass::emitCopyAll(CVariable* Dst, CVariable* Src, llvm::Type* Ty)
1583515835
else if (Ty->isStructTy())
1583615836
{
1583715837
IGC_ASSERT(Dst->GetType() == ISA_TYPE_B && Src->GetType() == ISA_TYPE_B);
15838-
if (Src->IsUniform() == Dst->IsUniform())
15838+
if (!Src->IsUniform() && Dst->IsUniform())
1583915839
{
15840-
IGC_ASSERT(Dst->GetNumberElement() == Src->GetNumberElement());
15841-
emitVectorCopy(Dst, Src, Src->GetNumberElement());
15842-
}
15843-
else if (Src->IsUniform() && !Dst->IsUniform())
15844-
{
15845-
// Copy from uniform src to non-uniform dst
15846-
// We need to expand each element separately since we use the SoA (struct of arrays) layout
15847-
StructType* STy = dyn_cast<StructType>(Ty);
15848-
const StructLayout* SL = m_DL->getStructLayout(STy);
15849-
unsigned nLanes = numLanes(m_currShader->m_dispatchSize);
15850-
for (unsigned i = 0; i < STy->getNumElements(); i++)
15851-
{
15852-
unsigned elementOffset = (unsigned)SL->getElementOffset(i);
15853-
Type* elementType = STy->getElementType(i);
15854-
unsigned numElements = elementType->isVectorTy() ? elementType->getVectorNumElements() : 1;
15855-
VISA_Type visaTy = m_currShader->GetType(elementType);
15856-
CVariable* srcElement = m_currShader->GetNewAlias(Src, visaTy, elementOffset, numElements, true);
15857-
CVariable* dstElement = m_currShader->GetNewAlias(Dst, visaTy, elementOffset * nLanes, numElements * nLanes, false);
15858-
emitCopyAll(dstElement, srcElement, elementType);
15859-
}
15840+
IGC_ASSERT(0 && "Does not support non-uniform to uniform struct copy");
1586015841
}
15861-
else
15842+
15843+
StructType* STy = dyn_cast<StructType>(Ty);
15844+
const StructLayout* SL = m_DL->getStructLayout(STy);
15845+
unsigned srcLanes = Src->IsUniform() ? 1 : numLanes(m_currShader->m_dispatchSize);
15846+
unsigned dstLanes = Dst->IsUniform() ? 1 : numLanes(m_currShader->m_dispatchSize);
15847+
for (unsigned i = 0; i < STy->getNumElements(); i++)
1586215848
{
15863-
IGC_ASSERT(0 && "Does not support non-uniform to uniform struct copy");
15849+
unsigned elementOffset = (unsigned)SL->getElementOffset(i);
15850+
Type* elementType = STy->getElementType(i);
15851+
unsigned numElements = elementType->isVectorTy() ? elementType->getVectorNumElements() : 1;
15852+
VISA_Type visaTy = m_currShader->GetType(elementType);
15853+
15854+
CVariable* srcElement = m_currShader->GetNewAlias(Src, visaTy, elementOffset * srcLanes, numElements * srcLanes, Src->IsUniform());
15855+
CVariable* dstElement = m_currShader->GetNewAlias(Dst, visaTy, elementOffset * dstLanes, numElements * dstLanes, Dst->IsUniform());
15856+
emitCopyAll(dstElement, srcElement, elementType);
1586415857
}
1586515858
}
1586615859
else

0 commit comments

Comments
 (0)